Skip to content
Snippets Groups Projects
Commit faca7c10 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[libraries][tests] Add tests for field query string handling of PUT

parent 9323e654
No related branches found
No related tags found
1 merge request!327Refactor update creation api
This commit is part of merge request !327. Comments created here will be created in the context of that merge request.
......@@ -835,7 +835,7 @@ class LibraryUpdate(LibrariesAPIBase):
response = self.client.put(self.url)
self.checkResponse(response, 200, content_type="application/json")
def test_successfull_update(self):
def test_successful_update(self):
self.login_jackdoe()
code = b"import numpy as np"
......@@ -867,7 +867,54 @@ class LibraryUpdate(LibrariesAPIBase):
)
self.assertEqual(storage.code.load(), code)
def test_successfull_update_description_only(self):
def test_successful_update_with_specific_return_field(self):
self.login_jackdoe()
code = b"""import numpy as np"""
response = self.client.put(
self.url,
json.dumps(
{
"description": "blah",
"declaration": LibrariesAPIBase.UPDATE,
"code": code,
}
),
content_type="application/json",
QUERY_STRING="fields=code",
)
self.checkResponse(response, 200, content_type="application/json")
answer = response.json()
self.assertEqual(len(answer), 1)
self.assertTrue("code" in answer)
def test_successful_update_with_specific_return_several_fields(self):
self.login_jackdoe()
code = b"""import numpy as np"""
response = self.client.put(
self.url,
json.dumps(
{
"description": "blah",
"declaration": LibrariesAPIBase.UPDATE,
"code": code,
}
),
content_type="application/json",
QUERY_STRING="fields=code,description",
)
self.checkResponse(response, 200, content_type="application/json")
answer = response.json()
self.assertEqual(len(answer), 2)
self.assertTrue("code" in answer)
self.assertTrue("description" in answer)
def test_successful_update_description_only(self):
self.login_jackdoe()
response = self.client.put(
......@@ -883,7 +930,7 @@ class LibraryUpdate(LibrariesAPIBase):
)
self.assertEqual(library.description, b"blah")
def test_successfull_update_declaration_only(self):
def test_successful_update_declaration_only(self):
self.login_jackdoe()
response = self.client.put(
......@@ -905,7 +952,7 @@ class LibraryUpdate(LibrariesAPIBase):
json.loads(storage.json.load()), json.loads(LibrariesAPIBase.UPDATE)
)
def test_successfull_update_code_only(self):
def test_successful_update_code_only(self):
self.login_jackdoe()
code = b"import numpy as np"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment