source: ogServer-Git/tests/units/test_0021_post_image_restore_basic.py @ 1f55beb

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

#915 Add test for POST /image/restore/basic 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.6 KB
Line 
1import requests
2import unittest
3
4class TestPostRestoreBasicImageMethods(unittest.TestCase):
5
6    def setUp(self):
7        self.url = 'http://localhost:8888/image/restore/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                      'id': '9',
13                      'name': 'test',
14                      'repository': '192.168.56.10',
15                      'profile': '17',
16                      'type': 'UNICAST',
17                      'sync_params':{'path': '',
18                                     'method': '1',
19                                     'sync': '1',
20                                     'diff': '0',
21                                     'remove': '1',
22                                     'compress': '0',
23                                     'cleanup': '0',
24                                     'cache': '0',
25                                     'cleanup_cache': '0',
26                                     'remove_dst': '0'} }
27
28    def test_post(self):
29        returned = requests.post(self.url, headers=self.headers, json=self.json)
30        self.assertEqual(returned.status_code, 200)
31
32    def test_no_payload(self):
33        returned = requests.post(self.url, headers=self.headers, json=None)
34        self.assertEqual(returned.status_code, 400)
35
36    def test_get(self):
37        returned = requests.get(self.url, headers=self.headers)
38        self.assertEqual(returned.status_code, 405)
39
40if __name__ == '__main__':
41    unittest.main()
Note: See TracBrowser for help on using the repository browser.