diff --git a/SAS/TMSS/backend/test/t_scheduling_units.py b/SAS/TMSS/backend/test/t_scheduling_units.py index b5d7eb0e6cc925c535cd607deefd6a10878b7439..2bee1ef9aa57c5b26339c948844ea29edff97e63 100644 --- a/SAS/TMSS/backend/test/t_scheduling_units.py +++ b/SAS/TMSS/backend/test/t_scheduling_units.py @@ -503,32 +503,31 @@ class SchedulingUnitBlueprintIndirectModificationsTestCase(unittest.TestCase): # --------------------------------------------------------------- - # use the specifications_doc from the draft for some 'user'-edits + # try to use the specifications_doc from the draft for some 'user'-edits + # this will fail, because we are not allowed to remove the drafts which are already referenced by blueprints + with self.assertRaises(Exception) as context: + edited_draft_specifications_doc = client.get_schedulingunit_draft_specifications_doc(scheduling_unit_draft['id']) + # our user wants to wipe the draft + edited_draft_specifications_doc['tasks'] = {} + edited_draft_specifications_doc['task_relations'] = [] + edited_draft_specifications_doc['task_scheduling_relations'] = [] + scheduling_unit_draft = client.update_task_graph_from_specifications_doc(scheduling_unit_draft['id'], edited_draft_specifications_doc) + self.assertTrue('Cannot delete some instances of model' in str(context.exception)) + + # but we can create a copy (which has no references anymore to blueprints), and edit this copy + scheduling_unit_draft = client.copy_scheduling_unit_draft(scheduling_unit_draft['id']) edited_draft_specifications_doc = client.get_schedulingunit_draft_specifications_doc(scheduling_unit_draft['id']) - # our user wants to wipe the draft edited_draft_specifications_doc['tasks'] = {} edited_draft_specifications_doc['task_relations'] = [] edited_draft_specifications_doc['task_scheduling_relations'] = [] - scheduling_unit_draft = client.update_task_graph_from_specifications_doc(scheduling_unit_draft['id'], edited_draft_specifications_doc) + scheduling_unit_draft = client.update_task_graph_from_specifications_doc(scheduling_unit_draft['id'], + edited_draft_specifications_doc) - # check: the draft should have no tasks any more + # check: the draft(copy) should have no tasks any more self.assertEqual(0, len(scheduling_unit_draft['task_drafts'])) self.assertEqual(edited_draft_specifications_doc, client.get_schedulingunit_draft_specifications_doc(scheduling_unit_draft['id'])) self.assertNotEqual(original_draft_specifications_doc, client.get_schedulingunit_draft_specifications_doc(scheduling_unit_draft['id'])) - # but the scheduling_unit_blueprint should still have it's tasks, - scheduling_unit_blueprint = client.get_schedulingunit_blueprint(scheduling_unit_blueprint['id'], extended=True) - self.assertTrue(len(scheduling_unit_blueprint['task_blueprints']) > 0) - # and the freshly exported specifications_doc should still be equal to the original - self.assertEqual(original_blueprint_specifications_doc, client.get_schedulingunit_blueprint_specifications_doc(scheduling_unit_draft['id'])) - # and the exported specifications_doc should NOT be equal anymore to the draft - self.assertNotEqual(client.get_schedulingunit_draft_specifications_doc(scheduling_unit_draft['id']), - client.get_schedulingunit_blueprint_specifications_doc(scheduling_unit_blueprint['id'])) - - # check that each task_blueprint should now has a null reference to its delete draft - for task_blueprint in scheduling_unit_blueprint['task_blueprints']: - self.assertIsNone(task_blueprint['draft']) - # ----------------------------------------------------------------------------- # use the specifications_doc from the draft to make later 'user'-edits possible. @@ -539,7 +538,7 @@ class SchedulingUnitBlueprintIndirectModificationsTestCase(unittest.TestCase): client.update_task_blueprints_and_subtasks_graph_from_draft(scheduling_unit_blueprint['id']) # ...fetch updates, and check that indeed nothing changed (compared to the original draft/blueprint) - scheduling_unit_draft = client.get_schedulingunit_draft(scheduling_unit_draft['id'], extended=False) + scheduling_unit_draft = client.get_schedulingunit_draft(scheduling_unit_blueprint['draft_id'], extended=False) scheduling_unit_blueprint = client.get_schedulingunit_blueprint(scheduling_unit_blueprint['id'], extended=True) # check that we have some tasks again