Last change
on this file since 8082efd was
713070a,
checked in by OpenGnSys Support Team <soporte-og@…>, 6 years ago
|
#915 Add test for POST /image/create/basic REST API
This test covers 3 scenarios:
- Correct usage.
- Incorrect usage, without payload.
- Incorrect usage, use this command with GET.
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | import requests |
---|
2 | import unittest |
---|
3 | |
---|
4 | class TestPostCreateBasicImageMethods(unittest.TestCase): |
---|
5 | |
---|
6 | def setUp(self): |
---|
7 | self.url = 'http://localhost:8888/image/create/basic' |
---|
8 | self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'} |
---|
9 | self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ], |
---|
10 | 'disk': '1', |
---|
11 | 'partition': '1', |
---|
12 | 'code': '131', |
---|
13 | 'id': '8', |
---|
14 | 'name': 'debianbasica', |
---|
15 | 'repository': '192.168.56.10', |
---|
16 | 'sync_params':{'sync': '1', |
---|
17 | 'diff': '0', |
---|
18 | 'remove': '1', |
---|
19 | 'compress': '0', |
---|
20 | 'cleanup': '0', |
---|
21 | 'cache': '0', |
---|
22 | 'cleanup_cache': '0', |
---|
23 | 'remove_dst': '0'} } |
---|
24 | |
---|
25 | def test_post(self): |
---|
26 | returned = requests.post(self.url, headers=self.headers, json=self.json) |
---|
27 | self.assertEqual(returned.status_code, 200) |
---|
28 | |
---|
29 | def test_no_payload(self): |
---|
30 | returned = requests.post(self.url, headers=self.headers, json=None) |
---|
31 | self.assertEqual(returned.status_code, 400) |
---|
32 | |
---|
33 | def test_get(self): |
---|
34 | returned = requests.get(self.url, headers=self.headers) |
---|
35 | self.assertEqual(returned.status_code, 405) |
---|
36 | |
---|
37 | if __name__ == '__main__': |
---|
38 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.