Last change
on this file since 40d4279 was
4d98bdf,
checked in by OpenGnSys Support Team <soporte-og@…>, 5 years ago
|
#915 Test malformed payload for POST /clients
This test covers requests that do not contain 1 of the parameters in their
payloads.
|
-
Property mode set to
100644
|
File size:
834 bytes
|
Rev | Line | |
---|
[c39b1f3] | 1 | import requests |
---|
| 2 | import unittest |
---|
| 3 | |
---|
| 4 | class TestPostClientsMethods(unittest.TestCase): |
---|
| 5 | |
---|
| 6 | def setUp(self): |
---|
| 7 | self.url = 'http://localhost:8888/clients' |
---|
[eae2385] | 8 | self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'} |
---|
[c39b1f3] | 9 | self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] } |
---|
| 10 | |
---|
| 11 | def test_post(self): |
---|
[eae2385] | 12 | returned = requests.post(self.url, headers=self.headers, json=self.json) |
---|
[c39b1f3] | 13 | self.assertEqual(returned.status_code, 200) |
---|
| 14 | |
---|
[65cc7c1] | 15 | def test_no_payload(self): |
---|
| 16 | returned = requests.post(self.url, headers=self.headers, json=None) |
---|
| 17 | self.assertEqual(returned.status_code, 400) |
---|
| 18 | |
---|
[4d98bdf] | 19 | def test_malformed_payload(self): |
---|
| 20 | returned = requests.post(self.url, headers=self.headers, json={}) |
---|
| 21 | self.assertEqual(returned.status_code, 400) |
---|
| 22 | |
---|
[c39b1f3] | 23 | if __name__ == '__main__': |
---|
| 24 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.