From c690d025d561d52f7fcddecfe2a9140571b26ad4 Mon Sep 17 00:00:00 2001
From: goei <JsXLRu>
Date: Wed, 3 Jun 2020 18:08:47 +0200
Subject: [PATCH] TMSS-207: Hack creating pipeline task blueprint when creating
 task blueprint observation

---
 SAS/TMSS/src/tmss/tmssapp/tasks.py     | 7 +++++--
 SAS/TMSS/test/t_specify_observation.py | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/SAS/TMSS/src/tmss/tmssapp/tasks.py b/SAS/TMSS/src/tmss/tmssapp/tasks.py
index 9b16ade3ad0..e42b9aff0b2 100644
--- a/SAS/TMSS/src/tmss/tmssapp/tasks.py
+++ b/SAS/TMSS/src/tmss/tmssapp/tasks.py
@@ -25,9 +25,12 @@ def create_task_blueprint_from_task_draft_and_instantiate_subtasks_from_template
     """
     logger.debug("create_task_blueprint_from_task_draft_and_instantiate_subtasks_from_template(task_draft.id=%s)...", task_draft.pk)
     task_blueprint = create_task_blueprint_from_task_draft(task_draft)
-
     obs_subtask = create_subtask_observation_control(task_blueprint)
-    pipe_subtask = create_subtask_pipeline_control(task_blueprint)
+
+    # HACK: I also create a task blueprint from task  draft (pipeline) but that should not be done here....
+    task_blueprint_pipeline = create_task_blueprint_from_task_draft(TaskDraft.objects.get(name='Test PreProcessingPipeline Task'))
+    pipe_subtask = create_subtask_pipeline_control(task_blueprint_pipeline)
+
     connect_observation_subtask_to_preprocessing_subtask(obs_subtask, pipe_subtask)
 
     if task_blueprint.specifications_doc.get("QA",{}).get("file_conversion",{}).get("enabled", False):
diff --git a/SAS/TMSS/test/t_specify_observation.py b/SAS/TMSS/test/t_specify_observation.py
index f80b138af73..2a3c1691887 100755
--- a/SAS/TMSS/test/t_specify_observation.py
+++ b/SAS/TMSS/test/t_specify_observation.py
@@ -54,7 +54,7 @@ class SpecifyObservationFromTaskDraftTest(unittest.TestCase):
         task_blueprint = create_task_blueprint_from_task_draft_and_instantiate_subtasks_from_template(task_draft)
         self.assertEqual(task_draft.name, task_blueprint.draft.name)
         res_task_blueprint = GET_and_assert_equal_expected_code(self, BASE_URL + '/task_blueprint/1/', 200)
-        self.assertEqual(len(res_task_blueprint['subtasks']), 4)
+        self.assertEqual(len(res_task_blueprint['subtasks']), 3)
         self.assertEqual(res_task_blueprint['specifications_template'], res_task_draft['specifications_template'])
         for subtask_url in res_task_blueprint['subtasks']:
             res_subtask = GET_and_assert_equal_expected_code(self, subtask_url, 200)
-- 
GitLab