source: ogServer-Git/tests/units/test_0019_post_image_create_basic.py @ b5722de

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

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