Last change
on this file since 1d451ac was
1d451ac,
checked in by OpenGnSys Support Team <soporte-og@…>, 5 years ago
|
#915 Fix several test errors
Test 0006: add json to GET /session and update expected return code.
Test 0012: add json to GET /software and update expected return code (200),
in this case json fields are integer, not string.
Test 0020: remove it, /image/create/incremental does not exist anymore.
Test 0021: same as before for /image/restore/basic
Test 0022: same as before for /image/restore/incremental
Test 0023: rename to test_0020.
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[b35438d] | 1 | import requests |
---|
| 2 | import unittest |
---|
| 3 | |
---|
| 4 | class TestPostSessionMethods(unittest.TestCase): |
---|
| 5 | |
---|
| 6 | def setUp(self): |
---|
[a887c7b] | 7 | self.url = 'http://localhost:8888/session' |
---|
[eae2385] | 8 | self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'} |
---|
[b35438d] | 9 | self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ], |
---|
| 10 | 'disk' : '0', 'partition' : '1'} |
---|
| 11 | |
---|
| 12 | def test_post(self): |
---|
[eae2385] | 13 | returned = requests.post(self.url, headers=self.headers, json=self.json) |
---|
[b35438d] | 14 | self.assertEqual(returned.status_code, 200) |
---|
| 15 | |
---|
[65cc7c1] | 16 | def test_no_payload(self): |
---|
| 17 | returned = requests.post(self.url, headers=self.headers, json=None) |
---|
| 18 | self.assertEqual(returned.status_code, 400) |
---|
| 19 | |
---|
[abd2b91] | 20 | def test_malformed_payload(self): |
---|
| 21 | for parameter in self.json: |
---|
| 22 | malformed_payload = self.json.copy() |
---|
| 23 | malformed_payload.pop(parameter) |
---|
| 24 | returned = requests.post(self.url, |
---|
| 25 | headers=self.headers, |
---|
| 26 | json=malformed_payload) |
---|
| 27 | self.assertEqual(returned.status_code, 400) |
---|
| 28 | |
---|
[b35438d] | 29 | def test_get(self): |
---|
[1d451ac] | 30 | returned = requests.get(self.url, headers=self.headers, json={ 'client': ['192.168.56.11'] }) |
---|
[55edb40] | 31 | self.assertEqual(returned.status_code, 405) |
---|
[b35438d] | 32 | |
---|
| 33 | if __name__ == '__main__': |
---|
| 34 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.