diff --git a/beat/web/algorithms/tests/tests_api.py b/beat/web/algorithms/tests/tests_api.py index cd1c829f2e58e5addf8508d3e94466a854e92044..d8c1c84926c4a7f92504e1cd7c5cd1bb81fd1083 100755 --- a/beat/web/algorithms/tests/tests_api.py +++ b/beat/web/algorithms/tests/tests_api.py @@ -1231,7 +1231,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): 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""" @@ -1263,23 +1263,69 @@ class AlgorithmUpdate(AlgorithmsAPIBase): ) 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"}), + json.dumps( + { + "description": "blah", + "declaration": AlgorithmsAPIBase.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": AlgorithmsAPIBase.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( + self.url, + json.dumps({"description": "blah"}), + content_type="application/json", + ) + + self.checkResponse(response, 200, content_type="application/json") algorithm = Algorithm.objects.get( author__username="jackdoe", name="personal", version=1 ) self.assertEqual(algorithm.description, b"blah") - def test_successfull_declaration_only(self): + def test_successful_declaration_only(self): self.login_jackdoe() response = self.client.put( @@ -1301,7 +1347,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): json.loads(storage.json.load()), json.loads(AlgorithmsAPIBase.UPDATE) ) - def test_successfull_update_code_only(self): + def test_successful_update_code_only(self): self.login_jackdoe() code = b"""import pandas""" @@ -1321,7 +1367,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): self.assertTrue(storage.exists()) self.assertEqual(storage.code.load(), code) - def test_successfull_update_change_input_name(self): + def test_successful_update_change_input_name(self): declaration = """{ "language": "python", "splittable": false, @@ -1368,7 +1414,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): self.assertFalse(endpoint.input) self.assertEqual(endpoint.dataformat.fullname(), "johndoe/single_integer/1") - def test_successfull_update_change_input_format(self): + def test_successful_update_change_input_format(self): declaration = """{ "language": "python", "splittable": false, @@ -1420,7 +1466,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): self.assertFalse(endpoint.input) self.assertEqual(endpoint.dataformat.fullname(), "johndoe/single_integer/1") - def test_successfull_update_change_output_name(self): + def test_successful_update_change_output_name(self): declaration = """{ "language": "python", "splittable": false, @@ -1473,7 +1519,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): self.assertFalse(endpoint.input) self.assertEqual(endpoint.dataformat.fullname(), "johndoe/single_integer/1") - def test_successfull_update_change_output_format(self): + def test_successful_update_change_output_format(self): declaration = """{ "language": "python", "splittable": false, @@ -1525,7 +1571,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): self.assertFalse(endpoint.input) self.assertEqual(endpoint.dataformat.fullname(), "jackdoe/single_float/1") - def test_successfull_update_add_input(self): + def test_successful_update_add_input(self): declaration = """{ "language": "python", "splittable": false, @@ -1577,7 +1623,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): self.assertFalse(endpoint.input) self.assertEqual(endpoint.dataformat.fullname(), "johndoe/single_integer/1") - def test_successfull_update_remove_input(self): + def test_successful_update_remove_input(self): declaration = """{ "language": "python", "splittable": false, @@ -1619,7 +1665,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): self.assertFalse(endpoint.input) self.assertEqual(endpoint.dataformat.fullname(), "johndoe/single_integer/1") - def test_successfull_update_add_output(self): + def test_successful_update_add_output(self): declaration = """{ "language": "python", "splittable": false, @@ -1671,7 +1717,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): self.assertFalse(endpoint.input) self.assertEqual(endpoint.dataformat.fullname(), "johndoe/single_integer/1") - def test_successfull_update_remove_output(self): + def test_successful_update_remove_output(self): declaration1 = """{ "language": "python", "splittable": false, @@ -1754,7 +1800,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): self.assertFalse(endpoint.input) self.assertEqual(endpoint.dataformat.fullname(), "johndoe/single_integer/1") - def test_successfull_update_change_input_to_output(self): + def test_successful_update_change_input_to_output(self): declaration = """{ "language": "python", "splittable": false, @@ -1802,7 +1848,7 @@ class AlgorithmUpdate(AlgorithmsAPIBase): self.assertFalse(endpoint.input) self.assertEqual(endpoint.dataformat.fullname(), "johndoe/single_integer/1") - def test_successfull_update_change_output_to_input(self): + def test_successful_update_change_output_to_input(self): declaration1 = """{ "language": "python", "splittable": false, @@ -1940,7 +1986,7 @@ class AlgorithmBinaryUpdate(AlgorithmsAPIBase): response = self.client.post(self.url, {"binary": None}) self.checkResponse(response, 400) - def test_successfull_update(self): + def test_successful_update(self): self.login_jackdoe() response = self.client.post(self.url, {"binary": self.updated_binary_file})