diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py b/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py index d5dcadf93a009a714cd9e033319a98daa6e3ddef..57f01d2b9190870e0ce9f94b4b4538f701fa4a86 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/tasks.py @@ -237,6 +237,7 @@ def create_task_drafts_for_scheduling_unit_draft(scheduling_unit_draft: models.S dataformat=task_relation_definition["output"]["dataformat"], iotype=models.IOType.Choices.OUTPUT.value) selection_template = models.TaskRelationSelectionTemplate.objects.get(name=task_relation_definition["selection_template"]) + selection_doc = task_relation_definition.get("selection_doc", selection_template.get_default_json_document_for_schema()) except Exception as e: logger.error("Could not determine Task Relations for %s. Error: %s", task_relation_definition, e) raise @@ -244,11 +245,11 @@ def create_task_drafts_for_scheduling_unit_draft(scheduling_unit_draft: models.S try: with transaction.atomic(): task_relation = models.TaskRelationDraft.objects.create(tags=task_relation_definition.get("tags",[]), - selection_doc=task_relation_definition["selection_doc"], producer=producer_task_draft, consumer=consumer_task_draft, input_role=input_role, output_role=output_role, + selection_doc=selection_doc, selection_template=selection_template) logger.info("created task_relation id=%s between task draft id=%s name='%s' and id=%s name='%s", task_relation.pk, producer_task_draft.id, producer_task_draft.name, consumer_task_draft.id, consumer_task_draft.name) diff --git a/SAS/TMSS/backend/test/t_tasks.py b/SAS/TMSS/backend/test/t_tasks.py index 5ecd0360ff39f1ef9a9f46468d988d516e554b1f..6ce52c1a95cf57ee52874c240857cc18c74c28b0 100755 --- a/SAS/TMSS/backend/test/t_tasks.py +++ b/SAS/TMSS/backend/test/t_tasks.py @@ -24,6 +24,7 @@ import unittest import requests import logging + logger = logging.getLogger(__name__) logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO) @@ -66,13 +67,13 @@ class CreationFromSchedulingUnitDraft(unittest.TestCase): scheduling_unit_draft = models.SchedulingUnitDraft.objects.create( name="Test Scheduling Unit UC1", - specifications_doc=strategy_template.template, specifications_template=strategy_template.scheduling_unit_template, observation_strategy_template=strategy_template, copy_reason=models.CopyReason.objects.get(value='template'), generator_instance_doc="para", copies=None, scheduling_set=models.SchedulingSet.objects.create(**SchedulingSet_test_data())) + create_task_drafts_for_scheduling_unit_draft(scheduling_unit_draft, strategy_template.template) scheduling_unit_blueprint = create_scheduling_unit_blueprint_from_scheduling_unit_draft(scheduling_unit_draft) self.assertEqual(scheduling_unit_draft.name, scheduling_unit_blueprint.draft.name) @@ -89,7 +90,6 @@ class CreationFromSchedulingUnitDraft(unittest.TestCase): scheduling_unit_draft = models.SchedulingUnitDraft.objects.create( name="Test Scheduling Unit UC1", - specifications_doc=strategy_template.template, specifications_template=strategy_template.scheduling_unit_template, observation_strategy_template=strategy_template, copy_reason=models.CopyReason.objects.get(value='template'), @@ -97,7 +97,7 @@ class CreationFromSchedulingUnitDraft(unittest.TestCase): copies=None, scheduling_set=models.SchedulingSet.objects.create(**SchedulingSet_test_data())) - create_task_drafts_from_scheduling_unit_draft(scheduling_unit_draft) + create_task_drafts_for_scheduling_unit_draft(scheduling_unit_draft, strategy_template.template) scheduling_unit_draft.refresh_from_db() task_drafts = scheduling_unit_draft.task_drafts.all() @@ -114,7 +114,6 @@ class CreationFromSchedulingUnitDraft(unittest.TestCase): scheduling_unit_draft = models.SchedulingUnitDraft.objects.create( name="Test Scheduling Unit UC1", - specifications_doc=strategy_template.template, specifications_template=strategy_template.scheduling_unit_template, observation_strategy_template=strategy_template, copy_reason=models.CopyReason.objects.get(value='template'), @@ -122,7 +121,7 @@ class CreationFromSchedulingUnitDraft(unittest.TestCase): copies=None, scheduling_set=models.SchedulingSet.objects.create(**SchedulingSet_test_data())) - create_task_drafts_from_scheduling_unit_draft(scheduling_unit_draft) + create_task_drafts_for_scheduling_unit_draft(scheduling_unit_draft, strategy_template.template) scheduling_unit_draft.refresh_from_db() task_drafts = scheduling_unit_draft.task_drafts.all() @@ -139,7 +138,6 @@ class CreationFromSchedulingUnitDraft(unittest.TestCase): scheduling_unit_draft = models.SchedulingUnitDraft.objects.create( name="Test Scheduling Unit UC1", - specifications_doc=strategy_template.template, specifications_template=strategy_template.scheduling_unit_template, observation_strategy_template=strategy_template, copy_reason=models.CopyReason.objects.get(value='template'), @@ -147,6 +145,7 @@ class CreationFromSchedulingUnitDraft(unittest.TestCase): copies=None, scheduling_set=models.SchedulingSet.objects.create(**SchedulingSet_test_data())) + create_task_drafts_for_scheduling_unit_draft(scheduling_unit_draft, strategy_template.template) scheduling_unit_blueprint = create_task_blueprints_and_subtasks_from_scheduling_unit_draft(scheduling_unit_draft) self.assertEqual(scheduling_unit_draft.name, scheduling_unit_blueprint.draft.name) self.assertEqual(1, len(scheduling_unit_draft.scheduling_unit_blueprints.all())) @@ -181,11 +180,10 @@ class CreationFromSchedulingUnitDraft(unittest.TestCase): # create the scheduling_unit_draft and its tasks scheduling_unit_draft = models.SchedulingUnitDraft.objects.create( name="Test Scheduling Unit", - specifications_doc=specifications_doc, specifications_template=specifications_template, copy_reason=models.CopyReason.objects.get(value='template'), scheduling_set=models.SchedulingSet.objects.create(**SchedulingSet_test_data())) - create_task_drafts_from_scheduling_unit_draft(scheduling_unit_draft) + create_task_drafts_for_scheduling_unit_draft(scheduling_unit_draft, specifications_doc) # check the results, the number of task_drafts, the relation between them... self.assertEqual(2, scheduling_unit_draft.task_drafts.count()) diff --git a/SAS/TMSS/backend/test/tmss_test_data_django_models.py b/SAS/TMSS/backend/test/tmss_test_data_django_models.py index 56164972ac8b3682ea09ef6d0f8e1ffc94399309..87ee1388dca0fdb7ec9a09a5084f4d497adca73a 100644 --- a/SAS/TMSS/backend/test/tmss_test_data_django_models.py +++ b/SAS/TMSS/backend/test/tmss_test_data_django_models.py @@ -200,9 +200,6 @@ def SchedulingUnitDraft_test_data(name="my_scheduling_unit_draft", scheduling_se if template is None: template = models.SchedulingUnitTemplate.objects.create(**SchedulingUnitTemplate_test_data()) - if specifications_doc is None: - specifications_doc = get_default_json_object_for_schema(template.schema) - if scheduling_constraints_template is None: scheduling_constraints_template = models.SchedulingConstraintsTemplate.objects.create(**SchedulingConstraintsTemplate_test_data()) @@ -212,7 +209,6 @@ def SchedulingUnitDraft_test_data(name="my_scheduling_unit_draft", scheduling_se return {"name": name, "description": "", "tags": [], - "specifications_doc": specifications_doc, "copy_reason": models.CopyReason.objects.get(value='template'), "generator_instance_doc": "para", "copies": None,