From 4d37ddd8044693baea0222cc471fa4310c84fc70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20K=C3=BCnsem=C3=B6ller?= <jkuensem@physik.uni-bielefeld.de> Date: Thu, 12 Jul 2018 07:38:42 +0000 Subject: [PATCH] Task LSMR-14: Fixed functional tests to work with new choices implementation --- SAS/LSMR/src/lsmr/settings.py | 2 +- SAS/LSMR/test/t_functional.py | 38 +++++++++++++++++------------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/SAS/LSMR/src/lsmr/settings.py b/SAS/LSMR/src/lsmr/settings.py index f5650c4d61a..d19aa86aca2 100644 --- a/SAS/LSMR/src/lsmr/settings.py +++ b/SAS/LSMR/src/lsmr/settings.py @@ -87,7 +87,7 @@ DATABASES = { 'USER': 'lsmruser', 'PASS': 'lsmrpass2', 'HOST': 'localhost', - 'PORT': 5432, + 'PORT': 7666, } } diff --git a/SAS/LSMR/test/t_functional.py b/SAS/LSMR/test/t_functional.py index 737fc880830..a0c5806d4d0 100755 --- a/SAS/LSMR/test/t_functional.py +++ b/SAS/LSMR/test/t_functional.py @@ -54,7 +54,7 @@ def _call_API_and_assert_expected_response(self, url, call, data, expected_code, raise ValueError("The provided call '%s' is not a valid API method choice" % call) if response.status_code is not expected_code: - print(response.content) + print("[%s] - %s %s: %s" % (self.id(), call, url, response.content)) self.assertEqual(response.status_code, expected_code) r_dict = json.loads(response.content.decode('utf-8')) for item in expected_content.items(): @@ -103,12 +103,12 @@ def DELETE_and_assert_gone(self, url): """ response = requests.delete(url) if response.status_code is not 204: - print(response.content) + print("[%s] - %s %s: %s" % (self.id(), 'DELETE', url, response.content)) self.assertEqual(response.status_code, 204) response = requests.get(url) if response.status_code is not 404: - print(response.content) + print("[%s] - %s %s: %s" % (self.id(), 'GET', url, response.content)) self.assertEqual(response.status_code, 404) @@ -155,7 +155,7 @@ class GeneratorTemplateTestCase(unittest.TestCase): # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', self.test_data_1, 201, self.test_data_1) url = r_dict['url'] - GET_and_assert_expected_response(self, url+'?format=json', 200, self.test_data_1) + GET_and_assert_expected_response(self, url, 200, self.test_data_1) def test_generator_template_PUT_invalid_raises_error(self): PUT_and_assert_expected_response(self, BASE_URL + '/generator_template/9876789876/', self.test_data_1, 404, {}) @@ -420,22 +420,22 @@ class WorkRelationSelectionTemplateTestCase(unittest.TestCase): class WorkIORolesTestCase(unittest.TestCase): # test data - test_data_1 = {"role": "CALIBRATOR", - "datatype": "INSTRUMENT_MODEL", - "dataformat": ['HDF5'], + test_data_1 = {"role": BASE_URL + '/role_choice/correlator/', + "datatype": BASE_URL + '/datatype_choice/image/', + "dataformat": BASE_URL + '/dataformat_choice/HDF5/', "outputs": None, "inputs": None } - test_data_2 = {"role": "TARGET", - "datatype": "VISIBILITIES", - "dataformat": ['MEASUREMENTSET'], + test_data_2 = {"role": BASE_URL + '/role_choice/target/', + "datatype": BASE_URL + '/datatype_choice/visibilities/', + "dataformat": BASE_URL + '/dataformat_choice/MeasurementSet/', "outputs": None, "inputs": None } - test_patch = {"role": 'CORRELATOR', - "dataformat": ['MEASUREMENTSET', "HDF5"] + test_patch = {"role": BASE_URL + '/role_choice/calibrator/', + "dataformat": BASE_URL + '/dataformat_choice/MeasurementSet/' } def test_work_io_roles_list_apiformat(self): @@ -450,31 +450,31 @@ class WorkIORolesTestCase(unittest.TestCase): # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_io_roles/', self.test_data_1, 201, self.test_data_1) url = r_dict['url'] - GET_and_assert_expected_response(self, url + '?format=json', 200, self.test_data_1) + GET_and_assert_expected_response(self, url, 200, self.test_data_1) def test_work_io_roles_POST_invalid_role_raises_error(self): # POST a new item with invalid choice test_data_invalid_role = dict(self.test_data_1) - test_data_invalid_role['role'] = 'forbidden' + test_data_invalid_role['role'] = BASE_URL + '/role_choice/forbidden/' r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_io_roles/', test_data_invalid_role, 400, {}) - self.assertTrue('not a valid choice' in str(r_dict['role'])) + self.assertTrue('Invalid hyperlink' in str(r_dict['role'])) def test_work_io_roles_POST_invalid_datatype_raises_error(self): # POST a new item with invalid choice test_data_invalid = dict(self.test_data_1) - test_data_invalid['datatype'] = 'forbidden' + test_data_invalid['datatype'] = BASE_URL + '/datatype_choice/forbidden/' r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_io_roles/', test_data_invalid, 400, {}) - self.assertTrue('not a valid choice' in str(r_dict['datatype'])) + self.assertTrue('Invalid hyperlink' in str(r_dict['datatype'])) def test_work_io_roles_POST_invalid_dataformat_raises_error(self): # POST a new item with invalid choice test_data_invalid = dict(self.test_data_1) - test_data_invalid['dataformat'] = ['forbidden', "HDF5"] + test_data_invalid['dataformat'] = BASE_URL + '/dataformat_choice/forbidden/' r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_io_roles/', test_data_invalid, 400, {}) - self.assertTrue('not a valid choice' in str(r_dict['dataformat'])) + self.assertTrue('Invalid hyperlink' in str(r_dict['dataformat'])) def test_work_io_roles_POST_nonexistant_inputs_raises_error(self): -- GitLab