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

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

#915 Extend REST API POST no payload tests to all remaining tests.

This patch extends tests for requests without any payload in the following REST
API POST functions:

  • /clients
  • /wol
  • /shell/run
  • /shell/output
  • /session
  • /poweroff
  • /reboot
  • /stop
  • /refresh
  • /hardware
  • /software
  • Property mode set to 100644
File size: 858 bytes
RevLine 
[b35438d]1import requests
2import unittest
3
4class TestPostSessionMethods(unittest.TestCase):
5
6    def setUp(self):
[a887c7b]7        self.url = 'http://localhost:8888/session'
[eae2385]8        self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'}
[b35438d]9        self.json = { 'clients' : [ '192.168.2.1', '192.168.2.2' ],
10                'disk' : '0', 'partition' : '1'}
11
12    def test_post(self):
[eae2385]13        returned = requests.post(self.url, headers=self.headers, json=self.json)
[b35438d]14        self.assertEqual(returned.status_code, 200)
15
[65cc7c1]16    def test_no_payload(self):
17        returned = requests.post(self.url, headers=self.headers, json=None)
18        self.assertEqual(returned.status_code, 400)
19
[b35438d]20    def test_get(self):
[55edb40]21        returned = requests.get(self.url, headers=self.headers)
22        self.assertEqual(returned.status_code, 405)
[b35438d]23
24if __name__ == '__main__':
25    unittest.main()
Note: See TracBrowser for help on using the repository browser.