source: ogServer-Git/tests/units/test_0020_post_image_create_incremental.py @ 20f935b

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

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