source: ogServer-Git/tests/units/test_0033_post_procedure_add.py @ 41fad11

Last change on this file since 41fad11 was 41fad11, checked in by OpenGnSys Support Team <soporte-og@…>, 3 years ago

#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.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1import requests
2import unittest
3
4class TestPostProcedureAddMethods(unittest.TestCase):
5
6    def setUp(self):
7        self.url = 'http://localhost:8888/procedure/add'
8        self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
9        self.full_json = { "center": "1",
10                           "name": "procedure1",
11                           "description": "procedure test" }
12        self.minimal_json = { "center": "1",
13                              "name": "procedure2" }
14        self.duplicated_procedure_json = { "center": "1",
15                                           "name": "repeated_procedure" }
16
17    def test_post(self):
18        returned = requests.post(self.url, headers=self.headers,
19                                 json=self.full_json)
20        self.assertEqual(returned.status_code, 200)
21
22    def test_post_only_required_fields(self):
23        returned = requests.post(self.url, headers=self.headers,
24                                 json=self.minimal_json)
25        self.assertEqual(returned.status_code, 200)
26
27    def test_post_duplicated_procedure(self):
28        requests.post(self.url, headers=self.headers,
29                                 json=self.duplicated_procedure_json)
30        returned = requests.post(self.url, headers=self.headers,
31                                 json=self.duplicated_procedure_json)
32        self.assertEqual(returned.status_code, 400)
33
34    def test_get(self):
35        returned = requests.get(self.url, headers=self.headers)
36        self.assertEqual(returned.status_code, 405)
37
38if __name__ == '__main__':
39    unittest.main()
Note: See TracBrowser for help on using the repository browser.