source: ogServer-Git/tests/units/test_0023_post_run_schedule.py @ 8082efd

Last change on this file since 8082efd was 2bc2490, checked in by OpenGnSys Support Team <soporte-og@…>, 5 years ago

#915 Add test for POST /run/schedule 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: 819 bytes
RevLine 
[2bc2490]1import requests
2import unittest
3
4class TestPostRunScheduleMethods(unittest.TestCase):
5
6    def setUp(self):
7        self.url = 'http://localhost:8888/run/schedule'
8        self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
9        self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ] }
10
11    def test_post(self):
12        returned = requests.post(self.url, headers=self.headers, json=self.json)
13        self.assertEqual(returned.status_code, 200)
14
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
19    def test_get(self):
20        returned = requests.get(self.url, headers=self.headers)
21        self.assertEqual(returned.status_code, 405)
22
23if __name__ == '__main__':
24    unittest.main()
Note: See TracBrowser for help on using the repository browser.