Skip to content
Snippets Groups Projects
Commit 97b5e263 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

add unit tests

parent 952a88af
No related branches found
No related tags found
1 merge request!350SDC-1313 ancillary dataproducts to dcache (ATDB side)
Pipeline #78889 passed
...@@ -10,33 +10,74 @@ class TestSummaryTasks(TestCase): ...@@ -10,33 +10,74 @@ class TestSummaryTasks(TestCase):
self.workflow_requantisation = Workflow(id=22, workflow_uri="psrfits_requantisation") self.workflow_requantisation = Workflow(id=22, workflow_uri="psrfits_requantisation")
self.workflow_requantisation.save() self.workflow_requantisation.save()
self.no_summary_task = Task.objects.create(sas_id=77777, new_status=State.DEFINED.value, workflow=self.workflow_requantisation, self.no_summary_task_77777 = Task.objects.create(sas_id=77777, new_status=State.DEFINED.value, workflow=self.workflow_requantisation,
outputs={"tar_archive": [{"size": 4885985280, "basename": "L621240_SAP002_B073_P000_bf.tar", "nameroot": "L621240_SAP002_B073_P000_bf"}]}) outputs={"tar_archive": [{"size": 4885985280, "basename": "L621240_SAP002_B073_P000_bf.tar", "nameroot": "L621240_SAP002_B073_P000_bf"}]})
self.summary_task_defined = Task.objects.create(sas_id=77777, new_status=State.DEFINED.value, workflow=self.workflow_requantisation, self.summary_task_defined_77777 = Task.objects.create(sas_id=77777, new_status=State.DEFINED.value, workflow=self.workflow_requantisation,
outputs={"tar_archive": [{"size": 4885985280, "basename": "L185619_summaryCS.tar", "nameroot": "L185619_summaryCS"}]}) outputs={"tar_archive": [{"size": 4885985280, "basename": "L185619_summaryCS.tar", "nameroot": "L185619_summaryCS"}]})
self.summary_task_validated = Task.objects.create(sas_id=77777, new_status=State.VALIDATED.value, workflow=self.workflow_requantisation, self.summary_task_validated_77777 = Task.objects.create(sas_id=77777, new_status=State.VALIDATED.value, workflow=self.workflow_requantisation,
outputs={"tar_archive": [{"size": 4885985280, "basename": "L185619_summaryCS.tar", "nameroot": "L185619_summaryCS"}]})
self.summary_task_processed_77777 = Task.objects.create(sas_id=77777, new_status=State.PROCESSED.value, workflow=self.workflow_requantisation,
outputs={"tar_archive": [{"size": 4885985280, "basename": "L185619_summaryCS.tar", "nameroot": "L185619_summaryCS"}]})
# simulate an Activity that is processed, with 1 task already in STORED, the other one in PROCESSED
self.summary_task_stored_88888 = Task.objects.create(sas_id=88888, new_status=State.STORED.value, workflow=self.workflow_requantisation,
outputs={"tar_archive": [{"size": 4885985280, "basename": "L185619_summaryCS.tar", "nameroot": "L185619_summaryCS"}]})
self.summary_task_processed_88888 = Task.objects.create(sas_id=88888, new_status=State.PROCESSED.value, workflow=self.workflow_requantisation,
outputs={"tar_archive": [{"size": 4885985280, "basename": "L185619_summaryCS.tar", "nameroot": "L185619_summaryCS"}]}) outputs={"tar_archive": [{"size": 4885985280, "basename": "L185619_summaryCS.tar", "nameroot": "L185619_summaryCS"}]})
def test_no_summary_task(self): def test_no_summary_task(self):
""" """
test task that is not a summary task test task that is not a summary task
""" """
actual = self.no_summary_task_77777.is_summary
actual = self.no_summary_task.is_summary
self.assertEqual(actual, False) self.assertEqual(actual, False)
def test_summary_task_defined(self): def test_task_defined_does_not_know_that_it_is_summary(self):
""" """
test summary task, but before it knows that it becomes a summary task (which it only knows when 'processed') test summary task, but before it knows that it becomes a summary task (which it only knows when 'processed')
""" """
actual = self.summary_task_defined_77777.is_summary
actual = self.summary_task_defined.is_summary
self.assertEqual(actual, False) self.assertEqual(actual, False)
def test_summary_task_stored(self): def test_task_validated_knows_that_it_is_summary(self):
"""
test summary task, at 'stored' it should know that it is a summary task and return True)
"""
self.summary_task_validated_77777.save()
actual = self.summary_task_validated_77777.is_summary
self.assertEqual(actual, True)
def test_task_processed_knows_that_it_is_summary(self):
""" """
test summary task, at 'stored' it should know that it is a summary task and return True) test summary task, at 'stored' it should know that it is a summary task and return True)
""" """
self.summary_task_validated.save() self.summary_task_processed_77777.save()
actual = self.summary_task_validated.is_summary actual = bool(self.summary_task_processed_77777.is_summary)
self.assertEqual(actual, True) self.assertEqual(actual, True)
def test_summary_task_processed_goes_on_halt(self):
"""
test summary task, at 'stored' it should know that it is a summary task and return True)
"""
self.summary_task_processed_88888.save()
actual = self.summary_task_processed_88888.resume
self.assertEqual(actual, False)
def test_activity_77777_not_is_processed(self):
"""
activity 77777 should not be fully processed, because some tasks have not reached 'processed' yet
"""
self.summary_task_processed_77777.save()
activity = self.summary_task_processed_77777.activity
actual = bool(activity.is_processed)
self.assertFalse(actual)
def test_activity_88888_is_processed(self):
"""
SAS_ID 88888 should be is_processed, because all its tasks have status 'processed' or 'stored'
"""
self.summary_task_stored_88888.save()
self.summary_task_processed_88888.save()
activity = self.summary_task_processed_88888.activity
actual = activity.is_processed
self.assertTrue(actual)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment