source: ogServer-Git/tests/units/test_0017_post_image_restore.py @ 1cdbc5f

Last change on this file since 1cdbc5f was ba3b1ad, checked in by OpenGnSys Support Team <soporte-og@…>, 5 years ago

#915 Add test for POST /image/restore REST API

This test covers 3 scenarios:

  1. Correct usage.
  2. Incorrect usage, without payload.
  3. Incorrect usage, use this command with GET.
  • Property mode set to 100644
File size: 1.1 KB
Line 
1import requests
2import unittest
3
4class TestPostRestoreImageMethods(unittest.TestCase):
5
6    def setUp(self):
7        self.url = 'http://localhost:8888/image/restore'
8        self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
9        self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ],
10                      'disk' : '1',
11                      'partition' : '1',
12                      'name' : 'test',
13                      'repository' : '192.168.56.10',
14                      'type' : 'UNICAST',
15                      'profile': '1',
16                      'id': '1' }
17
18    def test_post(self):
19        returned = requests.post(self.url, headers=self.headers, json=self.json)
20        self.assertEqual(returned.status_code, 200)
21
22    def test_no_payload(self):
23        returned = requests.post(self.url, headers=self.headers, json=None)
24        self.assertEqual(returned.status_code, 400)
25
26    def test_get(self):
27        returned = requests.get(self.url, headers=self.headers)
28        self.assertEqual(returned.status_code, 405)
29
30if __name__ == '__main__':
31    unittest.main()
Note: See TracBrowser for help on using the repository browser.