From eb2079d88442c52fd6261b19c20f204e41db6fd8 Mon Sep 17 00:00:00 2001
From: Jorrit Schaap <schaap@astron.nl>
Date: Wed, 27 Oct 2021 16:23:52 +0200
Subject: [PATCH] TMSS-1124: fixed blinking test

---
 .../test/t_tmssapp_specification_REST_API.py      | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/SAS/TMSS/backend/test/t_tmssapp_specification_REST_API.py b/SAS/TMSS/backend/test/t_tmssapp_specification_REST_API.py
index 1c21175df6f..25c551a93e7 100755
--- a/SAS/TMSS/backend/test/t_tmssapp_specification_REST_API.py
+++ b/SAS/TMSS/backend/test/t_tmssapp_specification_REST_API.py
@@ -3239,6 +3239,18 @@ class SchedulingUnitObservingStrategyTemplateTestCase(unittest.TestCase):
 
 
 class SubmitTriggerTestCase(unittest.TestCase):
+    @classmethod
+    def setUpClass(cls) -> None:
+        # wipe all SchedulingUnitObservingStrategyTemplate and all the referenced models
+        # because other tests may have submitted erroneous templates which cannot be submitted as trigger.
+        models.TaskBlueprint.objects.all().delete()
+        models.TaskDraft.objects.all().delete()
+        models.SchedulingUnitBlueprint.objects.all().delete()
+        models.SchedulingUnitDraft.objects.all().delete()
+        models.SchedulingUnitObservingStrategyTemplate.objects.all().delete()
+        # populate the templates again from disk which are the ones under test.
+        tmss_test_env.populate_schemas_and_connectors()
+
     def test_submit_trigger_for_all_strategy_templates(self):
         '''Try to create a scheduling_unit_draft/blueprint for each known strategy template via a trigger submission.'''
         project = models.Project.objects.create(**Project_test_data(can_trigger=True))
@@ -3246,7 +3258,8 @@ class SubmitTriggerTestCase(unittest.TestCase):
 
         with tmss_test_env.create_tmss_client() as client:
             for strategy_template in models.SchedulingUnitObservingStrategyTemplate.objects.all():
-                logger.info("test_submit_trigger_for_all_strategy_templates: checking template '%s'", strategy_template.name)
+                logger.info("--------------------------------------------------------------------------------------------")
+                logger.info("TEST_SUBMIT_TRIGGER_FOR_ALL_STRATEGY_TEMPLATES: checking template '%s'", strategy_template.name)
                 trigger_doc = client.get_trigger_specification_doc_for_scheduling_unit_observing_strategy_template(strategy_template.name, strategy_template.version)
                 trigger_doc['scheduling_set_id'] = scheduling_set.id
 
-- 
GitLab