From 4e5cb38270d1247ef8b65996a507ea7a91f4f460 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Thu, 13 Feb 2020 11:28:14 +0100 Subject: [PATCH] TMSS-142: factored out the test_data creation methods into seperate modules for better reusability. Adapted existing tests --- SAS/TMSS/test/CMakeLists.txt | 2 + SAS/TMSS/test/t_tmssapp_scheduling_django.py | 2 + .../test/t_tmssapp_scheduling_functional.py | 267 +++++----- .../test/t_tmssapp_specification_django.py | 2 +- .../t_tmssapp_specification_functional.py | 406 +++++++-------- SAS/TMSS/test/tmss_test_data_django_models.py | 297 +++++++++++ SAS/TMSS/test/tmss_test_data_rest.py | 461 ++++++++++++++++++ .../tmss_test_environment_unittest_setup.py | 441 +---------------- 8 files changed, 1107 insertions(+), 771 deletions(-) create mode 100644 SAS/TMSS/test/tmss_test_data_django_models.py create mode 100644 SAS/TMSS/test/tmss_test_data_rest.py diff --git a/SAS/TMSS/test/CMakeLists.txt b/SAS/TMSS/test/CMakeLists.txt index 9f620c7f965..09c4d23212b 100644 --- a/SAS/TMSS/test/CMakeLists.txt +++ b/SAS/TMSS/test/CMakeLists.txt @@ -15,6 +15,8 @@ if(BUILD_TESTING) ldap_test_service.py tmss_database_unittest_setup.py tmss_test_environment_unittest_setup.py + tmss_test_data_django_models.py + tmss_test_data_rest.py DESTINATION lofar/sas/tmss/test) lofar_add_test(t_tmss_test_database) diff --git a/SAS/TMSS/test/t_tmssapp_scheduling_django.py b/SAS/TMSS/test/t_tmssapp_scheduling_django.py index 5218d25ba70..28bdfefadbe 100755 --- a/SAS/TMSS/test/t_tmssapp_scheduling_django.py +++ b/SAS/TMSS/test/t_tmssapp_scheduling_django.py @@ -37,6 +37,8 @@ logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=loggin # (ignore pycharm unused import statement, python unittests does use at RunTime the tmss_database_unittest_setup module) from lofar.sas.tmss.test.tmss_database_unittest_setup import * +from lofar.sas.tmss.test.tmss_test_data_django_models import * + from django.db.utils import IntegrityError # TODO: rest API testing should be moved out of this test module. diff --git a/SAS/TMSS/test/t_tmssapp_scheduling_functional.py b/SAS/TMSS/test/t_tmssapp_scheduling_functional.py index 492a70decf9..221846c23b5 100755 --- a/SAS/TMSS/test/t_tmssapp_scheduling_functional.py +++ b/SAS/TMSS/test/t_tmssapp_scheduling_functional.py @@ -27,6 +27,7 @@ # todo: behavior in a controlled way. # todo: We should probably also fully test behavior wrt mandatory and nullable fields. +from datetime import datetime import unittest import logging logger = logging.getLogger(__name__) @@ -37,6 +38,10 @@ logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=loggin # (ignore pycharm unused import statement, python unittests does use at RunTime the tmss_test_environment_unittest_setup module) from lofar.sas.tmss.test.tmss_test_environment_unittest_setup import * +# import and setup test data creator +from lofar.sas.tmss.test.tmss_test_data_rest import TMSSRESTTestDataCreator +test_data_creator = TMSSRESTTestDataCreator(BASE_URL, AUTH) + class SubtaskTemplateTestCase(unittest.TestCase): def test_subtask_template_list_apiformat(self): @@ -48,7 +53,7 @@ class SubtaskTemplateTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/subtask_template/1234321/', 404, {}) def test_subtask_template_POST_and_GET(self): - st_test_data = SubtaskTemplate_test_data() + st_test_data = test_data_creator.SubtaskTemplate() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_template/', st_test_data, 201, st_test_data) @@ -56,12 +61,12 @@ class SubtaskTemplateTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, st_test_data) def test_subtask_template_PUT_invalid_raises_error(self): - st_test_data = SubtaskTemplate_test_data() + st_test_data = test_data_creator.SubtaskTemplate() PUT_and_assert_expected_response(self, BASE_URL + '/subtask_template/9876789876/', st_test_data, 404, {}) def test_subtask_template_PUT(self): - st_test_data = SubtaskTemplate_test_data(name="the one") - st_test_data2 = SubtaskTemplate_test_data(name="the other") + st_test_data = test_data_creator.SubtaskTemplate(name="the one") + st_test_data2 = test_data_creator.SubtaskTemplate(name="the other") # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_template/', st_test_data, 201, st_test_data) @@ -73,7 +78,7 @@ class SubtaskTemplateTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, st_test_data2) def test_subtask_template_PATCH(self): - st_test_data = SubtaskTemplate_test_data() + st_test_data = test_data_creator.SubtaskTemplate() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_template/', st_test_data, 201, st_test_data) @@ -92,7 +97,7 @@ class SubtaskTemplateTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_subtask_template_DELETE(self): - st_test_data = SubtaskTemplate_test_data() + st_test_data = test_data_creator.SubtaskTemplate() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_template/', st_test_data, 201, st_test_data) @@ -103,7 +108,7 @@ class SubtaskTemplateTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_subtask_template_PROTECT_behavior_on_type_choice_deleted(self): - st_test_data = SubtaskTemplate_test_data() + st_test_data = test_data_creator.SubtaskTemplate() # create dependency that is safe to delete (enums are not populated / re-established between tests) type_data = {'value': 'kickme'} @@ -134,7 +139,7 @@ class DataproductSpecificationsTemplateTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/dataproduct_specifications_template/1234321/', 404, {}) def test_dataproduct_specifications_template_POST_and_GET(self): - dst_test_data = DataproductSpecificationsTemplate_test_data() + dst_test_data = test_data_creator.DataproductSpecificationsTemplate() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_specifications_template/', dst_test_data, 201, dst_test_data) @@ -142,13 +147,13 @@ class DataproductSpecificationsTemplateTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, dst_test_data) def test_dataproduct_specifications_template_PUT_invalid_raises_error(self): - dst_test_data = DataproductSpecificationsTemplate_test_data() + dst_test_data = test_data_creator.DataproductSpecificationsTemplate() PUT_and_assert_expected_response(self, BASE_URL + '/dataproduct_specifications_template/9876789876/', dst_test_data, 404, {}) def test_dataproduct_specifications_template_PUT(self): - dst_test_data = DataproductSpecificationsTemplate_test_data(name="the one") - dst_test_data2 = DataproductSpecificationsTemplate_test_data(name="the other") + dst_test_data = test_data_creator.DataproductSpecificationsTemplate(name="the one") + dst_test_data2 = test_data_creator.DataproductSpecificationsTemplate(name="the other") # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_specifications_template/', dst_test_data, 201, dst_test_data) @@ -160,7 +165,7 @@ class DataproductSpecificationsTemplateTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, dst_test_data2) def test_dataproduct_specifications_template_PATCH(self): - dst_test_data = DataproductSpecificationsTemplate_test_data() + dst_test_data = test_data_creator.DataproductSpecificationsTemplate() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_specifications_template/', dst_test_data, 201, dst_test_data) @@ -178,7 +183,7 @@ class DataproductSpecificationsTemplateTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_dataproduct_specifications_template_DELETE(self): - dst_test_data = DataproductSpecificationsTemplate_test_data() + dst_test_data = test_data_creator.DataproductSpecificationsTemplate() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_specifications_template/', dst_test_data, 201, dst_test_data) @@ -201,19 +206,19 @@ class SubtaskInputSelectionTemplateTestCase(unittest.TestCase): class DefaultSubtaskTemplatesTestCase(unittest.TestCase): def test_default_subtask_template_POST(self): - template_url = post_data_and_get_url(SubtaskTemplate_test_data(), '/subtask_template/') - dst_test_data = DefaultSubtaskTemplates_test_data(template_url=template_url) + template_url = test_data_creator.post_data_and_get_url(test_data_creator.SubtaskTemplate(), '/subtask_template/') + dst_test_data = test_data_creator.DefaultSubtaskTemplates(template_url=template_url) POST_and_assert_expected_response(self, BASE_URL + '/default_subtask_template/', dst_test_data, 201, dst_test_data) def test_default_dataproduct_specifications_template_POST(self): - template_url = post_data_and_get_url(DataproductSpecificationsTemplate_test_data(), '/dataproduct_specifications_template/') - dst_test_data = DefaultSubtaskTemplates_test_data(template_url=template_url) + template_url = test_data_creator.post_data_and_get_url(test_data_creator.DataproductSpecificationsTemplate(), '/dataproduct_specifications_template/') + dst_test_data = test_data_creator.DefaultSubtaskTemplates(template_url=template_url) POST_and_assert_expected_response(self, BASE_URL + '/default_dataproduct_specifications_template/', dst_test_data, 201, dst_test_data) def test_default_subtask_template_PROTECT_behavior_on_template_deleted(self): - st_test_data = SubtaskTemplate_test_data() - template_url = post_data_and_get_url(st_test_data, '/subtask_template/') - dst_test_data = DefaultSubtaskTemplates_test_data(template_url=template_url) + st_test_data = test_data_creator.SubtaskTemplate() + template_url = test_data_creator.post_data_and_get_url(st_test_data, '/subtask_template/') + dst_test_data = test_data_creator.DefaultSubtaskTemplates(template_url=template_url) # POST with dependency POST_and_assert_expected_response(self, BASE_URL + '/default_subtask_template/', dst_test_data, 201, dst_test_data) @@ -226,9 +231,9 @@ class DefaultSubtaskTemplatesTestCase(unittest.TestCase): GET_and_assert_expected_response(self, template_url, 200, st_test_data) def test_default_dataproduct_specifications_template_PROTECT_behavior_on_template_deleted(self): - dpst_test_data = DataproductSpecificationsTemplate_test_data() - template_url = post_data_and_get_url(dpst_test_data, '/dataproduct_specifications_template/') - dst_test_data = DefaultSubtaskTemplates_test_data(template_url=template_url) + dpst_test_data = test_data_creator.DataproductSpecificationsTemplate() + template_url = test_data_creator.post_data_and_get_url(dpst_test_data, '/dataproduct_specifications_template/') + dst_test_data = test_data_creator.DefaultSubtaskTemplates(template_url=template_url) # POST with dependency POST_and_assert_expected_response(self, BASE_URL + '/default_dataproduct_specifications_template/', dst_test_data, 201, dst_test_data) @@ -251,7 +256,7 @@ class SubtaskTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/subtask/1234321/', 404, {}) def test_subtask_POST_and_GET(self): - st_test_data = Subtask_test_data() + st_test_data = test_data_creator.Subtask() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask/', st_test_data, 201, st_test_data) @@ -259,13 +264,13 @@ class SubtaskTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, st_test_data) def test_subtask_PUT_invalid_raises_error(self): - st_test_data = Subtask_test_data() + st_test_data = test_data_creator.Subtask() PUT_and_assert_expected_response(self, BASE_URL + '/subtask/9876789876/', st_test_data, 404, {}) def test_subtask_PUT(self): - st_test_data = Subtask_test_data() - st_test_data2 = Subtask_test_data() + st_test_data = test_data_creator.Subtask() + st_test_data2 = test_data_creator.Subtask() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask/', st_test_data, 201, st_test_data) @@ -277,7 +282,7 @@ class SubtaskTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, st_test_data2) def test_subtask_PATCH(self): - st_test_data = Subtask_test_data() + st_test_data = test_data_creator.Subtask() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask/', st_test_data, 201, st_test_data) @@ -293,7 +298,7 @@ class SubtaskTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_subtask_DELETE(self): - st_test_data = Subtask_test_data() + st_test_data = test_data_creator.Subtask() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask/', st_test_data, 201, st_test_data) @@ -304,7 +309,7 @@ class SubtaskTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_subtask_PROTECT_behavior_on_state_choice_deleted(self): - st_test_data = Subtask_test_data() + st_test_data = test_data_creator.Subtask() # create dependency that is safe to delete (enums are not populated / re-established between tests) state_data = {'value': 'kickme'} @@ -325,9 +330,9 @@ class SubtaskTestCase(unittest.TestCase): GET_and_assert_expected_response(self, state_url, 200, state_data) def test_subtask_SET_NULL_behavior_on_task_blueprint_deleted(self): - tbp_test_data = TaskBlueprint_test_data() - task_blueprint_url = post_data_and_get_url(tbp_test_data, '/task_blueprint/') - st_test_data = Subtask_test_data(task_blueprint_url=task_blueprint_url) + tbp_test_data = test_data_creator.TaskBlueprint() + task_blueprint_url = test_data_creator.post_data_and_get_url(tbp_test_data, '/task_blueprint/') + st_test_data = test_data_creator.Subtask(task_blueprint_url=task_blueprint_url) # POST new item and verify url = POST_and_assert_expected_response(self, BASE_URL + '/subtask/', st_test_data, 201, st_test_data)['url'] @@ -342,9 +347,9 @@ class SubtaskTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_subtask_PROTECT_behavior_on_template_deleted(self): - stt_test_data = SubtaskTemplate_test_data() - specifications_template_url = post_data_and_get_url(stt_test_data, '/subtask_template/') - st_test_data = Subtask_test_data(specifications_template_url=specifications_template_url) + stt_test_data = test_data_creator.SubtaskTemplate() + specifications_template_url = test_data_creator.post_data_and_get_url(stt_test_data, '/subtask_template/') + st_test_data = test_data_creator.Subtask(specifications_template_url=specifications_template_url) # POST new item and verify url = POST_and_assert_expected_response(self, BASE_URL + '/subtask/', st_test_data, 201, st_test_data)['url'] @@ -368,7 +373,7 @@ class DataproductTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/dataproduct/1234321/', 404, {}) def test_dataproduct_POST_and_GET(self): - dp_test_data = Dataproduct_test_data() + dp_test_data = test_data_creator.Dataproduct() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct/', dp_test_data, 201, dp_test_data) @@ -376,13 +381,13 @@ class DataproductTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, dp_test_data) def test_dataproduct_PUT_invalid_raises_error(self): - dp_test_data = Dataproduct_test_data() + dp_test_data = test_data_creator.Dataproduct() PUT_and_assert_expected_response(self, BASE_URL + '/dataproduct/9876789876/', dp_test_data, 404, {}) def test_dataproduct_PUT(self): - dp_test_data = Dataproduct_test_data() - dp_test_data2 = Dataproduct_test_data() + dp_test_data = test_data_creator.Dataproduct() + dp_test_data2 = test_data_creator.Dataproduct() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct/', dp_test_data, 201, dp_test_data) @@ -394,7 +399,7 @@ class DataproductTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, dp_test_data2) def test_dataproduct_PATCH(self): - dp_test_data = Dataproduct_test_data() + dp_test_data = test_data_creator.Dataproduct() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct/', dp_test_data, 201, dp_test_data) @@ -411,7 +416,7 @@ class DataproductTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_dataproduct_DELETE(self): - dp_test_data = Dataproduct_test_data() + dp_test_data = test_data_creator.Dataproduct() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct/', dp_test_data, 201, dp_test_data) @@ -422,7 +427,7 @@ class DataproductTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_dataproduct_PROTECT_behavior_on_dataformat_deleted(self): - dp_test_data = Dataproduct_test_data() + dp_test_data = test_data_creator.Dataproduct() # create dependency that is safe to delete (enums are not populated / re-established between tests) dataformat_data = {'value': 'kickme'} @@ -443,8 +448,8 @@ class DataproductTestCase(unittest.TestCase): GET_and_assert_expected_response(self, dataformat_url, 200, dataformat_data) def test_dataproduct_CASCADE_behavior_on_specifications_template_deleted(self): - specifications_template_url = post_data_and_get_url(SubtaskTemplate_test_data(), '/dataproduct_specifications_template/') - dp_test_data = Dataproduct_test_data(specifications_template_url=specifications_template_url) + specifications_template_url = test_data_creator.post_data_and_get_url(test_data_creator.SubtaskTemplate(), '/dataproduct_specifications_template/') + dp_test_data = test_data_creator.Dataproduct(specifications_template_url=specifications_template_url) # POST new item, verify url = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct/', dp_test_data, 201, dp_test_data)['url'] @@ -467,7 +472,7 @@ class SubtaskConnectorTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/subtask_connector/1234321/', 404, {}) def test_subtask_connector_POST_and_GET(self): - stc_test_data = SubtaskConnector_test_data() + stc_test_data = test_data_creator.SubtaskConnector() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_connector/', stc_test_data, 201, stc_test_data) @@ -475,13 +480,13 @@ class SubtaskConnectorTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, stc_test_data) def test_subtask_connector_PUT_invalid_raises_error(self): - stc_test_data = SubtaskConnector_test_data() + stc_test_data = test_data_creator.SubtaskConnector() PUT_and_assert_expected_response(self, BASE_URL + '/subtask_connector/9876789876/', stc_test_data, 404, {}) def test_subtask_connector_PUT(self): - stc_test_data = SubtaskConnector_test_data() - stc_test_data2 = SubtaskConnector_test_data() + stc_test_data = test_data_creator.SubtaskConnector() + stc_test_data2 = test_data_creator.SubtaskConnector() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_connector/', stc_test_data, 201, stc_test_data) @@ -493,7 +498,7 @@ class SubtaskConnectorTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, stc_test_data2) def test_subtask_connector_PATCH(self): - stc_test_data = SubtaskConnector_test_data() + stc_test_data = test_data_creator.SubtaskConnector() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_connector/', stc_test_data, 201, stc_test_data) @@ -510,7 +515,7 @@ class SubtaskConnectorTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_subtask_connector_DELETE(self): - stc_test_data = SubtaskConnector_test_data() + stc_test_data = test_data_creator.SubtaskConnector() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_connector/', stc_test_data, 201, stc_test_data) @@ -521,7 +526,7 @@ class SubtaskConnectorTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_subtask_connector_PROTECT_behavior_on_role_deleted(self): - stc_test_data = SubtaskConnector_test_data() + stc_test_data = test_data_creator.SubtaskConnector() # create dependency that is safe to delete (enums are not populated / re-established between tests) role_data = {'value': 'kickme'} @@ -544,7 +549,7 @@ class SubtaskConnectorTestCase(unittest.TestCase): def test_subtask_connector_PROTECT_behavior_on_datatype_deleted(self): - stc_test_data = SubtaskConnector_test_data() + stc_test_data = test_data_creator.SubtaskConnector() # create new dependency that is safe to delete (enums are not populated / re-established between tests) datatype_data = {'value': 'kickme'} @@ -575,7 +580,7 @@ class SubtaskInputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/subtask_input/1234321/', 404, {}) def test_subtask_input_POST_and_GET(self): - sti_test_data = SubtaskInput_test_data() + sti_test_data = test_data_creator.SubtaskInput() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_input/', sti_test_data, 201, sti_test_data) @@ -583,13 +588,12 @@ class SubtaskInputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, sti_test_data) def test_subtask_input_PUT_invalid_raises_error(self): - sti_test_data = SubtaskInput_test_data() + sti_test_data = test_data_creator.SubtaskInput() PUT_and_assert_expected_response(self, BASE_URL + '/subtask_input/9876789876/', sti_test_data, 404, {}) def test_subtask_input_PUT(self): - sti_test_data = SubtaskInput_test_data() - sti_test_data2 = SubtaskInput_test_data() + sti_test_data = test_data_creator.SubtaskInput() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_input/', sti_test_data, 201, sti_test_data) @@ -597,18 +601,19 @@ class SubtaskInputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, sti_test_data) # PUT new values, verify + sti_test_data2 = test_data_creator.SubtaskInput() PUT_and_assert_expected_response(self, url, sti_test_data2, 200, sti_test_data2) GET_and_assert_expected_response(self, url, 200, sti_test_data2) def test_subtask_input_PATCH(self): - sti_test_data = SubtaskInput_test_data() + sti_test_data = test_data_creator.SubtaskInput() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_input/', sti_test_data, 201, sti_test_data) url = r_dict['url'] GET_and_assert_expected_response(self, url, 200, sti_test_data) - subtask_url = post_data_and_get_url(Subtask_test_data(), '/subtask/') + subtask_url = test_data_creator.post_data_and_get_url(test_data_creator.Subtask(), '/subtask/') test_patch = {"subtask": subtask_url, "tags": ['FANCYTAG'], } @@ -620,7 +625,7 @@ class SubtaskInputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_subtask_input_DELETE(self): - sti_test_data = SubtaskInput_test_data() + sti_test_data = test_data_creator.SubtaskInput() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_input/', sti_test_data, 201, sti_test_data) @@ -631,8 +636,8 @@ class SubtaskInputTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_subtask_input_CASCADE_behavior_on_subtask_deleted(self): - subtask_url = post_data_and_get_url(Subtask_test_data(), '/subtask/') - sti_test_data = SubtaskInput_test_data(subtask_url=subtask_url) + subtask_url = test_data_creator.post_data_and_get_url(test_data_creator.Subtask(), '/subtask/') + sti_test_data = test_data_creator.SubtaskInput(subtask_url=subtask_url) # POST new item, verify url = POST_and_assert_expected_response(self, BASE_URL + '/subtask_input/', sti_test_data, 201, sti_test_data)['url'] @@ -645,8 +650,8 @@ class SubtaskInputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_subtask_input_SET_NULL_behavior_on_connector_deleted(self): - subtask_connector_url = post_data_and_get_url(SubtaskConnector_test_data(), '/subtask_connector/') - sti_test_data = SubtaskInput_test_data(subtask_connector_url=subtask_connector_url) + subtask_connector_url = test_data_creator.post_data_and_get_url(test_data_creator.SubtaskConnector(), '/subtask_connector/') + sti_test_data = test_data_creator.SubtaskInput(subtask_connector_url=subtask_connector_url) # POST new item, verify url = POST_and_assert_expected_response(self, BASE_URL + '/subtask_input/', sti_test_data, 201, sti_test_data)['url'] @@ -661,8 +666,8 @@ class SubtaskInputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_subtask_input_SET_NULL_behavior_on_task_relation_blueprint_deleted(self): - task_relation_blueprint_url = post_data_and_get_url(TaskRelationBlueprint_test_data(), '/task_relation_blueprint/') - sti_test_data = SubtaskInput_test_data(task_relation_blueprint_url=task_relation_blueprint_url) + task_relation_blueprint_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskRelationBlueprint(), '/task_relation_blueprint/') + sti_test_data = test_data_creator.SubtaskInput(task_relation_blueprint_url=task_relation_blueprint_url) # POST new item, verify url = POST_and_assert_expected_response(self, BASE_URL + '/subtask_input/', sti_test_data, 201, sti_test_data)['url'] @@ -677,8 +682,8 @@ class SubtaskInputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_subtask_input_PROTECT_behavior_on_producer_deleted(self): - subtask_output_url = post_data_and_get_url(SubtaskOutput_test_data(), '/subtask_output/') - sti_test_data = SubtaskInput_test_data(subtask_output_url=subtask_output_url) + subtask_output_url = test_data_creator.post_data_and_get_url(test_data_creator.SubtaskOutput(), '/subtask_output/') + sti_test_data = test_data_creator.SubtaskInput(subtask_output_url=subtask_output_url) # POST with dependency url = POST_and_assert_expected_response(self, BASE_URL + '/subtask_input/', sti_test_data, 201, sti_test_data)['url'] @@ -692,8 +697,8 @@ class SubtaskInputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, subtask_output_url, 200, {}) def test_subtask_input_PROTECT_behavior_on_selection_template_deleted(self): - subtask_input_selection_template_url = post_data_and_get_url(SubtaskInputSelectionTemplate_test_data(), '/subtask_input_selection_template/') - sti_test_data = SubtaskInput_test_data(subtask_input_selection_template_url=subtask_input_selection_template_url) + subtask_input_selection_template_url = test_data_creator.post_data_and_get_url(test_data_creator.SubtaskInputSelectionTemplate(), '/subtask_input_selection_template/') + sti_test_data = test_data_creator.SubtaskInput(subtask_input_selection_template_url=subtask_input_selection_template_url) # POST with dependency url = POST_and_assert_expected_response(self, BASE_URL + '/subtask_input/', sti_test_data, 201, sti_test_data)['url'] @@ -717,7 +722,7 @@ class SubtaskOutputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/subtask_output/1234321/', 404, {}) def test_subtask_output_POST_and_GET(self): - sto_test_data = SubtaskOutput_test_data() + sto_test_data = test_data_creator.SubtaskOutput() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_output/', sto_test_data, 201, @@ -726,12 +731,12 @@ class SubtaskOutputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, sto_test_data) def test_subtask_output_PUT_invalid_raises_error(self): - sto_test_data = SubtaskOutput_test_data() + sto_test_data = test_data_creator.SubtaskOutput() PUT_and_assert_expected_response(self, BASE_URL + '/subtask_output/9876789876/', sto_test_data, 404, {}) def test_subtask_output_PUT(self): - sto_test_data = SubtaskOutput_test_data() - sto_test_data2 = SubtaskOutput_test_data() + sto_test_data = test_data_creator.SubtaskOutput() + sto_test_data2 = test_data_creator.SubtaskOutput() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_output/', sto_test_data, 201,sto_test_data) @@ -743,8 +748,8 @@ class SubtaskOutputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, sto_test_data2) def test_subtask_output_PATCH(self): - sto_test_data = SubtaskOutput_test_data() - sto_test_data2 = SubtaskOutput_test_data() + sto_test_data = test_data_creator.SubtaskOutput() + sto_test_data2 = test_data_creator.SubtaskOutput() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_output/', sto_test_data, 201, @@ -762,7 +767,7 @@ class SubtaskOutputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_subtask_output_DELETE(self): - sto_test_data = SubtaskOutput_test_data() + sto_test_data = test_data_creator.SubtaskOutput() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/subtask_output/', sto_test_data, 201, @@ -774,9 +779,9 @@ class SubtaskOutputTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_subtask_output_CASCADE_behavior_on_subtask_deleted(self): - st_test_data = Subtask_test_data() - subtask_url = post_data_and_get_url(st_test_data, '/subtask/') - sto_test_data = SubtaskOutput_test_data(subtask_url=subtask_url) + st_test_data = test_data_creator.Subtask() + subtask_url = test_data_creator.post_data_and_get_url(st_test_data, '/subtask/') + sto_test_data = test_data_creator.SubtaskOutput(subtask_url=subtask_url) # POST new item, verify url = POST_and_assert_expected_response(self, BASE_URL + '/subtask_output/', sto_test_data, 201, sto_test_data)['url'] @@ -789,7 +794,7 @@ class SubtaskOutputTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_subtask_output_SET_NULL_behavior_on_connector_deleted(self): - sto_test_data = SubtaskOutput_test_data() + sto_test_data = test_data_creator.SubtaskOutput() # POST new item, verify url = \ @@ -817,7 +822,7 @@ class AntennaSetTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/antenna_set/1234321/', 404, {}) def test_antenna_set_POST_and_GET(self): - antennaset_test_data = AntennaSet_test_data() + antennaset_test_data = test_data_creator.AntennaSet() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/antenna_set/', antennaset_test_data, 201, antennaset_test_data) @@ -825,13 +830,13 @@ class AntennaSetTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, antennaset_test_data) def test_antenna_set_PUT_invalid_raises_error(self): - antennaset_test_data = AntennaSet_test_data() + antennaset_test_data = test_data_creator.AntennaSet() PUT_and_assert_expected_response(self, BASE_URL + '/antenna_set/9876789876/', antennaset_test_data, 404, {}) def test_antenna_set_PUT(self): - antennaset_test_data = AntennaSet_test_data(name="the one") - antennaset_test_data2 = AntennaSet_test_data(name="the other") + antennaset_test_data = test_data_creator.AntennaSet(name="the one") + antennaset_test_data2 = test_data_creator.AntennaSet(name="the other") # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/antenna_set/', antennaset_test_data, 201, antennaset_test_data) @@ -843,7 +848,7 @@ class AntennaSetTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, antennaset_test_data2) def test_antenna_set_PATCH(self): - antennaset_test_data = AntennaSet_test_data() + antennaset_test_data = test_data_creator.AntennaSet() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/antenna_set/', antennaset_test_data, 201, antennaset_test_data) @@ -860,7 +865,7 @@ class AntennaSetTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_antenna_set_DELETE(self): - antennaset_test_data = AntennaSet_test_data() + antennaset_test_data = test_data_creator.AntennaSet() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/antenna_set/', antennaset_test_data, 201, antennaset_test_data) @@ -871,7 +876,7 @@ class AntennaSetTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_antenna_set_PROTECT_behavior_on_station_type_deleted(self): - antennaset_test_data = AntennaSet_test_data() + antennaset_test_data = test_data_creator.AntennaSet() # create dependency that is safe to delete (enums are not populated / re-established between tests) dataformat_data = {'value': 'kickme'} @@ -902,7 +907,7 @@ class DataproductTransformTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/dataproduct_transform/1234321/', 404, {}) def test_dataproduct_transform_POST_and_GET(self): - dpt_test_data = DataproductTransform_test_data() + dpt_test_data = test_data_creator.DataproductTransform() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_transform/', dpt_test_data, 201, dpt_test_data) @@ -910,13 +915,13 @@ class DataproductTransformTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, dpt_test_data) def test_dataproduct_transform_PUT_invalid_raises_error(self): - dpt_test_data = DataproductTransform_test_data() + dpt_test_data = test_data_creator.DataproductTransform() PUT_and_assert_expected_response(self, BASE_URL + '/dataproduct_transform/9876789876/', dpt_test_data, 404, {}) def test_dataproduct_transform_PUT(self): - dpt_test_data = DataproductTransform_test_data() - dpt_test_data2 = DataproductTransform_test_data() + dpt_test_data = test_data_creator.DataproductTransform() + dpt_test_data2 = test_data_creator.DataproductTransform() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_transform/', dpt_test_data, 201, dpt_test_data) @@ -928,14 +933,14 @@ class DataproductTransformTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, dpt_test_data2) def test_dataproduct_transform_PATCH(self): - dpt_test_data = DataproductTransform_test_data() + dpt_test_data = test_data_creator.DataproductTransform() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_transform/', dpt_test_data, 201, dpt_test_data) url = r_dict['url'] GET_and_assert_expected_response(self, url, 200, dpt_test_data) - output_dataproduct_url = post_data_and_get_url(Dataproduct_test_data(), '/dataproduct/') + output_dataproduct_url = test_data_creator.post_data_and_get_url(test_data_creator.Dataproduct(), '/dataproduct/') test_patch = {"output": output_dataproduct_url, "identity": False } @@ -947,7 +952,7 @@ class DataproductTransformTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_dataproduct_transform_DELETE(self): - dpt_test_data = DataproductTransform_test_data() + dpt_test_data = test_data_creator.DataproductTransform() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_transform/', dpt_test_data, 201, dpt_test_data) @@ -958,9 +963,9 @@ class DataproductTransformTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_dataproduct_transform_PROTECT_behavior_on_input_deleted(self): - input_dp_test_data = Dataproduct_test_data() - input_dataproduct_url = post_data_and_get_url(input_dp_test_data, '/dataproduct/') - dpt_test_data = DataproductTransform_test_data(input_dataproduct_url=input_dataproduct_url) + input_dp_test_data = test_data_creator.Dataproduct() + input_dataproduct_url = test_data_creator.post_data_and_get_url(input_dp_test_data, '/dataproduct/') + dpt_test_data = test_data_creator.DataproductTransform(input_dataproduct_url=input_dataproduct_url) # POST new item and verify url = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_transform/', dpt_test_data, 201, dpt_test_data)['url'] @@ -974,9 +979,9 @@ class DataproductTransformTestCase(unittest.TestCase): GET_and_assert_expected_response(self, input_dataproduct_url, 200, input_dp_test_data) def test_dataproduct_transform_PROTECT_behavior_on_output_deleted(self): - output_dp_test_data = Dataproduct_test_data() - output_dataproduct_url = post_data_and_get_url(output_dp_test_data, '/dataproduct/') - dpt_test_data = DataproductTransform_test_data(output_dataproduct_url=output_dataproduct_url) + output_dp_test_data = test_data_creator.Dataproduct() + output_dataproduct_url = test_data_creator.post_data_and_get_url(output_dp_test_data, '/dataproduct/') + dpt_test_data = test_data_creator.DataproductTransform(output_dataproduct_url=output_dataproduct_url) # POST new item and verify url = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_transform/', dpt_test_data, 201, dpt_test_data)['url'] @@ -1000,7 +1005,7 @@ class FilesystemTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/filesystem/1234321/', 404, {}) def test_filesystem_POST_and_GET(self): - fs_test_data = Filesystem_test_data() + fs_test_data = test_data_creator.Filesystem() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/filesystem/', fs_test_data, 201, fs_test_data) @@ -1008,13 +1013,13 @@ class FilesystemTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, fs_test_data) def test_filesystem_PUT_invalid_raises_error(self): - fs_test_data = Filesystem_test_data() + fs_test_data = test_data_creator.Filesystem() PUT_and_assert_expected_response(self, BASE_URL + '/filesystem/9876789876/', fs_test_data, 404, {}) def test_filesystem_PUT(self): - fs_test_data = Filesystem_test_data() + fs_test_data = test_data_creator.Filesystem() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/filesystem/', fs_test_data, @@ -1022,15 +1027,15 @@ class FilesystemTestCase(unittest.TestCase): url = r_dict['url'] GET_and_assert_expected_response(self, url, 200, fs_test_data) - fs_test_data2 = Filesystem_test_data() + fs_test_data2 = test_data_creator.Filesystem() # PUT new values, verify PUT_and_assert_expected_response(self, url, fs_test_data2, 200, fs_test_data2) GET_and_assert_expected_response(self, url, 200, fs_test_data2) def test_filesystem_PATCH(self): - cluster_url = post_data_and_get_url(Cluster_test_data(), '/cluster/') - fs_test_data = Filesystem_test_data(cluster_url=cluster_url) + cluster_url = test_data_creator.post_data_and_get_url(test_data_creator.Cluster(), '/cluster/') + fs_test_data = test_data_creator.Filesystem(cluster_url=cluster_url) # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/filesystem/', fs_test_data, @@ -1038,7 +1043,7 @@ class FilesystemTestCase(unittest.TestCase): url = r_dict['url'] GET_and_assert_expected_response(self, url, 200, fs_test_data) - cluster_url2 = post_data_and_get_url(Cluster_test_data(), '/cluster/') + cluster_url2 = test_data_creator.post_data_and_get_url(test_data_creator.Cluster(), '/cluster/') test_patch = {"cluster": cluster_url2, "capacity": 3333333333} @@ -1049,7 +1054,7 @@ class FilesystemTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_filesystem_DELETE(self): - fs_test_data = Filesystem_test_data() + fs_test_data = test_data_creator.Filesystem() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/filesystem/', fs_test_data, @@ -1061,7 +1066,7 @@ class FilesystemTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_filesystem_PROTECT_behavior_on_cluster_deleted(self): - fs_test_data = Filesystem_test_data() + fs_test_data = test_data_creator.Filesystem() # POST new item and verify url = POST_and_assert_expected_response(self, BASE_URL + '/filesystem/', fs_test_data, 201, @@ -1086,7 +1091,7 @@ class ClusterTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/cluster/1234321/', 404, {}) def test_cluster_POST_and_GET(self): - c_test_data = Cluster_test_data() + c_test_data = test_data_creator.Cluster() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/cluster/', c_test_data, 201, c_test_data) @@ -1094,25 +1099,25 @@ class ClusterTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, c_test_data) def test_cluster_PUT_invalid_raises_error(self): - c_test_data = Cluster_test_data() + c_test_data = test_data_creator.Cluster() PUT_and_assert_expected_response(self, BASE_URL + '/cluster/9876789876/', c_test_data, 404, {}) def test_cluster_PUT(self): - c_test_data = Cluster_test_data() + c_test_data = test_data_creator.Cluster() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/cluster/', c_test_data, 201, c_test_data) url = r_dict['url'] GET_and_assert_expected_response(self, url, 200, c_test_data) - c_test_data2 = Cluster_test_data() + c_test_data2 = test_data_creator.Cluster() # PUT new values, verify PUT_and_assert_expected_response(self, url, c_test_data2, 200, c_test_data2) GET_and_assert_expected_response(self, url, 200, c_test_data2) def test_cluster_PATCH(self): - c_test_data = Cluster_test_data() + c_test_data = test_data_creator.Cluster() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/cluster/', c_test_data, 201, c_test_data) @@ -1128,7 +1133,7 @@ class ClusterTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_cluster_DELETE(self): - c_test_data = Cluster_test_data() + c_test_data = test_data_creator.Cluster() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/cluster/', c_test_data, 201, c_test_data) @@ -1149,7 +1154,7 @@ class DataproductHashTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/dataproduct_hash/1234321/', 404, {}) def test_dataproduct_hash_POST_and_GET(self): - dph_test_data = DataproductHash_test_data() + dph_test_data = test_data_creator.DataproductHash() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_hash/', dph_test_data, @@ -1158,14 +1163,14 @@ class DataproductHashTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, dph_test_data) def test_dataproduct_hash_PUT_invalid_raises_error(self): - dph_test_data = DataproductHash_test_data() + dph_test_data = test_data_creator.DataproductHash() PUT_and_assert_expected_response(self, BASE_URL + '/dataproduct_hash/9876789876/', dph_test_data, 404, {}) def test_dataproduct_hash_PUT(self): - dph_test_data = DataproductHash_test_data(hash="the one") - dph_test_data2 = DataproductHash_test_data(hash="the other") + dph_test_data = test_data_creator.DataproductHash(hash="the one") + dph_test_data2 = test_data_creator.DataproductHash(hash="the other") # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_hash/', dph_test_data, @@ -1178,7 +1183,7 @@ class DataproductHashTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, dph_test_data2) def test_dataproduct_hash_PATCH(self): - dph_test_data = DataproductHash_test_data() + dph_test_data = test_data_creator.DataproductHash() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_hash/', dph_test_data, @@ -1196,7 +1201,7 @@ class DataproductHashTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_dataproduct_hash_DELETE(self): - dph_test_data = DataproductHash_test_data() + dph_test_data = test_data_creator.DataproductHash() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_hash/', dph_test_data, @@ -1208,7 +1213,7 @@ class DataproductHashTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_dataproduct_hash_PROTECT_behavior_on_dataproduct_deleted(self): - dph_test_data = DataproductHash_test_data() + dph_test_data = test_data_creator.DataproductHash() # POST new item and verify url = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_hash/', dph_test_data, 201, @@ -1223,7 +1228,7 @@ class DataproductHashTestCase(unittest.TestCase): GET_and_assert_expected_response(self, dph_test_data['dataproduct'], 200, {}) def test_dataproduct_hash_PROTECT_behavior_on_algorithm_deleted(self): - dph_test_data = DataproductHash_test_data() + dph_test_data = test_data_creator.DataproductHash() # POST new item and verify url = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_hash/', dph_test_data, 201, @@ -1248,7 +1253,7 @@ class DataproductArchiveInfoTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/dataproduct_archive_info/1234321/', 404, {}) def test_dataproduct_archive_info_POST_and_GET(self): - dpai_test_data = DataproductArchiveInfo_test_data() + dpai_test_data = test_data_creator.DataproductArchiveInfo() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_archive_info/', dpai_test_data, @@ -1257,14 +1262,14 @@ class DataproductArchiveInfoTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, dpai_test_data) def test_dataproduct_archive_info_PUT_invalid_raises_error(self): - dpai_test_data = DataproductArchiveInfo_test_data() + dpai_test_data = test_data_creator.DataproductArchiveInfo() PUT_and_assert_expected_response(self, BASE_URL + '/dataproduct_archive_info/9876789876/', dpai_test_data, 404, {}) def test_dataproduct_archive_info_PUT(self): - dpai_test_data = DataproductArchiveInfo_test_data() - dpai_test_data2 = DataproductArchiveInfo_test_data() + dpai_test_data = test_data_creator.DataproductArchiveInfo() + dpai_test_data2 = test_data_creator.DataproductArchiveInfo() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_archive_info/', dpai_test_data, @@ -1277,7 +1282,7 @@ class DataproductArchiveInfoTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, dpai_test_data2) def test_dataproduct_archive_info_PATCH(self): - dpai_test_data = DataproductArchiveInfo_test_data() + dpai_test_data = test_data_creator.DataproductArchiveInfo() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_archive_info/', dpai_test_data, @@ -1294,7 +1299,7 @@ class DataproductArchiveInfoTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_dataproduct_archive_info_DELETE(self): - dpai_test_data = DataproductArchiveInfo_test_data() + dpai_test_data = test_data_creator.DataproductArchiveInfo() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_archive_info/', dpai_test_data, @@ -1306,7 +1311,7 @@ class DataproductArchiveInfoTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_dataproduct_archive_info_PROTECT_behavior_on_dataproduct_deleted(self): - dpai_test_data = DataproductArchiveInfo_test_data() + dpai_test_data = test_data_creator.DataproductArchiveInfo() # POST new item and verify url = POST_and_assert_expected_response(self, BASE_URL + '/dataproduct_archive_info/', dpai_test_data, 201, diff --git a/SAS/TMSS/test/t_tmssapp_specification_django.py b/SAS/TMSS/test/t_tmssapp_specification_django.py index 0159d195d9e..2682fd8abb4 100755 --- a/SAS/TMSS/test/t_tmssapp_specification_django.py +++ b/SAS/TMSS/test/t_tmssapp_specification_django.py @@ -36,9 +36,9 @@ logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=loggin # (ignore pycharm unused import statement, python unittests does use at RunTime the tmss_database_unittest_setup module) from lofar.sas.tmss.test.tmss_database_unittest_setup import * +from lofar.sas.tmss.test.tmss_test_data_django_models import * from django.db.utils import IntegrityError -from django.contrib.auth.models import User # TODO: rest API testing should be moved out of this test module. # import rest_framework.test diff --git a/SAS/TMSS/test/t_tmssapp_specification_functional.py b/SAS/TMSS/test/t_tmssapp_specification_functional.py index e995cbbea84..2aba43f467a 100755 --- a/SAS/TMSS/test/t_tmssapp_specification_functional.py +++ b/SAS/TMSS/test/t_tmssapp_specification_functional.py @@ -27,6 +27,7 @@ # todo: behavior in a controlled way. # todo: We should probably also fully test behavior wrt mandatory and nullable fields. +from datetime import datetime import unittest import logging logger = logging.getLogger(__name__) @@ -37,6 +38,9 @@ logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=loggin # (ignore pycharm unused import statement, python unittests does use at RunTime the tmss_test_environment_unittest_setup module) from lofar.sas.tmss.test.tmss_test_environment_unittest_setup import * +# import and setup test data creator +from lofar.sas.tmss.test.tmss_test_data_rest import TMSSRESTTestDataCreator +test_data_creator = TMSSRESTTestDataCreator(BASE_URL, AUTH) class BasicFunctionTestCase(unittest.TestCase): # todo: test_welcome_page (once we have one :)) @@ -55,46 +59,46 @@ class GeneratorTemplateTestCase(unittest.TestCase): def test_generator_template_POST_and_GET(self): # POST and GET a new item and assert correctness - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', GeneratorTemplate_test_data(), 201, GeneratorTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', test_data_creator.GeneratorTemplate(), 201, test_data_creator.GeneratorTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, GeneratorTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.GeneratorTemplate()) def test_generator_template_PUT_invalid_raises_error(self): - PUT_and_assert_expected_response(self, BASE_URL + '/generator_template/9876789876/', GeneratorTemplate_test_data(), 404, {}) + PUT_and_assert_expected_response(self, BASE_URL + '/generator_template/9876789876/', test_data_creator.GeneratorTemplate(), 404, {}) def test_generator_template_PUT(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', GeneratorTemplate_test_data(), 201, GeneratorTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', test_data_creator.GeneratorTemplate(), 201, test_data_creator.GeneratorTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, GeneratorTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.GeneratorTemplate()) # PUT new values, verify - PUT_and_assert_expected_response(self, url, GeneratorTemplate_test_data("generatortemplate2"), 200, GeneratorTemplate_test_data("generatortemplate2")) - GET_and_assert_expected_response(self, url, 200, GeneratorTemplate_test_data("generatortemplate2")) + PUT_and_assert_expected_response(self, url, test_data_creator.GeneratorTemplate("generatortemplate2"), 200, test_data_creator.GeneratorTemplate("generatortemplate2")) + GET_and_assert_expected_response(self, url, 200, test_data_creator.GeneratorTemplate("generatortemplate2")) def test_generator_template_PATCH(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', GeneratorTemplate_test_data(), 201, GeneratorTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', test_data_creator.GeneratorTemplate(), 201, test_data_creator.GeneratorTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, GeneratorTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.GeneratorTemplate()) test_patch = {"version": 'v6.28318530718', "schema": {"mykey": "my better value"}} # PATCH item and verify PATCH_and_assert_expected_response(self, url, test_patch, 200, test_patch) - expected_data = dict(GeneratorTemplate_test_data()) + expected_data = dict(test_data_creator.GeneratorTemplate()) expected_data.update(test_patch) GET_and_assert_expected_response(self, url, 200, expected_data) def test_generator_template_DELETE(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', GeneratorTemplate_test_data(), 201, GeneratorTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', test_data_creator.GeneratorTemplate(), 201, test_data_creator.GeneratorTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, GeneratorTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.GeneratorTemplate()) # DELETE and check it's gone DELETE_and_assert_gone(self, url) @@ -112,46 +116,46 @@ class SchedulingUnitTemplateTestCase(unittest.TestCase): def test_scheduling_unit_template_POST_and_GET(self): # POST and GET a new item and assert correctness - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/', SchedulingUnitTemplate_test_data(), 201, SchedulingUnitTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/', test_data_creator.SchedulingUnitTemplate(), 201, test_data_creator.SchedulingUnitTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url+'?format=json', 200, SchedulingUnitTemplate_test_data()) + GET_and_assert_expected_response(self, url+'?format=json', 200, test_data_creator.SchedulingUnitTemplate()) def test_scheduling_unit_template_PUT_invalid_raises_error(self): - PUT_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/9876789876/', SchedulingUnitTemplate_test_data(), 404, {}) + PUT_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/9876789876/', test_data_creator.SchedulingUnitTemplate(), 404, {}) def test_scheduling_unit_template_PUT(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/', SchedulingUnitTemplate_test_data(), 201, SchedulingUnitTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/', test_data_creator.SchedulingUnitTemplate(), 201, test_data_creator.SchedulingUnitTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, SchedulingUnitTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.SchedulingUnitTemplate()) # PUT new values, verify - PUT_and_assert_expected_response(self, url, SchedulingUnitTemplate_test_data("schedulingunittemplate2"), 200, SchedulingUnitTemplate_test_data("schedulingunittemplate2")) - GET_and_assert_expected_response(self, url, 200, SchedulingUnitTemplate_test_data("schedulingunittemplate2")) + PUT_and_assert_expected_response(self, url, test_data_creator.SchedulingUnitTemplate("schedulingunittemplate2"), 200, test_data_creator.SchedulingUnitTemplate("schedulingunittemplate2")) + GET_and_assert_expected_response(self, url, 200, test_data_creator.SchedulingUnitTemplate("schedulingunittemplate2")) def test_scheduling_unit_template_PATCH(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/', SchedulingUnitTemplate_test_data(), 201, SchedulingUnitTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/', test_data_creator.SchedulingUnitTemplate(), 201, test_data_creator.SchedulingUnitTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, SchedulingUnitTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.SchedulingUnitTemplate()) test_patch = {"version": 'v6.28318530718', "schema": {"mykey": "my better value"}} # PATCH item and verify PATCH_and_assert_expected_response(self, url, test_patch, 200, test_patch) - expected_data = dict(SchedulingUnitTemplate_test_data()) + expected_data = dict(test_data_creator.SchedulingUnitTemplate()) expected_data.update(test_patch) GET_and_assert_expected_response(self, url, 200, expected_data) def test_scheduling_unit_template_DELETE(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/', SchedulingUnitTemplate_test_data(), 201, SchedulingUnitTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/', test_data_creator.SchedulingUnitTemplate(), 201, test_data_creator.SchedulingUnitTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, SchedulingUnitTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.SchedulingUnitTemplate()) # DELETE and check it's gone DELETE_and_assert_gone(self, url) @@ -168,47 +172,47 @@ class TaskTemplateTestCase(unittest.TestCase): def test_task_template_POST_and_GET(self): # POST and GET a new item and assert correctness - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', TaskTemplate_test_data(), 201, - TaskTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', test_data_creator.TaskTemplate(), 201, + test_data_creator.TaskTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url + '?format=json', 200, TaskTemplate_test_data()) + GET_and_assert_expected_response(self, url + '?format=json', 200, test_data_creator.TaskTemplate()) def test_task_template_PUT_invalid_raises_error(self): - PUT_and_assert_expected_response(self, BASE_URL + '/task_template/9876789876/', TaskTemplate_test_data(), 404, {}) + PUT_and_assert_expected_response(self, BASE_URL + '/task_template/9876789876/', test_data_creator.TaskTemplate(), 404, {}) def test_task_template_PUT(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', TaskTemplate_test_data(), 201, - TaskTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', test_data_creator.TaskTemplate(), 201, + test_data_creator.TaskTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, TaskTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.TaskTemplate()) # PUT new values, verify - PUT_and_assert_expected_response(self, url, TaskTemplate_test_data("tasktemplate2"), 200, TaskTemplate_test_data("tasktemplate2")) - GET_and_assert_expected_response(self, url, 200, TaskTemplate_test_data("tasktemplate2")) + PUT_and_assert_expected_response(self, url, test_data_creator.TaskTemplate("tasktemplate2"), 200, test_data_creator.TaskTemplate("tasktemplate2")) + GET_and_assert_expected_response(self, url, 200, test_data_creator.TaskTemplate("tasktemplate2")) def test_task_template_PATCH(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', TaskTemplate_test_data(), 201, - TaskTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', test_data_creator.TaskTemplate(), 201, + test_data_creator.TaskTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, TaskTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.TaskTemplate()) test_patch = {"version": 'v6.28318530718', "schema": {"mykey": "my better value"}, } # PATCH item and verify PATCH_and_assert_expected_response(self, url, test_patch, 200, test_patch) - expected_data = dict(TaskTemplate_test_data()) + expected_data = dict(test_data_creator.TaskTemplate()) expected_data.update(test_patch) GET_and_assert_expected_response(self, url, 200, expected_data) def test_task_template_DELETE(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', TaskTemplate_test_data(), 201, - TaskTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', test_data_creator.TaskTemplate(), 201, + test_data_creator.TaskTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, TaskTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.TaskTemplate()) # DELETE and check it's gone DELETE_and_assert_gone(self, url) @@ -226,30 +230,30 @@ class WorkRelationSelectionTemplateTestCase(unittest.TestCase): def test_work_relation_selection_template_POST_and_GET(self): # POST and GET a new item and assert correctness - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/', WorkRelationSelectionTemplate_test_data(), 201, WorkRelationSelectionTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/', test_data_creator.WorkRelationSelectionTemplate(), 201, test_data_creator.WorkRelationSelectionTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url+'?format=json', 200, WorkRelationSelectionTemplate_test_data()) + GET_and_assert_expected_response(self, url+'?format=json', 200, test_data_creator.WorkRelationSelectionTemplate()) def test_work_relation_selection_template_PUT_invalid_raises_error(self): - PUT_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/9876789876/', WorkRelationSelectionTemplate_test_data(), 404, {}) + PUT_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/9876789876/', test_data_creator.WorkRelationSelectionTemplate(), 404, {}) def test_work_relation_selection_template_PUT(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/', WorkRelationSelectionTemplate_test_data(), 201, WorkRelationSelectionTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/', test_data_creator.WorkRelationSelectionTemplate(), 201, test_data_creator.WorkRelationSelectionTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, WorkRelationSelectionTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.WorkRelationSelectionTemplate()) # PUT new values, verify - PUT_and_assert_expected_response(self, url, WorkRelationSelectionTemplate_test_data("workrelationselectiontemplate2"), 200, WorkRelationSelectionTemplate_test_data("workrelationselectiontemplate2")) - GET_and_assert_expected_response(self, url, 200, WorkRelationSelectionTemplate_test_data("workrelationselectiontemplate2")) + PUT_and_assert_expected_response(self, url, test_data_creator.WorkRelationSelectionTemplate("workrelationselectiontemplate2"), 200, test_data_creator.WorkRelationSelectionTemplate("workrelationselectiontemplate2")) + GET_and_assert_expected_response(self, url, 200, test_data_creator.WorkRelationSelectionTemplate("workrelationselectiontemplate2")) def test_work_relation_selection_template_PATCH(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/', WorkRelationSelectionTemplate_test_data(), 201, WorkRelationSelectionTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/', test_data_creator.WorkRelationSelectionTemplate(), 201, test_data_creator.WorkRelationSelectionTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, WorkRelationSelectionTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.WorkRelationSelectionTemplate()) test_patch = {"version": 'v6.28318530718', "schema": {"mykey": "my better value"}, @@ -257,16 +261,16 @@ class WorkRelationSelectionTemplateTestCase(unittest.TestCase): # PATCH item and verify PATCH_and_assert_expected_response(self, url, test_patch, 200, test_patch) - expected_data = dict(WorkRelationSelectionTemplate_test_data()) + expected_data = dict(test_data_creator.WorkRelationSelectionTemplate()) expected_data.update(test_patch) GET_and_assert_expected_response(self, url, 200, expected_data) def test_work_relation_selection_template_DELETE(self): # POST new item, verify - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/', WorkRelationSelectionTemplate_test_data(), 201, WorkRelationSelectionTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/', test_data_creator.WorkRelationSelectionTemplate(), 201, test_data_creator.WorkRelationSelectionTemplate()) url = r_dict['url'] - GET_and_assert_expected_response(self, url, 200, WorkRelationSelectionTemplate_test_data()) + GET_and_assert_expected_response(self, url, 200, test_data_creator.WorkRelationSelectionTemplate()) # DELETE and check it's gone DELETE_and_assert_gone(self, url) @@ -283,7 +287,7 @@ class TaskConnectorsTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/task_connectors/1234321/', 404, {}) def test_task_connectors_POST_and_GET(self): - tc_test_data = TaskConnectors_test_data() + tc_test_data = test_data_creator.TaskConnectors() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', tc_test_data, 201, tc_test_data) url = r_dict['url'] @@ -292,7 +296,7 @@ class TaskConnectorsTestCase(unittest.TestCase): def test_task_connectors_POST_invalid_role_raises_error(self): # POST a new item with invalid choice - test_data_invalid_role = dict(TaskConnectors_test_data()) + test_data_invalid_role = dict(test_data_creator.TaskConnectors()) test_data_invalid_role['role'] = BASE_URL + '/role/forbidden/' r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', test_data_invalid_role, 400, {}) self.assertTrue('Invalid hyperlink' in str(r_dict['role'])) @@ -300,7 +304,7 @@ class TaskConnectorsTestCase(unittest.TestCase): def test_task_connectors_POST_invalid_datatype_raises_error(self): # POST a new item with invalid choice - test_data_invalid = dict(TaskConnectors_test_data()) + test_data_invalid = dict(test_data_creator.TaskConnectors()) test_data_invalid['datatype'] = BASE_URL + '/datatype/forbidden/' r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', test_data_invalid, 400, {}) self.assertTrue('Invalid hyperlink' in str(r_dict['datatype'])) @@ -308,7 +312,7 @@ class TaskConnectorsTestCase(unittest.TestCase): def test_task_connectors_POST_invalid_dataformats_raises_error(self): # POST a new item with invalid choice - test_data_invalid = dict(TaskConnectors_test_data()) + test_data_invalid = dict(test_data_creator.TaskConnectors()) test_data_invalid['dataformats'] = [BASE_URL + '/dataformat/forbidden/'] r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', test_data_invalid, 400, {}) self.assertTrue('Invalid hyperlink' in str(r_dict['dataformats'])) @@ -316,7 +320,7 @@ class TaskConnectorsTestCase(unittest.TestCase): def test_task_connectors_POST_nonexistant_input_of_raises_error(self): # POST a new item with wrong reference - test_data_invalid = dict(TaskConnectors_test_data()) + test_data_invalid = dict(test_data_creator.TaskConnectors()) test_data_invalid['input_of'] = BASE_URL + "/task_template/6353748/" r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', test_data_invalid, 400, {}) self.assertTrue('Invalid hyperlink' in str(r_dict['input_of'])) @@ -324,7 +328,7 @@ class TaskConnectorsTestCase(unittest.TestCase): def test_task_connectors_POST_nonexistant_output_of_raises_error(self): # POST a new item with wrong reference - test_data_invalid = dict(TaskConnectors_test_data()) + test_data_invalid = dict(test_data_creator.TaskConnectors()) test_data_invalid['output_of'] = BASE_URL + "/task_template/6353748/" r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', test_data_invalid, 400, {}) self.assertTrue('Invalid hyperlink' in str(r_dict['output_of'])) @@ -332,20 +336,20 @@ class TaskConnectorsTestCase(unittest.TestCase): def test_task_connectors_POST_existing_outputs_works(self): # First POST a new item to reference - r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', TaskTemplate_test_data(), 201, TaskTemplate_test_data()) + r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', test_data_creator.TaskTemplate(), 201, test_data_creator.TaskTemplate()) url = r_dict['url'] # POST a new item with correct reference - test_data_valid = dict(TaskConnectors_test_data()) + test_data_valid = dict(test_data_creator.TaskConnectors()) test_data_valid['output_of'] = url POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', test_data_valid, 201, test_data_valid) def test_task_connectors_PUT_nonexistant_raises_error(self): - PUT_and_assert_expected_response(self, BASE_URL + '/task_connectors/9876789876/', TaskConnectors_test_data(), 404, {}) + PUT_and_assert_expected_response(self, BASE_URL + '/task_connectors/9876789876/', test_data_creator.TaskConnectors(), 404, {}) def test_task_connectors_PUT(self): - tc_test_data1 = TaskConnectors_test_data(role="correlator") - tc_test_data2 = TaskConnectors_test_data(role="beamformer") + tc_test_data1 = test_data_creator.TaskConnectors(role="correlator") + tc_test_data2 = test_data_creator.TaskConnectors(role="beamformer") # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', tc_test_data1, 201, tc_test_data1) @@ -357,7 +361,7 @@ class TaskConnectorsTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, tc_test_data2) def test_task_connectors_PATCH(self): - tc_test_data = TaskConnectors_test_data() + tc_test_data = test_data_creator.TaskConnectors() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', tc_test_data, 201, tc_test_data) @@ -375,7 +379,7 @@ class TaskConnectorsTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_task_connectors_DELETE(self): - tc_test_data = TaskConnectors_test_data() + tc_test_data = test_data_creator.TaskConnectors() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', tc_test_data, 201, tc_test_data) @@ -387,7 +391,7 @@ class TaskConnectorsTestCase(unittest.TestCase): def test_task_relation_blueprint_CASCADE_behavior_on_inputs_template_deleted(self): - tc_test_data = TaskConnectors_test_data() + tc_test_data = test_data_creator.TaskConnectors() # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', tc_test_data, 201, tc_test_data)['url'] @@ -403,7 +407,7 @@ class TaskConnectorsTestCase(unittest.TestCase): def test_task_relation_blueprint_CASCADE_behavior_on_outputs_template_deleted(self): - tc_test_data = TaskConnectors_test_data() + tc_test_data = test_data_creator.TaskConnectors() # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_connectors/', tc_test_data, 201, tc_test_data)['url'] @@ -421,42 +425,42 @@ class TaskConnectorsTestCase(unittest.TestCase): class DefaultTemplates(unittest.TestCase): def test_default_generator_template_POST(self): r_dict = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', - GeneratorTemplate_test_data(), 201, - GeneratorTemplate_test_data()) + test_data_creator.GeneratorTemplate(), 201, + test_data_creator.GeneratorTemplate()) url = r_dict['url'] - test_data_1 = dict(DefaultTemplates_test_data()) + test_data_1 = dict(test_data_creator.DefaultTemplates()) test_data_1['template'] = url POST_and_assert_expected_response(self, BASE_URL + '/default_generator_template/', test_data_1, 201, test_data_1) def test_default_scheduling_unit_template_POST(self): r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/', - SchedulingUnitTemplate_test_data(), 201, - SchedulingUnitTemplate_test_data()) + test_data_creator.SchedulingUnitTemplate(), 201, + test_data_creator.SchedulingUnitTemplate()) url = r_dict['url'] - test_data_1 = dict(DefaultTemplates_test_data()) + test_data_1 = dict(test_data_creator.DefaultTemplates()) test_data_1['template'] = url POST_and_assert_expected_response(self, BASE_URL + '/default_scheduling_unit_template/', test_data_1, 201, test_data_1) def test_default_task_template_POST(self): r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', - TaskTemplate_test_data(), 201, - TaskTemplate_test_data()) + test_data_creator.TaskTemplate(), 201, + test_data_creator.TaskTemplate()) url = r_dict['url'] - test_data_1 = dict(DefaultTemplates_test_data()) + test_data_1 = dict(test_data_creator.DefaultTemplates()) test_data_1['template'] = url POST_and_assert_expected_response(self, BASE_URL + '/default_task_template/', test_data_1, 201, test_data_1) def test_default_work_relation_selection_template_POST(self): r_dict = POST_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/', - WorkRelationSelectionTemplate_test_data(), 201, - WorkRelationSelectionTemplate_test_data()) + test_data_creator.WorkRelationSelectionTemplate(), 201, + test_data_creator.WorkRelationSelectionTemplate()) url = r_dict['url'] - test_data_1 = dict(DefaultTemplates_test_data()) + test_data_1 = dict(test_data_creator.DefaultTemplates()) test_data_1['template'] = url POST_and_assert_expected_response(self, BASE_URL + '/default_work_relation_selection_template/', test_data_1, 201, test_data_1) @@ -464,9 +468,9 @@ class DefaultTemplates(unittest.TestCase): # POST with dependency template_url = POST_and_assert_expected_response(self, BASE_URL + '/generator_template/', - GeneratorTemplate_test_data(), 201, - GeneratorTemplate_test_data())['url'] - test_data = dict(DefaultTemplates_test_data("defaulttemplate2")) + test_data_creator.GeneratorTemplate(), 201, + test_data_creator.GeneratorTemplate())['url'] + test_data = dict(test_data_creator.DefaultTemplates("defaulttemplate2")) test_data['template'] = template_url POST_and_assert_expected_response(self, BASE_URL + '/default_generator_template/', test_data, 201, test_data) @@ -476,15 +480,15 @@ class DefaultTemplates(unittest.TestCase): response = requests.delete(template_url, auth=AUTH) self.assertEqual(500, response.status_code) self.assertTrue("ProtectedError" in str(response.content)) - GET_and_assert_expected_response(self, template_url, 200, GeneratorTemplate_test_data()) + GET_and_assert_expected_response(self, template_url, 200, test_data_creator.GeneratorTemplate()) def test_default_scheduling_unit_template_PROTECT_behavior_on_template_deleted(self): # POST with dependency template_url = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_template/', - SchedulingUnitTemplate_test_data(), 201, - SchedulingUnitTemplate_test_data())['url'] - test_data = dict(DefaultTemplates_test_data("defaulttemplate2")) + test_data_creator.SchedulingUnitTemplate(), 201, + test_data_creator.SchedulingUnitTemplate())['url'] + test_data = dict(test_data_creator.DefaultTemplates("defaulttemplate2")) test_data['template'] = template_url POST_and_assert_expected_response(self, BASE_URL + '/default_scheduling_unit_template/', test_data, 201, test_data) @@ -494,16 +498,16 @@ class DefaultTemplates(unittest.TestCase): response = requests.delete(template_url, auth=AUTH) self.assertEqual(500, response.status_code) self.assertTrue("ProtectedError" in str(response.content)) - GET_and_assert_expected_response(self, template_url, 200, SchedulingUnitTemplate_test_data()) + GET_and_assert_expected_response(self, template_url, 200, test_data_creator.SchedulingUnitTemplate()) def test_default_task_template_PROTECT_behavior_on_template_deleted(self): # POST with dependency template_url = POST_and_assert_expected_response(self, BASE_URL + '/task_template/', - TaskTemplate_test_data(), 201, - TaskTemplate_test_data())['url'] - test_data = dict(DefaultTemplates_test_data("defaulttemplate2")) + test_data_creator.TaskTemplate(), 201, + test_data_creator.TaskTemplate())['url'] + test_data = dict(test_data_creator.DefaultTemplates("defaulttemplate2")) test_data['template'] = template_url POST_and_assert_expected_response(self, BASE_URL + '/default_task_template/', test_data, 201, test_data) @@ -513,15 +517,15 @@ class DefaultTemplates(unittest.TestCase): response = requests.delete(template_url, auth=AUTH) self.assertEqual(500, response.status_code) self.assertTrue("ProtectedError" in str(response.content)) - GET_and_assert_expected_response(self, template_url, 200, TaskTemplate_test_data()) + GET_and_assert_expected_response(self, template_url, 200, test_data_creator.TaskTemplate()) def test_default_work_relation_selection_template_PROTECT_behavior_on_template_deleted(self): # POST with dependency template_url = POST_and_assert_expected_response(self, BASE_URL + '/work_relation_selection_template/', - WorkRelationSelectionTemplate_test_data(), 201, - WorkRelationSelectionTemplate_test_data())['url'] - test_data = dict(DefaultTemplates_test_data("defaulttemplate2")) + test_data_creator.WorkRelationSelectionTemplate(), 201, + test_data_creator.WorkRelationSelectionTemplate())['url'] + test_data = dict(test_data_creator.DefaultTemplates("defaulttemplate2")) test_data['template'] = template_url POST_and_assert_expected_response(self, BASE_URL + '/default_work_relation_selection_template/', test_data, 201, test_data) @@ -531,7 +535,7 @@ class DefaultTemplates(unittest.TestCase): response = requests.delete(template_url, auth=AUTH) self.assertEqual(500, response.status_code) self.assertTrue("ProtectedError" in str(response.content)) - GET_and_assert_expected_response(self, template_url, 200, WorkRelationSelectionTemplate_test_data()) + GET_and_assert_expected_response(self, template_url, 200, test_data_creator.WorkRelationSelectionTemplate()) class CycleTestCase(unittest.TestCase): @@ -546,16 +550,16 @@ class CycleTestCase(unittest.TestCase): def test_cycle_POST_and_GET(self): # POST and GET a new item and assert correctness - cycle_test_data = Cycle_test_data() + cycle_test_data = test_data_creator.Cycle() r_dict = POST_and_assert_expected_response(self, BASE_URL + '/cycle/', cycle_test_data, 201, cycle_test_data) url = r_dict['url'] GET_and_assert_expected_response(self, url, 200, cycle_test_data) def test_cycle_PUT_invalid_raises_error(self): - PUT_and_assert_expected_response(self, BASE_URL + '/cycle/9876789876/', Cycle_test_data(), 404, {}) + PUT_and_assert_expected_response(self, BASE_URL + '/cycle/9876789876/', test_data_creator.Cycle(), 404, {}) def test_cycle_PUT(self): - cycle_test_data = Cycle_test_data() + cycle_test_data = test_data_creator.Cycle() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/cycle/', cycle_test_data, 201, cycle_test_data) @@ -563,13 +567,13 @@ class CycleTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, cycle_test_data) # PUT new values, verify - test_data = dict(Cycle_test_data("other description")) + test_data = dict(test_data_creator.Cycle("other description")) test_data['name'] = cycle_test_data['name'] # since name is PK, need to keep that unchanged PUT_and_assert_expected_response(self, url, test_data, 200, test_data) GET_and_assert_expected_response(self, url, 200, test_data) def test_cycle_PATCH(self): - cycle_test_data = Cycle_test_data() + cycle_test_data = test_data_creator.Cycle() # POST new item, verify @@ -586,7 +590,7 @@ class CycleTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_cycle_DELETE(self): - cycle_test_data = Cycle_test_data() + cycle_test_data = test_data_creator.Cycle() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/cycle/', cycle_test_data, 201, cycle_test_data) @@ -607,7 +611,7 @@ class ProjectTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/project/1234321/', 404, {}) def test_project_POST_and_GET(self): - project_test_data = Project_test_data() + project_test_data = test_data_creator.Project() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/project/', project_test_data, 201, project_test_data) @@ -615,10 +619,10 @@ class ProjectTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, project_test_data) def test_project_PUT_invalid_raises_error(self): - PUT_and_assert_expected_response(self, BASE_URL + '/project/9876789876/', Project_test_data(), 404, {}) + PUT_and_assert_expected_response(self, BASE_URL + '/project/9876789876/', test_data_creator.Project(), 404, {}) def test_project_PUT(self): - project_test_data = Project_test_data() + project_test_data = test_data_creator.Project() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/project/', project_test_data, 201, project_test_data) @@ -626,13 +630,13 @@ class ProjectTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, project_test_data) # PUT new values, verify - test_data = dict(Project_test_data("other description")) + test_data = dict(test_data_creator.Project("other description")) test_data['name'] = project_test_data['name'] # since name is PK, need to keep that unchanged PUT_and_assert_expected_response(self, url, test_data, 200, test_data) GET_and_assert_expected_response(self, url, 200, test_data) def test_project_PATCH(self): - project_test_data = Project_test_data() + project_test_data = test_data_creator.Project() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/project/', project_test_data, 201, project_test_data) @@ -649,7 +653,7 @@ class ProjectTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_project_DELETE(self): - project_test_data = Project_test_data() + project_test_data = test_data_creator.Project() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/project/', project_test_data, 201, project_test_data) @@ -662,9 +666,9 @@ class ProjectTestCase(unittest.TestCase): def test_project_PROTECT_behavior_on_cycle_deleted(self): # POST new item with dependencies - cycle_test_data = Cycle_test_data() + cycle_test_data = test_data_creator.Cycle() cycle_url = POST_and_assert_expected_response(self, BASE_URL + '/cycle/', cycle_test_data, 201, cycle_test_data)['url'] - test_data = dict(Project_test_data()) + test_data = dict(test_data_creator.Project()) test_data['cycle'] = cycle_url url = POST_and_assert_expected_response(self, BASE_URL + '/project/', test_data, 201, test_data)['url'] @@ -692,7 +696,7 @@ class SchedulingSetTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/scheduling_set/1234321/', 404, {}) def test_scheduling_set_POST_and_GET(self): - schedulingset_test_data = SchedulingSet_test_data() + schedulingset_test_data = test_data_creator.SchedulingSet() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_set/', schedulingset_test_data, 201, schedulingset_test_data) @@ -700,25 +704,25 @@ class SchedulingSetTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, schedulingset_test_data) def test_scheduling_set_PUT_invalid_raises_error(self): - schedulingset_test_data = SchedulingSet_test_data() + schedulingset_test_data = test_data_creator.SchedulingSet() PUT_and_assert_expected_response(self, BASE_URL + '/scheduling_set/9876789876/', schedulingset_test_data, 404, {}) def test_scheduling_set_PUT(self): - project_url = post_data_and_get_url(Project_test_data(), '/project/') - schedulingset_test_data = SchedulingSet_test_data(project_url=project_url) + project_url = test_data_creator.post_data_and_get_url(test_data_creator.Project(), '/project/') + schedulingset_test_data = test_data_creator.SchedulingSet(project_url=project_url) # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_set/', schedulingset_test_data, 201, schedulingset_test_data) url = r_dict['url'] GET_and_assert_expected_response(self, url, 200, schedulingset_test_data) - schedulingset_test_data2 = SchedulingSet_test_data("schedulingset2", project_url=project_url) + schedulingset_test_data2 = test_data_creator.SchedulingSet("schedulingset2", project_url=project_url) # PUT new values, verify PUT_and_assert_expected_response(self, url, schedulingset_test_data2, 200, schedulingset_test_data2) GET_and_assert_expected_response(self, url, 200, schedulingset_test_data2) def test_scheduling_set_PATCH(self): - schedulingset_test_data = SchedulingSet_test_data() + schedulingset_test_data = test_data_creator.SchedulingSet() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_set/', schedulingset_test_data, 201, schedulingset_test_data) @@ -735,7 +739,7 @@ class SchedulingSetTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_scheduling_set_DELETE(self): - schedulingset_test_data = SchedulingSet_test_data() + schedulingset_test_data = test_data_creator.SchedulingSet() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_set/', schedulingset_test_data, 201, schedulingset_test_data) @@ -746,9 +750,9 @@ class SchedulingSetTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_scheduling_set_PROTECT_behavior_on_project_deleted(self): - project_url = post_data_and_get_url(Project_test_data(), '/project/') + project_url = test_data_creator.post_data_and_get_url(test_data_creator.Project(), '/project/') project_test_data = GET_and_assert_expected_response(self, project_url, 200, {}) - schedulingset_test_data = SchedulingSet_test_data(project_url=project_url) + schedulingset_test_data = test_data_creator.SchedulingSet(project_url=project_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_set/', schedulingset_test_data, 201, schedulingset_test_data)['url'] @@ -764,8 +768,8 @@ class SchedulingSetTestCase(unittest.TestCase): GET_and_assert_expected_response(self, project_url, 200, project_test_data) def test_scheduling_set_SET_NULL_behavior_on_generator_template_deleted(self): - generator_template_url = post_data_and_get_url(GeneratorTemplate_test_data(), '/generator_template/') - schedulingset_test_data = SchedulingSet_test_data(generator_template_url=generator_template_url) + generator_template_url = test_data_creator.post_data_and_get_url(test_data_creator.GeneratorTemplate(), '/generator_template/') + schedulingset_test_data = test_data_creator.SchedulingSet(generator_template_url=generator_template_url) # POST new item test_data = dict(schedulingset_test_data) @@ -792,7 +796,7 @@ class SchedulingUnitDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_draft/1234321/', 404, {}) def test_scheduling_unit_draft_POST_and_GET(self): - schedulingunitdraft_test_data = SchedulingUnitDraft_test_data() + schedulingunitdraft_test_data = test_data_creator.SchedulingUnitDraft() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_draft/', schedulingunitdraft_test_data, 201, schedulingunitdraft_test_data) @@ -800,25 +804,25 @@ class SchedulingUnitDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, schedulingunitdraft_test_data) def test_scheduling_unit_draft_PUT_invalid_raises_error(self): - schedulingunitdraft_test_data = SchedulingUnitDraft_test_data() + schedulingunitdraft_test_data = test_data_creator.SchedulingUnitDraft() PUT_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_draft/9876789876/', schedulingunitdraft_test_data, 404, {}) def test_scheduling_unit_draft_PUT(self): - schedulingunitdraft_test_data = SchedulingUnitDraft_test_data() + schedulingunitdraft_test_data = test_data_creator.SchedulingUnitDraft() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_draft/', schedulingunitdraft_test_data, 201, schedulingunitdraft_test_data) url = r_dict['url'] GET_and_assert_expected_response(self, url, 200, schedulingunitdraft_test_data) - schedulingunitdraft_test_data2 = SchedulingUnitDraft_test_data("my_scheduling_unit_draft2") + schedulingunitdraft_test_data2 = test_data_creator.SchedulingUnitDraft("my_scheduling_unit_draft2") # PUT new values, verify PUT_and_assert_expected_response(self, url, schedulingunitdraft_test_data2, 200, schedulingunitdraft_test_data2) GET_and_assert_expected_response(self, url, 200, schedulingunitdraft_test_data2) def test_scheduling_unit_draft_PATCH(self): - schedulingunitdraft_test_data = SchedulingUnitDraft_test_data() + schedulingunitdraft_test_data = test_data_creator.SchedulingUnitDraft() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_draft/', schedulingunitdraft_test_data, 201, schedulingunitdraft_test_data) @@ -835,7 +839,7 @@ class SchedulingUnitDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_scheduling_unit_draft_DELETE(self): - schedulingunitdraft_test_data = SchedulingUnitDraft_test_data() + schedulingunitdraft_test_data = test_data_creator.SchedulingUnitDraft() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_draft/', schedulingunitdraft_test_data, 201, schedulingunitdraft_test_data) @@ -846,8 +850,8 @@ class SchedulingUnitDraftTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_scheduling_unit_draft_CASCADE_behavior_on_scheduling_unit_template_deleted(self): - template_url = post_data_and_get_url(SchedulingUnitTemplate_test_data(), '/scheduling_unit_template/') - schedulingunitdraft_test_data = SchedulingUnitDraft_test_data(template_url=template_url) + template_url = test_data_creator.post_data_and_get_url(test_data_creator.SchedulingUnitTemplate(), '/scheduling_unit_template/') + schedulingunitdraft_test_data = test_data_creator.SchedulingUnitDraft(template_url=template_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_draft/', schedulingunitdraft_test_data, 201, schedulingunitdraft_test_data)['url'] @@ -862,8 +866,8 @@ class SchedulingUnitDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_scheduling_unit_draft_CASCADE_behavior_on_scheduling_set_deleted(self): - scheduling_set_url = post_data_and_get_url(SchedulingSet_test_data(), '/scheduling_set/') - schedulingunitdraft_test_data = SchedulingUnitDraft_test_data(scheduling_set_url=scheduling_set_url) + scheduling_set_url = test_data_creator.post_data_and_get_url(test_data_creator.SchedulingSet(), '/scheduling_set/') + schedulingunitdraft_test_data = test_data_creator.SchedulingUnitDraft(scheduling_set_url=scheduling_set_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_draft/', schedulingunitdraft_test_data, 201, schedulingunitdraft_test_data)['url'] @@ -878,7 +882,7 @@ class SchedulingUnitDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_scheduling_unit_draft_SET_NULL_behavior_on_copies_deleted(self): - schedulingunitdraft_test_data = SchedulingUnitDraft_test_data() + schedulingunitdraft_test_data = test_data_creator.SchedulingUnitDraft() # POST new item with dependency copy_url = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_draft/', schedulingunitdraft_test_data, 201, schedulingunitdraft_test_data)['url'] @@ -907,7 +911,7 @@ class TaskDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/task_draft/1234321/', 404, {}) def test_task_draft_POST_and_GET(self): - taskdraft_test_data = TaskDraft_test_data() + taskdraft_test_data = test_data_creator.TaskDraft() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_draft/', taskdraft_test_data, 201, taskdraft_test_data) @@ -915,12 +919,12 @@ class TaskDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, taskdraft_test_data) def test_task_draft_PUT_invalid_raises_error(self): - taskdraft_test_data = TaskDraft_test_data() + taskdraft_test_data = test_data_creator.TaskDraft() PUT_and_assert_expected_response(self, BASE_URL + '/task_draft/9876789876/', taskdraft_test_data, 404, {}) def test_task_draft_PUT(self): - taskdraft_test_data1 = TaskDraft_test_data(name="the one") - taskdraft_test_data2 = TaskDraft_test_data(name="the other") + taskdraft_test_data1 = test_data_creator.TaskDraft(name="the one") + taskdraft_test_data2 = test_data_creator.TaskDraft(name="the other") # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_draft/', taskdraft_test_data1, 201, taskdraft_test_data1) @@ -932,7 +936,7 @@ class TaskDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, taskdraft_test_data2) def test_task_draft_PATCH(self): - taskdraft_test_data = TaskDraft_test_data() + taskdraft_test_data = test_data_creator.TaskDraft() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_draft/', taskdraft_test_data, 201, taskdraft_test_data) @@ -949,7 +953,7 @@ class TaskDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_task_draft_DELETE(self): - taskdraft_test_data = TaskDraft_test_data() + taskdraft_test_data = test_data_creator.TaskDraft() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_draft/', taskdraft_test_data, 201, taskdraft_test_data) @@ -960,8 +964,8 @@ class TaskDraftTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_task_draft_CASCADE_behavior_on_task_template_deleted(self): - template_url = post_data_and_get_url(TaskTemplate_test_data(), '/task_template/') - taskdraft_test_data = TaskDraft_test_data(name="task draft 2", template_url=template_url) + template_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskTemplate(), '/task_template/') + taskdraft_test_data = test_data_creator.TaskDraft(name="task draft 2", template_url=template_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_draft/', taskdraft_test_data, 201, taskdraft_test_data)['url'] @@ -976,8 +980,8 @@ class TaskDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_task_draft_CASCADE_behavior_on_scheduling_unit_draft_deleted(self): - scheduling_unit_draft_url = post_data_and_get_url(SchedulingUnitDraft_test_data(), '/scheduling_unit_draft/') - taskdraft_test_data = TaskDraft_test_data(name="task draft 2", scheduling_unit_draft_url=scheduling_unit_draft_url) + scheduling_unit_draft_url = test_data_creator.post_data_and_get_url(test_data_creator.SchedulingUnitDraft(), '/scheduling_unit_draft/') + taskdraft_test_data = test_data_creator.TaskDraft(name="task draft 2", scheduling_unit_draft_url=scheduling_unit_draft_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_draft/', taskdraft_test_data, 201, taskdraft_test_data)['url'] @@ -992,8 +996,8 @@ class TaskDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_task_draft_SET_NULL_behavior_on_copies_deleted(self): - taskdraft_test_data1 = TaskDraft_test_data(name="the one") - taskdraft_test_data2 = TaskDraft_test_data(name="the other") + taskdraft_test_data1 = test_data_creator.TaskDraft(name="the one") + taskdraft_test_data2 = test_data_creator.TaskDraft(name="the other") # POST new item with dependency copy_url = POST_and_assert_expected_response(self, BASE_URL + '/task_draft/', taskdraft_test_data2, 201, taskdraft_test_data2)['url'] @@ -1022,7 +1026,7 @@ class TaskRelationDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/1234321/', 404, {}) def test_task_relation_draft_POST_and_GET(self): - trd_test_data = TaskRelationDraft_test_data() + trd_test_data = test_data_creator.TaskRelationDraft() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/', trd_test_data, 201, trd_test_data) @@ -1030,12 +1034,12 @@ class TaskRelationDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, trd_test_data) def test_task_relation_draft_PUT_invalid_raises_error(self): - trd_test_data = TaskRelationDraft_test_data() + trd_test_data = test_data_creator.TaskRelationDraft() PUT_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/9876789876/', trd_test_data, 404, {}) def test_task_relation_draft_PUT(self): - trd_test_data1 = TaskRelationDraft_test_data() - trd_test_data2 = TaskRelationDraft_test_data() + trd_test_data1 = test_data_creator.TaskRelationDraft() + trd_test_data2 = test_data_creator.TaskRelationDraft() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/', trd_test_data1, 201, trd_test_data1) @@ -1047,7 +1051,7 @@ class TaskRelationDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, trd_test_data2) def test_task_relation_draft_PATCH(self): - trd_test_data = TaskRelationDraft_test_data() + trd_test_data = test_data_creator.TaskRelationDraft() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/', trd_test_data, 201, trd_test_data) @@ -1063,7 +1067,7 @@ class TaskRelationDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_task_relation_draft_DELETE(self): - trd_test_data = TaskRelationDraft_test_data() + trd_test_data = test_data_creator.TaskRelationDraft() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/', trd_test_data, 201, trd_test_data) @@ -1074,8 +1078,8 @@ class TaskRelationDraftTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_task_relation_draft_CASCADE_behavior_on_work_relation_selection_template_deleted(self): - template_url = post_data_and_get_url(WorkRelationSelectionTemplate_test_data(), '/work_relation_selection_template/') - trd_test_data = TaskRelationDraft_test_data(template_url=template_url) + template_url = test_data_creator.post_data_and_get_url(test_data_creator.WorkRelationSelectionTemplate(), '/work_relation_selection_template/') + trd_test_data = test_data_creator.TaskRelationDraft(template_url=template_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/', trd_test_data, 201, trd_test_data)['url'] @@ -1090,8 +1094,8 @@ class TaskRelationDraftTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_task_relation_draft_CASCADE_behavior_on_producer_deleted(self): - producer_url = post_data_and_get_url(TaskDraft_test_data(), '/task_draft/') - trd_test_data = TaskRelationDraft_test_data(producer_url=producer_url) + producer_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskDraft(), '/task_draft/') + trd_test_data = test_data_creator.TaskRelationDraft(producer_url=producer_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/', @@ -1108,8 +1112,8 @@ class TaskRelationDraftTestCase(unittest.TestCase): def test_task_relation_draft_CASCADE_behavior_on_consumer_deleted(self): - consumer_url = post_data_and_get_url(TaskDraft_test_data(), '/task_draft/') - trd_test_data = TaskRelationDraft_test_data(consumer_url=consumer_url) + consumer_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskDraft(), '/task_draft/') + trd_test_data = test_data_creator.TaskRelationDraft(consumer_url=consumer_url) # POST new item with dependency url = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/', @@ -1126,8 +1130,8 @@ class TaskRelationDraftTestCase(unittest.TestCase): def test_task_relation_draft_CASCADE_behavior_on_input_deleted(self): - input_url = post_data_and_get_url(TaskConnectors_test_data(), '/task_connectors/') - trd_test_data = TaskRelationDraft_test_data(input_url=input_url) + input_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskConnectors(), '/task_connectors/') + trd_test_data = test_data_creator.TaskRelationDraft(input_url=input_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/', @@ -1144,8 +1148,8 @@ class TaskRelationDraftTestCase(unittest.TestCase): def test_task_relation_draft_CASCADE_behavior_on_output_deleted(self): - output_url = post_data_and_get_url(TaskConnectors_test_data(), '/task_connectors/') - trd_test_data = TaskRelationDraft_test_data(output_url=output_url) + output_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskConnectors(), '/task_connectors/') + trd_test_data = test_data_creator.TaskRelationDraft(output_url=output_url) # POST new item with dependency url = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_draft/', @@ -1171,7 +1175,7 @@ class SchedulingUnitBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_blueprint/1234321/', 404, {}) def test_scheduling_unit_blueprint_POST_and_GET(self): - sub_test_data = SchedulingUnitBlueprint_test_data() + sub_test_data = test_data_creator.SchedulingUnitBlueprint() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_blueprint/', sub_test_data, 201, sub_test_data) @@ -1179,12 +1183,12 @@ class SchedulingUnitBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, sub_test_data) def test_scheduling_unit_blueprint_PUT_invalid_raises_error(self): - sub_test_data = SchedulingUnitBlueprint_test_data() + sub_test_data = test_data_creator.SchedulingUnitBlueprint() PUT_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_blueprint/9876789876/', sub_test_data, 404, {}) def test_scheduling_unit_blueprint_PUT(self): - sub_test_data1 = SchedulingUnitBlueprint_test_data(name="the one") - sub_test_data2 = SchedulingUnitBlueprint_test_data(name="the other") + sub_test_data1 = test_data_creator.SchedulingUnitBlueprint(name="the one") + sub_test_data2 = test_data_creator.SchedulingUnitBlueprint(name="the other") # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_blueprint/', sub_test_data1, 201, sub_test_data1) @@ -1196,7 +1200,7 @@ class SchedulingUnitBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, sub_test_data2) def test_scheduling_unit_blueprint_PATCH(self): - sub_test_data = SchedulingUnitBlueprint_test_data() + sub_test_data = test_data_creator.SchedulingUnitBlueprint() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_blueprint/', sub_test_data, 201, sub_test_data) @@ -1213,7 +1217,7 @@ class SchedulingUnitBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_scheduling_unit_blueprint_DELETE(self): - sub_test_data = SchedulingUnitBlueprint_test_data() + sub_test_data = test_data_creator.SchedulingUnitBlueprint() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_blueprint/', sub_test_data, 201, sub_test_data) @@ -1224,7 +1228,7 @@ class SchedulingUnitBlueprintTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_scheduling_unit_blueprint_CASCADE_behavior_on_scheduling_unit_template_deleted(self): - sub_test_data = SchedulingUnitBlueprint_test_data() + sub_test_data = test_data_creator.SchedulingUnitBlueprint() # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_blueprint/', sub_test_data, 201, sub_test_data)['url'] @@ -1239,7 +1243,7 @@ class SchedulingUnitBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_scheduling_unit_blueprint_CASCADE_behavior_on_scheduling_unit_draft_deleted(self): - sub_test_data = SchedulingUnitBlueprint_test_data() + sub_test_data = test_data_creator.SchedulingUnitBlueprint() # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/scheduling_unit_blueprint/', sub_test_data, 201, sub_test_data)['url'] @@ -1263,7 +1267,7 @@ class TaskBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/task_blueprint/1234321/', 404, {}) def test_task_blueprint_POST_and_GET(self): - tb_test_data = TaskBlueprint_test_data() + tb_test_data = test_data_creator.TaskBlueprint() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_blueprint/', tb_test_data, 201, tb_test_data) @@ -1271,12 +1275,12 @@ class TaskBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, tb_test_data) def test_task_blueprint_PUT_invalid_raises_error(self): - tb_test_data = TaskBlueprint_test_data() + tb_test_data = test_data_creator.TaskBlueprint() PUT_and_assert_expected_response(self, BASE_URL + '/task_blueprint/9876789876/', tb_test_data, 404, {}) def test_task_blueprint_PUT(self): - tb_test_data1 = TaskBlueprint_test_data(name="the one") - tb_test_data2 = TaskBlueprint_test_data(name="the other") + tb_test_data1 = test_data_creator.TaskBlueprint(name="the one") + tb_test_data2 = test_data_creator.TaskBlueprint(name="the other") # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_blueprint/', tb_test_data1, 201, tb_test_data1) @@ -1288,7 +1292,7 @@ class TaskBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, tb_test_data2) def test_task_blueprint_PATCH(self): - tb_test_data = TaskBlueprint_test_data() + tb_test_data = test_data_creator.TaskBlueprint() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_blueprint/', tb_test_data, 201, tb_test_data) @@ -1305,7 +1309,7 @@ class TaskBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_task_blueprint_DELETE(self): - tb_test_data = TaskBlueprint_test_data() + tb_test_data = test_data_creator.TaskBlueprint() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_blueprint/', tb_test_data, 201, tb_test_data) @@ -1316,7 +1320,7 @@ class TaskBlueprintTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_task_blueprint_prevents_missing_specification_template(self): - tb_test_data = TaskBlueprint_test_data() + tb_test_data = test_data_creator.TaskBlueprint() # test data test_data = dict(tb_test_data) @@ -1327,7 +1331,7 @@ class TaskBlueprintTestCase(unittest.TestCase): self.assertTrue('This field may not be null' in str(r_dict['specifications_template'])) def test_task_blueprint_prevents_missing_draft(self): - tb_test_data = TaskBlueprint_test_data() + tb_test_data = test_data_creator.TaskBlueprint() # test data test_data = dict(tb_test_data) @@ -1338,7 +1342,7 @@ class TaskBlueprintTestCase(unittest.TestCase): self.assertTrue('This field may not be null' in str(r_dict['draft'])) def test_task_blueprint_prevents_missing_scheduling_unit_blueprint(self): - tb_test_data = TaskBlueprint_test_data() + tb_test_data = test_data_creator.TaskBlueprint() # test data test_data = dict(tb_test_data) @@ -1349,7 +1353,7 @@ class TaskBlueprintTestCase(unittest.TestCase): self.assertTrue('This field may not be null' in str(r_dict['scheduling_unit_blueprint'])) def test_task_blueprint_CASCADE_behavior_on_task_template_deleted(self): - tb_test_data = TaskBlueprint_test_data() + tb_test_data = test_data_creator.TaskBlueprint() # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_blueprint/', tb_test_data, 201, tb_test_data)['url'] @@ -1364,7 +1368,7 @@ class TaskBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_task_blueprint_CASCADE_behavior_on_task_draft_deleted(self): - tb_test_data = TaskBlueprint_test_data() + tb_test_data = test_data_creator.TaskBlueprint() # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_blueprint/', tb_test_data, 201, tb_test_data)['url'] @@ -1379,7 +1383,7 @@ class TaskBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_task_blueprint_CASCADE_behavior_on_scheduling_unit_blueprint_deleted(self): - tb_test_data = TaskBlueprint_test_data() + tb_test_data = test_data_creator.TaskBlueprint() # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_blueprint/', tb_test_data, 201, tb_test_data)['url'] @@ -1404,7 +1408,7 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/1234321/', 404, {}) def test_task_relation_blueprint_POST_and_GET(self): - trb_test_data = TaskRelationBlueprint_test_data() + trb_test_data = test_data_creator.TaskRelationBlueprint() # POST and GET a new item and assert correctness r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/', trb_test_data, 201, trb_test_data) @@ -1412,12 +1416,12 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, trb_test_data) def test_task_relation_blueprint_PUT_invalid_raises_error(self): - trb_test_data = TaskRelationBlueprint_test_data() + trb_test_data = test_data_creator.TaskRelationBlueprint() PUT_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/9876789876/', trb_test_data, 404, {}) def test_task_relation_blueprint_PUT(self): - trb_test_data1 = TaskRelationBlueprint_test_data() - trb_test_data2 = TaskRelationBlueprint_test_data() + trb_test_data1 = test_data_creator.TaskRelationBlueprint() + trb_test_data2 = test_data_creator.TaskRelationBlueprint() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/', trb_test_data1, 201, trb_test_data1) @@ -1429,7 +1433,7 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, trb_test_data2) def test_task_relation_blueprint_PATCH(self): - trb_test_data = TaskRelationBlueprint_test_data() + trb_test_data = test_data_creator.TaskRelationBlueprint() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/', trb_test_data, 201, trb_test_data) @@ -1445,7 +1449,7 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 200, expected_data) def test_task_relation_blueprint_DELETE(self): - trb_test_data = TaskRelationBlueprint_test_data() + trb_test_data = test_data_creator.TaskRelationBlueprint() # POST new item, verify r_dict = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/', trb_test_data, 201, trb_test_data) @@ -1456,7 +1460,7 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): DELETE_and_assert_gone(self, url) def test_task_relation_blueprint_prevents_missing_selection_template(self): - trb_test_data = TaskRelationBlueprint_test_data() + trb_test_data = test_data_creator.TaskRelationBlueprint() # test data test_data = dict(trb_test_data) @@ -1467,7 +1471,7 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): self.assertTrue('This field may not be null' in str(r_dict['selection_template'])) def test_task_relation_blueprint_prevents_missing_draft(self): - trb_test_data = TaskRelationBlueprint_test_data() + trb_test_data = test_data_creator.TaskRelationBlueprint() # test data test_data = dict(trb_test_data) @@ -1478,7 +1482,7 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): self.assertTrue('This field may not be null' in str(r_dict['draft'])) def test_task_relation_blueprint_prevents_missing_producer(self): - trb_test_data = TaskRelationBlueprint_test_data() + trb_test_data = test_data_creator.TaskRelationBlueprint() # test data test_data = dict(trb_test_data) @@ -1489,7 +1493,7 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): self.assertTrue('This field may not be null' in str(r_dict['producer'])) def test_task_relation_blueprint_prevents_missing_consumer(self): - trb_test_data = TaskRelationBlueprint_test_data() + trb_test_data = test_data_creator.TaskRelationBlueprint() # test data test_data = dict(trb_test_data) @@ -1500,7 +1504,7 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): self.assertTrue('This field may not be null' in str(r_dict['consumer'])) def test_task_relation_blueprint_prevents_missing_input(self): - trb_test_data = TaskRelationBlueprint_test_data() + trb_test_data = test_data_creator.TaskRelationBlueprint() # test data test_data = dict(trb_test_data) @@ -1511,7 +1515,7 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): self.assertTrue('This field may not be null' in str(r_dict['input'])) def test_task_relation_blueprint_prevents_missing_output(self): - trb_test_data = TaskRelationBlueprint_test_data() + trb_test_data = test_data_creator.TaskRelationBlueprint() # test data test_data = dict(trb_test_data) @@ -1522,8 +1526,8 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): self.assertTrue('This field may not be null' in str(r_dict['output'])) def test_task_relation_blueprint_CASCADE_behavior_on_work_relation_selection_template_deleted(self): - template_url = post_data_and_get_url(WorkRelationSelectionTemplate_test_data(), '/work_relation_selection_template/') - trb_test_data = TaskRelationBlueprint_test_data(template_url=template_url) + template_url = test_data_creator.post_data_and_get_url(test_data_creator.WorkRelationSelectionTemplate(), '/work_relation_selection_template/') + trb_test_data = test_data_creator.TaskRelationBlueprint(template_url=template_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/', trb_test_data, 201, trb_test_data)['url'] @@ -1538,8 +1542,8 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): GET_and_assert_expected_response(self, url, 404, {}) def test_task_relation_blueprint_CASCADE_behavior_on_producer_deleted(self): - producer_url = post_data_and_get_url(TaskBlueprint_test_data(), '/task_blueprint/') - trb_test_data = TaskRelationBlueprint_test_data(producer_url=producer_url) + producer_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskBlueprint(), '/task_blueprint/') + trb_test_data = test_data_creator.TaskRelationBlueprint(producer_url=producer_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/', @@ -1556,8 +1560,8 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): def test_task_relation_blueprint_CASCADE_behavior_on_consumer_deleted(self): - consumer_url = post_data_and_get_url(TaskBlueprint_test_data(), '/task_blueprint/') - trb_test_data = TaskRelationBlueprint_test_data(consumer_url=consumer_url) + consumer_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskBlueprint(), '/task_blueprint/') + trb_test_data = test_data_creator.TaskRelationBlueprint(consumer_url=consumer_url) # POST new item with dependency url = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/', @@ -1574,8 +1578,8 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): def test_task_relation_blueprint_CASCADE_behavior_on_input_deleted(self): - input_url = post_data_and_get_url(TaskConnectors_test_data(), '/task_connectors/') - trb_test_data = TaskRelationBlueprint_test_data(input_url=input_url) + input_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskConnectors(), '/task_connectors/') + trb_test_data = test_data_creator.TaskRelationBlueprint(input_url=input_url) # POST new item url = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/', @@ -1592,8 +1596,8 @@ class TaskRelationBlueprintTestCase(unittest.TestCase): def test_task_relation_blueprint_CASCADE_behavior_on_output_deleted(self): - output_url = post_data_and_get_url(TaskConnectors_test_data(), '/task_connectors/') - trb_test_data = TaskRelationBlueprint_test_data(output_url=output_url) + output_url = test_data_creator.post_data_and_get_url(test_data_creator.TaskConnectors(), '/task_connectors/') + trb_test_data = test_data_creator.TaskRelationBlueprint(output_url=output_url) # POST new item with dependency url = POST_and_assert_expected_response(self, BASE_URL + '/task_relation_blueprint/', diff --git a/SAS/TMSS/test/tmss_test_data_django_models.py b/SAS/TMSS/test/tmss_test_data_django_models.py new file mode 100644 index 00000000000..56e97911f32 --- /dev/null +++ b/SAS/TMSS/test/tmss_test_data_django_models.py @@ -0,0 +1,297 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2018 ASTRON (Netherlands Institute for Radio Astronomy) +# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This file is part of the LOFAR software suite. +# The LOFAR software suite is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The LOFAR software suite is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. + +''' +By importing this helper module in your unittest module you get a TMSSTestDatabaseInstance +which is automatically destroyed at the end of the unittest session. +''' + +####################################################### +# the methods below can be used to create test data +# naming convention is: <django_model_name>_test_data() +####################################################### + +from lofar.sas.tmss.tmss.tmssapp import models + +from datetime import datetime +import uuid + +def GeneratorTemplate_test_data(name="my_GeneratorTemplate"): + return {"name": name, + "description": 'My one observation', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "create_function": 'Funky', + "tags": ["TMSS", "TESTING"]} + +def DefaultGeneratorTemplate_test_data(name=None, template=None): + return {'name': name if name is not None else "DefaultGeneratorTemplate_"+str(uuid.uuid4()), + 'template': template, + 'tags':[]} + +def SchedulingUnitTemplate_test_data(): + return {"name": "My SchedulingUnitTemplate", + "description": 'My SchedulingUnitTemplate description', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + +def TaskTemplate_test_data(): + return {"validation_code_js":"", + "name": "my TaskTemplate", + "description": 'My TaskTemplate description', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + +def WorkRelationSelectionTemplate_test_data(): + return {"name": "my WorkRelationSelectionTemplate", + "description": 'My WorkRelationSelectionTemplate description', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + +def TaskConnectors_test_data(): + return {"role": models.Role.objects.get(value='calibrator'), + "datatype": models.Datatype.objects.get(value='instrument model'), + "output_of": models.TaskTemplate.objects.create(**TaskTemplate_test_data()), + "input_of": models.TaskTemplate.objects.create(**TaskTemplate_test_data()), + "tags": []} + +def Cycle_test_data(): + return {"name": 'my_cycle' + str(uuid.uuid4()), + "description": "", + "tags": [], + "start": datetime.utcnow().isoformat(), + "stop": datetime.utcnow().isoformat(), + "number": 1, + "standard_hours": 2, + "expert_hours": 3, + "filler_hours": 4} + +def Project_test_data(): + return { "cycle": models.Cycle.objects.create(**Cycle_test_data()), + "name": 'my_project_' + str(uuid.uuid4()), + "description": 'my description ' + str(uuid.uuid4()), + "tags": [], + "priority": 1, + "can_trigger": False, + "private_data": True, + "expert": True, + "filler": False} + +def SchedulingSet_test_data(): + return {"name": 'my_scheduling_set', + "description": "", + "tags": [], + "generator_doc": "{}", + "project": models.Project.objects.create(**Project_test_data()), + "generator_template": models.GeneratorTemplate.objects.create(**GeneratorTemplate_test_data()), + "generator_source": None} + +def SchedulingUnitDraft_test_data(): + return {"name": 'my_scheduling_unit_draft', + "description": "", + "tags": [], + "requirements_doc": "{}", + "copy_reason": models.CopyReason.objects.get(value='template'), + "generator_instance_doc": "para", + "copies": None, + "scheduling_set": models.SchedulingSet.objects.create(**SchedulingSet_test_data()), + "requirements_template": models.SchedulingUnitTemplate.objects.create(**SchedulingUnitTemplate_test_data())} + +def TaskDraft_test_data(): + return {"name": 'my_task_draft', + "description": "", + "tags": [], + "specifications_doc": "{}", + "copy_reason": models.CopyReason.objects.get(value='template'), + "copies": None, + "scheduling_unit_draft": models.SchedulingUnitDraft.objects.create(**SchedulingUnitDraft_test_data()), + "specifications_template": models.TaskTemplate.objects.create(**TaskTemplate_test_data())} + +def TaskRelationDraft_test_data(): + return {"tags": [], + "selection_doc": "{}", + "dataformat": models.Dataformat.objects.get(value='Beamformed'), + "producer": models.TaskDraft.objects.create(**TaskDraft_test_data()), + "consumer": models.TaskDraft.objects.create(**TaskDraft_test_data()), + "input": models.TaskConnectors.objects.create(**TaskConnectors_test_data()), + "output": models.TaskConnectors.objects.create(**TaskConnectors_test_data()), + "selection_template": models.WorkRelationSelectionTemplate.objects.create(**WorkRelationSelectionTemplate_test_data())} + +def SchedulingUnitBlueprint_test_data(): + return {"name": 'my_scheduling_unit_blueprint', + "description": "", + "tags": [], + "requirements_doc": "{}", + "do_cancel": False, + "draft": models.SchedulingUnitDraft.objects.create(**SchedulingUnitDraft_test_data()), + "requirements_template": models.SchedulingUnitTemplate.objects.create(**SchedulingUnitTemplate_test_data())} + +def TaskBlueprint_test_data(): + return {"name": 'my_task_blueprint', + "description": "", + "tags": [], + "specifications_doc": "{}", + "do_cancel": False, + "draft": models.TaskDraft.objects.create(**TaskDraft_test_data()), + "specifications_template": models.TaskTemplate.objects.create(**TaskTemplate_test_data()), + "scheduling_unit_blueprint": models.SchedulingUnitBlueprint.objects.create(**SchedulingUnitBlueprint_test_data())} + +def TaskRelationBlueprint_test_data(): + return { "tags": [], + "selection_doc": "{}", + "dataformat": models.Dataformat.objects.get(value='Beamformed'), + "input": models.TaskConnectors.objects.create(**TaskConnectors_test_data()), + "output": models.TaskConnectors.objects.create(**TaskConnectors_test_data()), + "draft": models.TaskRelationDraft.objects.create(**TaskRelationDraft_test_data()), + "selection_template": models.WorkRelationSelectionTemplate.objects.create(**WorkRelationSelectionTemplate_test_data()), + "producer": models.TaskBlueprint.objects.create(**TaskBlueprint_test_data()), + "consumer": models.TaskBlueprint.objects.create(**TaskBlueprint_test_data())} + + +def SubtaskTemplate_test_data(): + return {"type": models.SubtaskType.objects.get(value='copy'), + "name": "observation", + "description": 'My one observation', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "realtime": True, + "queue": False, + "tags": ["TMSS", "TESTING"]} + +def DataproductSpecificationsTemplate_test_data(): + return {"name": "data", + "description": 'My one date', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + +def DataproductFeedbackTemplate_test_data(): + return {"name": "data", + "description": 'My one date', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + +def SubtaskOutput_test_data(): + return {"subtask": models.Subtask.objects.create(**Subtask_test_data()), + "connector": models.SubtaskConnector.objects.create(**SubtaskConnector_test_data()), + "tags":[]} + +def SubtaskInput_test_data(): + # test data + return {"subtask": models.Subtask.objects.create(**Subtask_test_data()), + "task_relation_blueprint": models.TaskRelationBlueprint.objects.create(**TaskRelationBlueprint_test_data()), + "connector": models.SubtaskConnector.objects.create(**SubtaskConnector_test_data()), + "producer": models.SubtaskOutput.objects.create(**SubtaskOutput_test_data()), + #"dataproducts": models.Dataproduct.objects.create(**dpt.get_test_data()), + "selection_doc": "{}", + "selection_template": models.SubtaskInputSelectionTemplate.objects.create(**SubtaskInputSelectionTemplate_test_data()), + "tags":[]} + +def Subtask_test_data(subtask_template: models.SubtaskTemplate=None, specifications_doc: str=None): + if subtask_template is None: + subtask_template = models.SubtaskTemplate.objects.create(**SubtaskTemplate_test_data()) + + if specifications_doc is None: + specifications_doc = "{}" # simplest json object + + return { "start_time": datetime.utcnow().isoformat(), + "stop_time": datetime.utcnow().isoformat(), + "state": models.SubtaskState.objects.get(value='scheduling'), + "specifications_doc": specifications_doc, + "task_blueprint": models.TaskBlueprint.objects.create(**TaskBlueprint_test_data()), + "specifications_template": subtask_template, + "tags": ["TMSS", "TESTING"], + "do_cancel": datetime.utcnow().isoformat(), + "priority": 1, + "schedule_method": models.ScheduleMethod.objects.get(value='manual'), + "cluster": models.Cluster.objects.create(location="downstairs", tags=[]), + "scheduler_input_doc": "{}"} + +def Dataproduct_test_data(): + return {"filename": "my.file", + "directory": "/home/boskabouter/", + "dataformat": models.Dataformat.objects.get(value='Beamformed'), + "deleted_since": datetime.utcnow().isoformat(), + "pinned_since": datetime.utcnow().isoformat(), + "specifications_doc": "{}", + "specifications_template": models.DataproductSpecificationsTemplate.objects.create(**DataproductSpecificationsTemplate_test_data()), + "tags": ["TMSS", "TESTING"], + "producer": models.SubtaskOutput.objects.create(**SubtaskOutput_test_data()), + "do_cancel": datetime.utcnow().isoformat(), + "expected_size": 1234, + "size": 123, + "feedback_doc": "{}", + "feedback_template": models.DataproductFeedbackTemplate.objects.create(**DataproductFeedbackTemplate_test_data())} + +def SubtaskConnector_test_data(): + return {"role": models.Role.objects.get(value='calibrator'), + "datatype": models.Datatype.objects.get(value='instrument model'), + # "dataformats": [models.Dataformat.objects.get(value='Beamformed')], # -> use set() + "output_of": models.SubtaskTemplate.objects.create(**SubtaskTemplate_test_data()), + "input_of": models.SubtaskTemplate.objects.create(**SubtaskTemplate_test_data()), + "tags": []} + +def AntennaSet_test_data(): + return {"name": "observation", + "description": 'My one observation', + "station_type": models.StationType.objects.get(value='core'), + "rcus": [1,2,3,4,5], + "inputs": ['input1', 'input2'], + "tags": ['tmss', 'testing']} + + +def DataproductTransform_test_data(): + return {"input": models.Dataproduct.objects.create(**Dataproduct_test_data()), + "output": models.Dataproduct.objects.create(**Dataproduct_test_data()), + "identity": True, + "tags": ['tmss', 'testing']} + +def Filesystem_test_data(): + return {"capacity": 1111111111, + "cluster": models.Cluster.objects.create(**Cluster_test_data()), + "tags": ['tmss', 'testing']} + +def Cluster_test_data(): + return {"location": "upstairs", + "tags": ['tmss', 'testing']} + +def DataproductArchiveInfo_test_data(): + return {"dataproduct": models.Dataproduct.objects.create(**Dataproduct_test_data()), + "storage_ticket": "myticket_1", + "public_since": datetime.utcnow().isoformat(), + "corrupted_since": datetime.utcnow().isoformat(), + "tags": ['tmss', 'testing']} + +def DataproductHash_test_data(): + return {"dataproduct": models.Dataproduct.objects.create(**Dataproduct_test_data()), + "algorithm": models.Algorithm.objects.get(value='md5'), + "hash": "myhash_1", + "tags": ['tmss', 'testing']} + +def SubtaskInputSelectionTemplate_test_data(): + return {"name": "data", + "description": 'My one date', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + diff --git a/SAS/TMSS/test/tmss_test_data_rest.py b/SAS/TMSS/test/tmss_test_data_rest.py new file mode 100644 index 00000000000..5cd3a613366 --- /dev/null +++ b/SAS/TMSS/test/tmss_test_data_rest.py @@ -0,0 +1,461 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2018 ASTRON (Netherlands Institute for Radio Astronomy) +# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This file is part of the LOFAR software suite. +# The LOFAR software suite is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The LOFAR software suite is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with the LOFAR software suite. If not, see <http://www.gnu.org/licenses/>. + +################################################################################################ +# the methods below can be used to to HTTP REST calls to the django server and check the results +################################################################################################ + +from datetime import datetime +import uuid +import requests +import json + +class TMSSRESTTestDataCreator(): + def __init__(self, django_api_url: str, auth: requests.auth.HTTPBasicAuth): + self.django_api_url = django_api_url + self.auth = auth + + def post_data_and_get_url(self, data, url_postfix): + """POST the given data the self.django_api_url+url_postfix, and return the response's url""" + return json.loads(requests.post(self.django_api_url + url_postfix, json=data, auth=self.auth).content.decode('utf-8'))['url'] + + ####################################################### + # the methods below can be used to create test data + # naming convention is: <django_model_name>() + ####################################################### + + + def GeneratorTemplate(self, name="generatortemplate"): + return {"name": name, + "description": 'My one observation', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "create_function": 'Funky', + "tags": ["TMSS", "TESTING"]} + + def SchedulingUnitTemplate(self, name="schedulingunittemplate1"): + return { "name": name, + "description": 'My description', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + + def TaskTemplate(self, name="tasktemplate1"): + return {"name": name, + "description": 'My one observation', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"], + "validation_code_js": "???"} + + def WorkRelationSelectionTemplate(self, name="workrelationselectiontemplate1"): + return {"name": name, + "description": 'My one observation', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + + def TaskConnectors(self, role="correlator", input_of_url=None, output_of_url=None): + if input_of_url is None: + input_of_url = self.post_data_and_get_url(self.TaskTemplate(), '/task_template/') + + if output_of_url is None: + output_of_url = self.post_data_and_get_url(self.TaskTemplate(), '/task_template/') + + return {"role": self.django_api_url + '/role/%s/'%role, + "datatype": self.django_api_url + '/datatype/image/', + "dataformats": [self.django_api_url + '/dataformat/Beamformed/'], + "output_of": output_of_url, + "input_of": input_of_url, + "tags": []} + + def DefaultTemplates(self, name="defaulttemplate"): + return {"name": name, + "template": None, + "tags": []} + + def Cycle(self, description="my cycle description"): + return {"name": 'my_cycle_' + str(uuid.uuid4()), + "description": description, + "tags": [], + "start": datetime.utcnow().isoformat(), + "stop": datetime.utcnow().isoformat(), + "number": 1, + "standard_hours": 2, + "expert_hours": 3, + "filler_hours": 4, + "projects": []} + + def Project(self, description="my project description"): + return {"name": 'my_project_' + str(uuid.uuid4()), + "description": description, + "tags": [], + "priority": 1, + "can_trigger": False, + "private_data": True} + + def SchedulingSet(self, name="my_scheduling_set", project_url=None, generator_template_url=None): + if project_url is None: + project_url = self.post_data_and_get_url(self.Project(), '/project/') + + if generator_template_url is None: + generator_template_url = self.post_data_and_get_url(self.GeneratorTemplate(), '/generator_template/') + + return {"name": name, + "description": "This is my scheduling set", + "tags": [], + "generator_doc": "{}", + "project": project_url, + "generator_template": generator_template_url, + "generator_source": None, + "scheduling_unit_drafts": []} + + def SchedulingUnitDraft(self, name="my_scheduling_unit_draft", scheduling_set_url=None, template_url=None): + if scheduling_set_url is None: + scheduling_set_url = self.post_data_and_get_url(self.SchedulingSet(), '/scheduling_set/') + + if template_url is None: + template_url = self.post_data_and_get_url(self.SchedulingUnitTemplate(), '/scheduling_unit_template/') + + return {"name": name, + "description": "This is my run draft", + "tags": [], + "requirements_doc": "{}", + "copy_reason": self.django_api_url + '/copy_reason/template/', + "generator_instance_doc": "{}", + "copies": None, + "scheduling_set": scheduling_set_url, + "requirements_template": template_url, + "related_scheduling_unit_blueprint": [], + "task_drafts": []} + + def TaskDraft(self, name='my_task_draft', scheduling_unit_draft_url=None, template_url=None): + if scheduling_unit_draft_url is None: + scheduling_unit_draft_url = self.post_data_and_get_url(self.SchedulingUnitDraft(), '/scheduling_unit_draft/') + + if template_url is None: + template_url = self.post_data_and_get_url(self.TaskTemplate(), '/task_template/') + + return {"name": name, + "description": "This is my task draft", + "tags": [], + "specifications_doc": "{}", + "copy_reason": self.django_api_url + '/copy_reason/template/', + "copies": None, + "scheduling_unit_draft": scheduling_unit_draft_url, + "specifications_template": template_url, + 'related_task_blueprint': [], + 'produced_by': [], + 'consumed_by': []} + + + def TaskRelationDraft(self, name="myTaskRelationDraft", producer_url=None, consumer_url=None, template_url=None, input_url=None, output_url=None): + if producer_url is None: + producer_url = self.post_data_and_get_url(self.TaskDraft(), '/task_draft/') + + if consumer_url is None: + consumer_url = self.post_data_and_get_url(self.TaskDraft(),'/task_draft/') + + if template_url is None: + template_url = self.post_data_and_get_url(self.WorkRelationSelectionTemplate(), '/work_relation_selection_template/') + + if input_url is None: + input_url = self.post_data_and_get_url(self.TaskConnectors(), '/task_connectors/') + + if output_url is None: + output_url = self.post_data_and_get_url(self.TaskConnectors(), '/task_connectors/') + + return {"tags": [], + "selection_doc": "{}", + "dataformat": self.django_api_url + "/dataformat/Beamformed/", + "producer": producer_url, + "consumer": consumer_url, + "input": input_url, + "output": output_url, + "selection_template": template_url, + 'related_task_relation_blueprint': []} + + def SchedulingUnitBlueprint(self, name="my_scheduling_unit_blueprint", scheduling_unit_draft_url=None, template_url=None): + if scheduling_unit_draft_url is None: + scheduling_unit_draft_url = self.post_data_and_get_url(self.SchedulingUnitDraft(), '/scheduling_unit_draft/') + + if template_url is None: + template_url = self.post_data_and_get_url(self.SchedulingUnitTemplate(), '/scheduling_unit_template/') + + return {"name": name, + "description": "This is my run blueprint", + "tags": [], + "requirements_doc": "{}", + "do_cancel": False, + "draft": scheduling_unit_draft_url, + "requirements_template": template_url} + + def TaskBlueprint(self, name="my_TaskBlueprint", draft_url=None, template_url=None, scheduling_unit_blueprint_url=None): + if draft_url is None: + draft_url = self.post_data_and_get_url(self.TaskDraft(), '/task_draft/') + + if template_url is None: + template_url = self.post_data_and_get_url(self.TaskTemplate(), '/task_template/') + + if scheduling_unit_blueprint_url is None: + scheduling_unit_blueprint_url = self.post_data_and_get_url(self.SchedulingUnitBlueprint(), '/scheduling_unit_blueprint/') + + return {"name": name, + "description": "This is my work request blueprint", + "tags": [], + "specifications_doc": "{}", + "do_cancel": False, + "draft": draft_url, + "specifications_template": template_url, + "scheduling_unit_blueprint": scheduling_unit_blueprint_url, + "subtasks": [], + "produced_by": [], + "consumed_by": []} + + def TaskRelationBlueprint(self, draft_url=None, template_url=None, input_url=None, output_url=None, consumer_url=None, producer_url=None): + if draft_url is None: + draft_url = self.post_data_and_get_url(self.TaskRelationDraft(), '/task_relation_draft/') + + if producer_url is None: + producer_url = self.post_data_and_get_url(self.TaskBlueprint(), '/task_blueprint/') + + if consumer_url is None: + consumer_url = self.post_data_and_get_url(self.TaskBlueprint(),'/task_blueprint/') + + if template_url is None: + template_url = self.post_data_and_get_url(self.WorkRelationSelectionTemplate(), '/work_relation_selection_template/') + + if input_url is None: + input_url = self.post_data_and_get_url(self.TaskConnectors(), '/task_connectors/') + + if output_url is None: + output_url = self.post_data_and_get_url(self.TaskConnectors(), '/task_connectors/') + + # test data + return {"tags": [], + "selection_doc": "{}", + "dataformat": self.django_api_url + '/dataformat/MeasurementSet/', + "input": input_url, + "output": output_url, + "draft": draft_url, + "selection_template": template_url, + "producer": producer_url, + "consumer": consumer_url} + + def SubtaskTemplate(self, name="subtask1"): + return {"type": self.django_api_url + '/subtask_type/copy/', + "name": name, + "description": 'My one observation', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "realtime": True, + "queue": False, + "tags": ["TMSS", "TESTING"]} + + def DataproductSpecificationsTemplate(self, name="my_DataproductSpecificationsTemplate"): + return {"name": name, + "description": 'My one date', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + + def DataproductFeedbackTemplate(self, name="my_DataproductFeedbackTemplate"): + return {"name": name, + "description": 'My one date', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + + def DefaultSubtaskTemplates(self, name=None, template_url=None): + if template_url is None: + template_url = self.post_data_and_get_url(self.SubtaskTemplate(), '/subtask_template/') + + return {"name": name if name else "default_template_%s" % uuid.uuid4(), + "template": template_url, + "tags": []} + + def Cluster(self, name=None): + return {"name": name if name else "Cluster %s" % uuid.uuid4(), + "description": 'My one cluster', + "location": "upstairs", + "tags": ['tmss', 'testing']} + + def Subtask(self, cluster_url=None, task_blueprint_url=None, specifications_template_url=None): + if cluster_url is None: + cluster_url = self.post_data_and_get_url(self.Cluster(), '/cluster/') + + if task_blueprint_url is None: + task_blueprint_url = self.post_data_and_get_url(self.TaskBlueprint(), '/task_blueprint/') + + if specifications_template_url is None: + specifications_template_url = self.post_data_and_get_url(self.SubtaskTemplate(), '/subtask_template/') + + return {"start_time": datetime.utcnow().isoformat(), + "stop_time": datetime.utcnow().isoformat(), + "state": self.django_api_url + '/subtask_state/scheduling/', + "specifications_doc": "{}", + "task_blueprint": task_blueprint_url, + "specifications_template": specifications_template_url, + "tags": ["TMSS", "TESTING"], + "do_cancel": datetime.utcnow().isoformat(), + "priority": 1, + "schedule_method": self.django_api_url + '/schedule_method/manual/', + "cluster": cluster_url, + "scheduler_input_doc": "{}" } + + def SubtaskOutput(self, subtask_url=None, subtask_connector_url=None): + if subtask_url is None: + subtask_url = self.post_data_and_get_url(self.Subtask(), '/subtask/') + + if subtask_connector_url is None: + subtask_connector_url = self.post_data_and_get_url(self.SubtaskConnector(), '/subtask_connector/') + + return {"subtask": subtask_url, + "connector": subtask_connector_url, + "tags": []} + + def SubtaskConnector(self, input_of_url=None, output_of_url=None): + if input_of_url is None: + input_of_url = self.post_data_and_get_url(self.SubtaskTemplate(), '/subtask_template/') + + if output_of_url is None: + output_of_url = self.post_data_and_get_url(self.SubtaskTemplate(), '/subtask_template/') + + return {"role": self.django_api_url + '/role/correlator/', + "datatype": self.django_api_url + '/datatype/image/', + "dataformats": [self.django_api_url + '/dataformat/Beamformed/'], + "output_of": output_of_url, + "input_of": input_of_url, + "tags": []} + + def Dataproduct(self, filename="my_filename", specifications_template_url=None, subtask_output_url=None, dataproduct_feedback_template_url=None): + if specifications_template_url is None: + specifications_template_url = self.post_data_and_get_url(self.SubtaskTemplate(), '/dataproduct_specifications_template/') + + if subtask_output_url is None: + subtask_output_url = self.post_data_and_get_url(self.SubtaskOutput(), '/subtask_output/') + + if dataproduct_feedback_template_url is None: + dataproduct_feedback_template_url = self.post_data_and_get_url(self.DataproductFeedbackTemplate(), '/dataproduct_feedback_template/') + + return {"filename": "my.file", + "directory": "/home/boskabouter/", + "dataformat": self.django_api_url + '/dataformat/Beamformed/', + "deleted_since": None, + "pinned_since": None, + "specifications_doc": "{}", + "specifications_template": specifications_template_url, + "tags": ["TMSS", "TESTING"], + "producer": subtask_output_url, + "do_cancel": datetime.utcnow().isoformat(), + "expected_size": 1234, + "size": 123, + "feedback_doc": "{}", + "feedback_template": dataproduct_feedback_template_url + } + + def AntennaSet(self, name="antennaset1"): + return {"name": name, + "description": 'My one observation', + "station_type": self.django_api_url + '/station_type/core/', + "rcus": [1,2,3,4,5], + "inputs": ['input1', 'input2'], + "tags": ['tmss', 'testing']} + + def DataproductTransform(self, input_dataproduct_url=None, output_dataproduct_url=None): + if input_dataproduct_url is None: + input_dataproduct_url = self.post_data_and_get_url(self.Dataproduct(), '/dataproduct/') + + if output_dataproduct_url is None: + output_dataproduct_url = self.post_data_and_get_url(self.Dataproduct(), '/dataproduct/') + + return {"input": input_dataproduct_url, + "output": output_dataproduct_url, + "identity": True, + "tags": ['tmss', 'testing']} + + def DataproductHash(self, algorithm_url=None, hash="my_hash", dataproduct_url=None): + if algorithm_url is None: + algorithm_url = self.django_api_url + '/algorithm/md5/' + + if dataproduct_url is None: + dataproduct_url = self.post_data_and_get_url(self.Dataproduct(), '/dataproduct/') + + return {"dataproduct": dataproduct_url, + "algorithm": algorithm_url, + "hash": hash, + "tags": ['tmss', 'testing']} + + + def DataproductArchiveInfo(self, storage_ticket="my_storage_ticket", dataproduct_url=None): + if dataproduct_url is None: + dataproduct_url = self.post_data_and_get_url(self.Dataproduct(), '/dataproduct/') + + return {"dataproduct": dataproduct_url, + "storage_ticket": storage_ticket, + "public_since": datetime.utcnow().isoformat(), + "corrupted_since": datetime.utcnow().isoformat(), + "tags": ['tmss', 'testing']} + + def SubtaskInputSelectionTemplate(self, name="my_SubtaskInputSelectionTemplate"): + return {"name": name, + "description": 'My one date', + "version": 'v0.314159265359', + "schema": {"mykey": "my value"}, + "tags": ["TMSS", "TESTING"]} + + def SubtaskInput(self, subtask_url=None, task_relation_blueprint_url=None, dataproduct_urls=None, subtask_connector_url=None, subtask_output_url=None, subtask_input_selection_template_url=None): + if subtask_url is None: + subtask_url = self.post_data_and_get_url(self.Subtask(), '/subtask/') + + if task_relation_blueprint_url is None: + task_relation_blueprint_url = self.post_data_and_get_url(self.TaskRelationBlueprint(), '/task_relation_blueprint/') + + if dataproduct_urls is None: + dataproduct_urls = [self.post_data_and_get_url(self.Dataproduct(), '/dataproduct/'), + self.post_data_and_get_url(self.Dataproduct(), '/dataproduct/')] + + if subtask_connector_url is None: + subtask_connector_url = self.post_data_and_get_url(self.SubtaskConnector(), '/subtask_connector/') + + if subtask_output_url is None: + subtask_output_url = self.post_data_and_get_url(self.SubtaskOutput(), '/subtask_output/') + + if subtask_input_selection_template_url is None: + subtask_input_selection_template_url = self.post_data_and_get_url(self.SubtaskInputSelectionTemplate(), '/subtask_input_selection_template/') + + return {"subtask": subtask_url, + "task_relation_blueprint": task_relation_blueprint_url, + "connector": subtask_connector_url, + "producer": subtask_output_url, + "dataproducts": dataproduct_urls, + "selection_doc": "{}", + "selection_template": subtask_input_selection_template_url, + "tags": []} + + def Filesystem(self, name="my_Filesystem", cluster_url=None): + if cluster_url is None: + cluster_url = self.post_data_and_get_url(self.Cluster(), '/cluster/') + + return {"name": name, + "description": 'My one filesystem', + "capacity": 1111111111, + "cluster": cluster_url, + "tags": ['tmss', 'testing']} + diff --git a/SAS/TMSS/test/tmss_test_environment_unittest_setup.py b/SAS/TMSS/test/tmss_test_environment_unittest_setup.py index c8dc5e904cc..dc5e1c5316a 100644 --- a/SAS/TMSS/test/tmss_test_environment_unittest_setup.py +++ b/SAS/TMSS/test/tmss_test_environment_unittest_setup.py @@ -39,16 +39,10 @@ def tearDownModule(): # the methods below can be used to to HTTP REST calls to the django server and check the results ################################################################################################ -from requests.auth import HTTPBasicAuth -AUTH = HTTPBasicAuth(tmss_test_env.ldap_server.dbcreds.user, tmss_test_env.ldap_server.dbcreds.password) -BASE_URL = tmss_test_env.django_server.url - -import requests import json - -def post_data_and_get_url(data, url_postfix): - """POST the given data the BASE_URL+url_postfix, and return the response's url""" - return json.loads(requests.post(BASE_URL + url_postfix, json=data, auth=AUTH).content.decode('utf-8'))['url'] +import requests +AUTH = requests.auth.HTTPBasicAuth(tmss_test_env.ldap_server.dbcreds.user, tmss_test_env.ldap_server.dbcreds.password) +BASE_URL = tmss_test_env.django_server.url def _call_API_and_assert_expected_response(test_instance, url, call, data, expected_code, expected_content): """ @@ -130,432 +124,3 @@ def DELETE_and_assert_gone(test_instance, url): if response.status_code != 404: print("!!! Unexpected: [%s] - %s %s: %s" % (test_instance.id(), 'GET', url, response.content)) test_instance.assertEqual(response.status_code, 404) - - - -####################################################### -# the methods below can be used to create test data -# naming convention is: <django_model_name>_test_data() -####################################################### - -from datetime import datetime -import uuid - -def GeneratorTemplate_test_data(name="generatortemplate"): - return {"name": name, - "description": 'My one observation', - "version": 'v0.314159265359', - "schema": {"mykey": "my value"}, - "create_function": 'Funky', - "tags": ["TMSS", "TESTING"]} - -def SchedulingUnitTemplate_test_data(name="schedulingunittemplate1"): - return { "name": name, - "description": 'My description', - "version": 'v0.314159265359', - "schema": {"mykey": "my value"}, - "tags": ["TMSS", "TESTING"]} - -def TaskTemplate_test_data(name="tasktemplate1"): - return {"name": name, - "description": 'My one observation', - "version": 'v0.314159265359', - "schema": {"mykey": "my value"}, - "tags": ["TMSS", "TESTING"], - "validation_code_js": "???"} - -def WorkRelationSelectionTemplate_test_data(name="workrelationselectiontemplate1"): - return {"name": name, - "description": 'My one observation', - "version": 'v0.314159265359', - "schema": {"mykey": "my value"}, - "tags": ["TMSS", "TESTING"]} - -def TaskConnectors_test_data(role="correlator", input_of_url=None, output_of_url=None): - if input_of_url is None: - input_of_url = post_data_and_get_url(TaskTemplate_test_data(), '/task_template/') - - if output_of_url is None: - output_of_url = post_data_and_get_url(TaskTemplate_test_data(), '/task_template/') - - return {"role": BASE_URL + '/role/%s/'%role, - "datatype": BASE_URL + '/datatype/image/', - "dataformats": [BASE_URL + '/dataformat/Beamformed/'], - "output_of": output_of_url, - "input_of": input_of_url, - "tags": []} - -def DefaultTemplates_test_data(name="defaulttemplate"): - return {"name": name, - "template": None, - "tags": []} - -def Cycle_test_data(description="my cycle description"): - return {"name": 'my_cycle_' + str(uuid.uuid4()), - "description": description, - "tags": [], - "start": datetime.utcnow().isoformat(), - "stop": datetime.utcnow().isoformat(), - "number": 1, - "standard_hours": 2, - "expert_hours": 3, - "filler_hours": 4, - "projects": []} - -def Project_test_data(description="my project description"): - return {"name": 'my_project_' + str(uuid.uuid4()), - "description": description, - "tags": [], - "priority": 1, - "can_trigger": False, - "private_data": True} - -def SchedulingSet_test_data(name="my_scheduling_set", project_url=None, generator_template_url=None): - if project_url is None: - project_url = post_data_and_get_url(Project_test_data(), '/project/') - - if generator_template_url is None: - generator_template_url = post_data_and_get_url(GeneratorTemplate_test_data(), '/generator_template/') - - return {"name": name, - "description": "This is my scheduling set", - "tags": [], - "generator_doc": "{}", - "project": project_url, - "generator_template": generator_template_url, - "generator_source": None, - "scheduling_unit_drafts": []} - -def SchedulingUnitDraft_test_data(name="my_scheduling_unit_draft", scheduling_set_url=None, template_url=None): - if scheduling_set_url is None: - scheduling_set_url = post_data_and_get_url(SchedulingSet_test_data(), '/scheduling_set/') - - if template_url is None: - template_url = post_data_and_get_url(SchedulingUnitTemplate_test_data(), '/scheduling_unit_template/') - - return {"name": name, - "description": "This is my run draft", - "tags": [], - "requirements_doc": "{}", - "copy_reason": BASE_URL + '/copy_reason/template/', - "generator_instance_doc": "{}", - "copies": None, - "scheduling_set": scheduling_set_url, - "requirements_template": template_url, - "related_scheduling_unit_blueprint": [], - "task_drafts": []} - -def TaskDraft_test_data(name='my_task_draft', scheduling_unit_draft_url=None, template_url=None): - if scheduling_unit_draft_url is None: - scheduling_unit_draft_url = post_data_and_get_url(SchedulingUnitDraft_test_data(), '/scheduling_unit_draft/') - - if template_url is None: - template_url = post_data_and_get_url(TaskTemplate_test_data(), '/task_template/') - - return {"name": name, - "description": "This is my task draft", - "tags": [], - "specifications_doc": "{}", - "copy_reason": BASE_URL + '/copy_reason/template/', - "copies": None, - "scheduling_unit_draft": scheduling_unit_draft_url, - "specifications_template": template_url, - 'related_task_blueprint': [], - 'produced_by': [], - 'consumed_by': []} - - -def TaskRelationDraft_test_data(name="myTaskRelationDraft", producer_url=None, consumer_url=None, template_url=None, input_url=None, output_url=None): - if producer_url is None: - producer_url = post_data_and_get_url(TaskDraft_test_data(), '/task_draft/') - - if consumer_url is None: - consumer_url = post_data_and_get_url(TaskDraft_test_data(),'/task_draft/') - - if template_url is None: - template_url = post_data_and_get_url(WorkRelationSelectionTemplate_test_data(), '/work_relation_selection_template/') - - if input_url is None: - input_url = post_data_and_get_url(TaskConnectors_test_data(), '/task_connectors/') - - if output_url is None: - output_url = post_data_and_get_url(TaskConnectors_test_data(), '/task_connectors/') - - return {"tags": [], - "selection_doc": "{}", - "dataformat": BASE_URL + "/dataformat/Beamformed/", - "producer": producer_url, - "consumer": consumer_url, - "input": input_url, - "output": output_url, - "selection_template": template_url, - 'related_task_relation_blueprint': []} - -def SchedulingUnitBlueprint_test_data(name="my_scheduling_unit_blueprint", scheduling_unit_draft_url=None, template_url=None): - if scheduling_unit_draft_url is None: - scheduling_unit_draft_url = post_data_and_get_url(SchedulingUnitDraft_test_data(), '/scheduling_unit_draft/') - - if template_url is None: - template_url = post_data_and_get_url(SchedulingUnitTemplate_test_data(), '/scheduling_unit_template/') - - return {"name": name, - "description": "This is my run blueprint", - "tags": [], - "requirements_doc": "{}", - "do_cancel": False, - "draft": scheduling_unit_draft_url, - "requirements_template": template_url} - -def TaskBlueprint_test_data(name="my_TaskBlueprint", draft_url=None, template_url=None, scheduling_unit_blueprint_url=None): - if draft_url is None: - draft_url = post_data_and_get_url(TaskDraft_test_data(), '/task_draft/') - - if template_url is None: - template_url = post_data_and_get_url(TaskTemplate_test_data(), '/task_template/') - - if scheduling_unit_blueprint_url is None: - scheduling_unit_blueprint_url = post_data_and_get_url(SchedulingUnitBlueprint_test_data(), '/scheduling_unit_blueprint/') - - return {"name": name, - "description": "This is my work request blueprint", - "tags": [], - "specifications_doc": "{}", - "do_cancel": False, - "draft": draft_url, - "specifications_template": template_url, - "scheduling_unit_blueprint": scheduling_unit_blueprint_url, - "subtasks": [], - "produced_by": [], - "consumed_by": []} - -def TaskRelationBlueprint_test_data(draft_url=None, template_url=None, input_url=None, output_url=None, consumer_url=None, producer_url=None): - if draft_url is None: - draft_url = post_data_and_get_url(TaskRelationDraft_test_data(), '/task_relation_draft/') - - if producer_url is None: - producer_url = post_data_and_get_url(TaskBlueprint_test_data(), '/task_blueprint/') - - if consumer_url is None: - consumer_url = post_data_and_get_url(TaskBlueprint_test_data(),'/task_blueprint/') - - if template_url is None: - template_url = post_data_and_get_url(WorkRelationSelectionTemplate_test_data(), '/work_relation_selection_template/') - - if input_url is None: - input_url = post_data_and_get_url(TaskConnectors_test_data(), '/task_connectors/') - - if output_url is None: - output_url = post_data_and_get_url(TaskConnectors_test_data(), '/task_connectors/') - - # test data - return {"tags": [], - "selection_doc": "{}", - "dataformat": BASE_URL + '/dataformat/MeasurementSet/', - "input": input_url, - "output": output_url, - "draft": draft_url, - "selection_template": template_url, - "producer": producer_url, - "consumer": consumer_url} - -def SubtaskTemplate_test_data(name="subtask1"): - return {"type": BASE_URL + '/subtask_type/copy/', - "name": name, - "description": 'My one observation', - "version": 'v0.314159265359', - "schema": {"mykey": "my value"}, - "realtime": True, - "queue": False, - "tags": ["TMSS", "TESTING"]} - -def DataproductSpecificationsTemplate_test_data(name="my_DataproductSpecificationsTemplate"): - return {"name": name, - "description": 'My one date', - "version": 'v0.314159265359', - "schema": {"mykey": "my value"}, - "tags": ["TMSS", "TESTING"]} - -def DataproductFeedbackTemplate_test_data(name="my_DataproductFeedbackTemplate"): - return {"name": name, - "description": 'My one date', - "version": 'v0.314159265359', - "schema": {"mykey": "my value"}, - "tags": ["TMSS", "TESTING"]} - -def DefaultSubtaskTemplates_test_data(name=None, template_url=None): - if template_url is None: - template_url = post_data_and_get_url(SubtaskTemplate_test_data(), '/subtask_template/') - - return {"name": name if name else "default_template_%s" % uuid.uuid4(), - "template": template_url, - "tags": []} - -def Cluster_test_data(name=None): - return {"name": name if name else "Cluster %s" % uuid.uuid4(), - "description": 'My one cluster', - "location": "upstairs", - "tags": ['tmss', 'testing']} - -def Subtask_test_data(cluster_url=None, task_blueprint_url=None, specifications_template_url=None): - if cluster_url is None: - cluster_url = post_data_and_get_url(Cluster_test_data(), '/cluster/') - - if task_blueprint_url is None: - task_blueprint_url = post_data_and_get_url(TaskBlueprint_test_data(), '/task_blueprint/') - - if specifications_template_url is None: - specifications_template_url = post_data_and_get_url(SubtaskTemplate_test_data(), '/subtask_template/') - - return {"start_time": datetime.utcnow().isoformat(), - "stop_time": datetime.utcnow().isoformat(), - "state": BASE_URL + '/subtask_state/scheduling/', - "specifications_doc": "{}", - "task_blueprint": task_blueprint_url, - "specifications_template": specifications_template_url, - "tags": ["TMSS", "TESTING"], - "do_cancel": datetime.utcnow().isoformat(), - "priority": 1, - "schedule_method": BASE_URL + '/schedule_method/manual/', - "cluster": cluster_url, - "scheduler_input_doc": "{}" } - -def SubtaskOutput_test_data(subtask_url=None, subtask_connector_url=None): - if subtask_url is None: - subtask_url = post_data_and_get_url(Subtask_test_data(), '/subtask/') - - if subtask_connector_url is None: - subtask_connector_url = post_data_and_get_url(SubtaskConnector_test_data(), '/subtask_connector/') - - return {"subtask": subtask_url, - "connector": subtask_connector_url, - "tags": []} - -def SubtaskConnector_test_data(input_of_url=None, output_of_url=None): - if input_of_url is None: - input_of_url = post_data_and_get_url(SubtaskTemplate_test_data(), '/subtask_template/') - - if output_of_url is None: - output_of_url = post_data_and_get_url(SubtaskTemplate_test_data(), '/subtask_template/') - - return {"role": BASE_URL + '/role/correlator/', - "datatype": BASE_URL + '/datatype/image/', - "dataformats": [BASE_URL + '/dataformat/Beamformed/'], - "output_of": output_of_url, - "input_of": input_of_url, - "tags": []} - -def Dataproduct_test_data(filename="my_filename", specifications_template_url=None, subtask_output_url=None, dataproduct_feedback_template_url=None): - if specifications_template_url is None: - specifications_template_url = post_data_and_get_url(SubtaskTemplate_test_data(), '/dataproduct_specifications_template/') - - if subtask_output_url is None: - subtask_output_url = post_data_and_get_url(SubtaskOutput_test_data(), '/subtask_output/') - - if dataproduct_feedback_template_url is None: - dataproduct_feedback_template_url = post_data_and_get_url(DataproductFeedbackTemplate_test_data(), '/dataproduct_feedback_template/') - - return {"filename": "my.file", - "directory": "/home/boskabouter/", - "dataformat": BASE_URL + '/dataformat/Beamformed/', - "deleted_since": None, - "pinned_since": None, - "specifications_doc": "{}", - "specifications_template": specifications_template_url, - "tags": ["TMSS", "TESTING"], - "producer": subtask_output_url, - "do_cancel": datetime.utcnow().isoformat(), - "expected_size": 1234, - "size": 123, - "feedback_doc": "{}", - "feedback_template": dataproduct_feedback_template_url - } - -def AntennaSet_test_data(name="antennaset1"): - return {"name": name, - "description": 'My one observation', - "station_type": BASE_URL + '/station_type/core/', - "rcus": [1,2,3,4,5], - "inputs": ['input1', 'input2'], - "tags": ['tmss', 'testing']} - -def DataproductTransform_test_data(input_dataproduct_url=None, output_dataproduct_url=None): - if input_dataproduct_url is None: - input_dataproduct_url = post_data_and_get_url(Dataproduct_test_data(), '/dataproduct/') - - if output_dataproduct_url is None: - output_dataproduct_url = post_data_and_get_url(Dataproduct_test_data(), '/dataproduct/') - - return {"input": input_dataproduct_url, - "output": output_dataproduct_url, - "identity": True, - "tags": ['tmss', 'testing']} - -def DataproductHash_test_data(algorithm_url=None, hash="my_hash", dataproduct_url=None): - if algorithm_url is None: - algorithm_url = BASE_URL + '/algorithm/md5/' - - if dataproduct_url is None: - dataproduct_url = post_data_and_get_url(Dataproduct_test_data(), '/dataproduct/') - - return {"dataproduct": dataproduct_url, - "algorithm": algorithm_url, - "hash": hash, - "tags": ['tmss', 'testing']} - - -def DataproductArchiveInfo_test_data(storage_ticket="my_storage_ticket", dataproduct_url=None): - if dataproduct_url is None: - dataproduct_url = post_data_and_get_url(Dataproduct_test_data(), '/dataproduct/') - - return {"dataproduct": dataproduct_url, - "storage_ticket": storage_ticket, - "public_since": datetime.utcnow().isoformat(), - "corrupted_since": datetime.utcnow().isoformat(), - "tags": ['tmss', 'testing']} - -def SubtaskInputSelectionTemplate_test_data(name="my_SubtaskInputSelectionTemplate"): - return {"name": name, - "description": 'My one date', - "version": 'v0.314159265359', - "schema": {"mykey": "my value"}, - "tags": ["TMSS", "TESTING"]} - -def SubtaskInput_test_data(subtask_url=None, task_relation_blueprint_url=None, dataproduct_urls=None, subtask_connector_url=None, subtask_output_url=None, subtask_input_selection_template_url=None): - if subtask_url is None: - subtask_url = post_data_and_get_url(Subtask_test_data(), '/subtask/') - - if task_relation_blueprint_url is None: - task_relation_blueprint_url = post_data_and_get_url(TaskRelationBlueprint_test_data(), '/task_relation_blueprint/') - - if dataproduct_urls is None: - dataproduct_urls = [post_data_and_get_url(Dataproduct_test_data(), '/dataproduct/'), - post_data_and_get_url(Dataproduct_test_data(), '/dataproduct/')] - - if subtask_connector_url is None: - subtask_connector_url = post_data_and_get_url(SubtaskConnector_test_data(), '/subtask_connector/') - - if subtask_output_url is None: - subtask_output_url = post_data_and_get_url(SubtaskOutput_test_data(), '/subtask_output/') - - if subtask_input_selection_template_url is None: - subtask_input_selection_template_url = post_data_and_get_url(SubtaskInputSelectionTemplate_test_data(), '/subtask_input_selection_template/') - - return {"subtask": subtask_url, - "task_relation_blueprint": task_relation_blueprint_url, - "connector": subtask_connector_url, - "producer": subtask_output_url, - "dataproducts": dataproduct_urls, - "selection_doc": "{}", - "selection_template": subtask_input_selection_template_url, - "tags": []} - -def Filesystem_test_data(name="my_Filesystem", cluster_url=None): - if cluster_url is None: - cluster_url = post_data_and_get_url(Cluster_test_data(), '/cluster/') - - return {"name": name, - "description": 'My one filesystem', - "capacity": 1111111111, - "cluster": cluster_url, - "tags": ['tmss', 'testing']} - -- GitLab