Last change
on this file since ee2e16a was
b4d2890,
checked in by OpenGnSys Support Team <soporte-og@…>, 6 years ago
|
#915 Add test for POST /image/create 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.0 KB
|
Rev | Line | |
---|
[b4d2890] | 1 | import requests |
---|
| 2 | import unittest |
---|
| 3 | |
---|
| 4 | class TestPostCreateImageMethods(unittest.TestCase): |
---|
| 5 | |
---|
| 6 | def setUp(self): |
---|
| 7 | self.url = 'http://localhost:8888/image/create' |
---|
| 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' : '1', |
---|
| 13 | 'id' : '1', |
---|
| 14 | 'name' : 'test', |
---|
| 15 | 'repository' : '192.168.2.4' } |
---|
| 16 | |
---|
| 17 | def test_post(self): |
---|
| 18 | returned = requests.post(self.url, headers=self.headers, json=self.json) |
---|
| 19 | self.assertEqual(returned.status_code, 200) |
---|
| 20 | |
---|
| 21 | def test_no_payload(self): |
---|
| 22 | returned = requests.post(self.url, headers=self.headers, json=None) |
---|
| 23 | self.assertEqual(returned.status_code, 400) |
---|
| 24 | |
---|
| 25 | def test_get(self): |
---|
| 26 | returned = requests.get(self.url, headers=self.headers) |
---|
| 27 | self.assertEqual(returned.status_code, 405) |
---|
| 28 | |
---|
| 29 | if __name__ == '__main__': |
---|
| 30 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.