diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py index d7dbbe955a81119731c2c5673972efa99960a82a..14d24b81f19d1b1f8974450d2010081f04846ff8 100644 --- a/atdb/taskdatabase/models.py +++ b/atdb/taskdatabase/models.py @@ -217,7 +217,7 @@ class Task(models.Model): self.calculated_qualities = qualities.calculate_qualities(self, tasks_for_this_sasid, quality_thresholds) # nv:20feb2024, check if this task is a summary task - if (self.status != State.PROCESSED.value) & (self.new_status == State.PROCESSED.value): + if (self.status != State.STORED.value) & (self.new_status == State.STORED.value): self.is_summary = check_if_summary(self) # nv:20feb2024, same as above, but for backward compatibilty reasons. diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index fc4fe7f33da131e313a1b83810dfa786f4e32ff6..35a46bfd0f2ad11b1652b01fa2cdb834d8545a12 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -31,7 +31,7 @@ {% include 'taskdatabase/pagination.html' %} </div> </div> - <p class="footer"> Version 20 Feb 2024 + <p class="footer"> Version 22 Feb 2024 </div> {% include 'taskdatabase/refresh.html' %} diff --git a/atdb/taskdatabase/tests/test_activities_associate.py b/atdb/taskdatabase/tests/test_activities_associate.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/atdb/taskdatabase/tests/test_summary_tasks.py b/atdb/taskdatabase/tests/test_summary_tasks.py new file mode 100644 index 0000000000000000000000000000000000000000..bf33c9f75d68202b5ecfec0e0e801e81c50a1f40 --- /dev/null +++ b/atdb/taskdatabase/tests/test_summary_tasks.py @@ -0,0 +1,42 @@ +from django.test import TestCase +import json +from taskdatabase.models import Task, Workflow, Activity +from taskdatabase.services.common import State +class TestSummaryTasks(TestCase): + def setUp(self): + """ + initialize test data + """ + self.workflow_requantisation = Workflow(id=22, workflow_uri="psrfits_requantisation") + self.workflow_requantisation.save() + + self.no_summary_task = 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"}]}) + self.summary_task_defined = 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"}]}) + self.summary_task_stored = Task.objects.create(sas_id=77777, new_status=State.STORED.value, workflow=self.workflow_requantisation, + outputs={"tar_archive": [{"size": 4885985280, "basename": "L185619_summaryCS.tar", "nameroot": "L185619_summaryCS"}]}) + + def test_no_summary_task(self): + """ + test task that is not a summary task + """ + + actual = self.no_summary_task.is_summary + self.assertEqual(actual, False) + + def test_summary_task_defined(self): + """ + test summary task, but before it knows that it becomes a summary task (which it only knows when 'processed') + """ + + actual = self.summary_task_defined.is_summary + self.assertEqual(actual, False) + + def test_summary_task_stored(self): + """ + test summary task, at 'stored' it should know that it is a summary task and return True) + """ + self.summary_task_stored.save() + actual = self.summary_task_stored.is_summary + self.assertEqual(actual, True)