From 8015f85b04c30350acbea8ce939a98b1f4c51cd8 Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Mon, 5 Apr 2021 16:01:14 +0200 Subject: #915 Add GET /oglive/test REST API function This function returns the installed and available ogLiveS in the server to be booted from. Request: GET /oglive/list NO BODY Response 200 OK { "oglive": [ { "distribution": "bionic", "kernel": "5.4.0-40-generic", "architecture": "amd64", "revision": "r20200629", "directory": "ogLive-5.4.0-r20200629", "iso": "ogLive-bionic-5.4.0-40-generic-amd64-r20200629.85eceaf.iso" }, { "distribution": "bionic", "kernel": "5.0.0-27-generic", "architecture": "amd64", "revision": "r20190830", "directory": "ogLive-5.0.0-r20190830", "iso": "ogLive-bionic-5.0.0-27-generic-amd64-r20190830.7208cc9.iso" } ], "default": 0 } This commit also adds tests for GET /oglive/test. --- tests/units/test_0030_get_oglive_list.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/units/test_0030_get_oglive_list.py (limited to 'tests') diff --git a/tests/units/test_0030_get_oglive_list.py b/tests/units/test_0030_get_oglive_list.py new file mode 100644 index 0000000..4b9aac7 --- /dev/null +++ b/tests/units/test_0030_get_oglive_list.py @@ -0,0 +1,19 @@ +import requests +import unittest + +class TestGetOgliveListMethods(unittest.TestCase): + + def setUp(self): + self.url = 'http://localhost:8888/oglive/list' + self.headers = {'Authorization' : '07b3bfe728954619b58f0107ad73acc1'} + + def test_get(self): + returned = requests.get(self.url, headers=self.headers) + self.assertEqual(returned.status_code, 200) + + def test_post(self): + returned = requests.post(self.url, headers=self.headers) + self.assertEqual(returned.status_code, 405) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3-18-g5258