summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJavier Sánchez Parra <jsanchez@soleta.eu>2021-05-31 10:56:13 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-05-31 13:01:47 +0200
commit41fad11408daf3769ff1774390357caf6dd50a25 (patch)
treed0ebfc4ede4628eee0f38be90536315994356dc6 /tests
parentee2f909dbee5ed204258d013f27adb1d70bf5926 (diff)
#942 Add POST /procedure/add method
This method adds a procedure associated with a center to the database. Required payload parameters are center and name, description is optional. Note: ogServer does not allow to add more than one procedure with the same name and center. Request: POST /procedure/add { "center": "1" "name": "procedure1" "description": "My procedure" } Response: 200 OK This commit also adds unit tests for /procedure/add POST method.
Diffstat (limited to 'tests')
-rw-r--r--tests/units/test_0033_post_procedure_add.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/units/test_0033_post_procedure_add.py b/tests/units/test_0033_post_procedure_add.py
new file mode 100644
index 0000000..b31ac70
--- /dev/null
+++ b/tests/units/test_0033_post_procedure_add.py
@@ -0,0 +1,39 @@
+import requests
+import unittest
+
+class TestPostProcedureAddMethods(unittest.TestCase):
+
+ def setUp(self):
+ self.url = 'http://localhost:8888/procedure/add'
+ self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
+ self.full_json = { "center": "1",
+ "name": "procedure1",
+ "description": "procedure test" }
+ self.minimal_json = { "center": "1",
+ "name": "procedure2" }
+ self.duplicated_procedure_json = { "center": "1",
+ "name": "repeated_procedure" }
+
+ def test_post(self):
+ returned = requests.post(self.url, headers=self.headers,
+ json=self.full_json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_post_only_required_fields(self):
+ returned = requests.post(self.url, headers=self.headers,
+ json=self.minimal_json)
+ self.assertEqual(returned.status_code, 200)
+
+ def test_post_duplicated_procedure(self):
+ requests.post(self.url, headers=self.headers,
+ json=self.duplicated_procedure_json)
+ returned = requests.post(self.url, headers=self.headers,
+ json=self.duplicated_procedure_json)
+ self.assertEqual(returned.status_code, 400)
+
+ def test_get(self):
+ returned = requests.get(self.url, headers=self.headers)
+ self.assertEqual(returned.status_code, 405)
+
+if __name__ == '__main__':
+ unittest.main()