diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py index bc3c82bae1405f86267b821da45be8e959689120..adb0cc5df6f592d110e0d05324245c038e431db8 100644 --- a/atdb/taskdatabase/models.py +++ b/atdb/taskdatabase/models.py @@ -42,51 +42,6 @@ class Workflow(models.Model): return str(self.id) + ' - ' + str(self.workflow_uri) -# convert the quality information from the JSONfield into a easy parsable list for the template -def convert_quality_to_list_for_template(task): - list = [] - - try: - list.append(str(task.quality_json['uv-coverage'])) - except: - list.append("-") - - try: - list.append(str(task.quality_json['sensitivity'])) - except: - list.append("-") - - try: - list.append(str(task.quality_json['observing-conditions'])) - except: - list.append("-") - - return list - - -def convert_quality_to_shortlist_for_template(task): - list = [] - - try: - list.append(str(task.quality_json['uv-coverage'])) - list.append(str(task.quality_json['sensitivity'])) - list.append(str(task.quality_json['observing-conditions'])) - except Exception as err: - pass - - return list - -def convert_summary_to_list_for_template(task): - list = [] - - try: - summary = task.quality_json['summary'] - - except Exception as err: - pass - - return list - def associate_task_with_activity(task): if not task.activity: @@ -410,29 +365,6 @@ class Task(models.Model): except: return None - @property - def quality_as_list(self): - try: - q = convert_quality_to_list_for_template(self) - return q - except: - return None - - @property - def quality_as_shortlist(self): - try: - q = convert_quality_to_shortlist_for_template(self) - return q - except: - return None - - @property - def summary_as_list(self): - try: - q = convert_summary_to_list_for_template(self) - return q - except: - return None @property def sas_id_archived(self): diff --git a/atdb/taskdatabase/templates/taskdatabase/validation/tasks.html b/atdb/taskdatabase/templates/taskdatabase/validation/tasks.html index 85b5007cef9df74b1976f5b9bec1980148e9b2b5..856161cad8212d406104187221d06c39e6d720db 100644 --- a/atdb/taskdatabase/templates/taskdatabase/validation/tasks.html +++ b/atdb/taskdatabase/templates/taskdatabase/validation/tasks.html @@ -44,7 +44,7 @@ {% endif %} {% else %} - <td>-</td><td>-</td><td>-</td><td>-</td><td>-</td> + <td>-</td><td>-</td> {% endif %} diff --git a/atdb/taskdatabase/tests/test_models_processed_summary.py b/atdb/taskdatabase/tests/test_models_processed_summary.py index 2c317872ab717e06b1d6cfa120103d074603d2d2..9774545cfeef1145d93bf5da1b64288a3626ce87 100644 --- a/atdb/taskdatabase/tests/test_models_processed_summary.py +++ b/atdb/taskdatabase/tests/test_models_processed_summary.py @@ -37,7 +37,14 @@ class TestProcessedSummary(TestCase): self.task3 = Task.objects.create(sas_id=222, new_status=State.PROCESSED.value, workflow=self.workflow_requantisation, - outputs={"summary": [{"is_summary": True}]}) + outputs={ + "summary": [{"is_summary": True}], + "quality": { + "summary" : {"L441006_summaryCS.tar" : {"is_summary" : True} }, + "plots" : [{"basename": "L441006_CS_quick_summary.pdf"}] + } + }) + self.task3.save() # this is a summary task, but it uses a workflow with an aggregation_strategy that should not hold the task @@ -91,4 +98,32 @@ class TestProcessedSummary(TestCase): task 3 only has the new 'is_summary' test. Check if the task indeed gets seen as a summary_task """ actual = self.task3.is_summary - self.assertTrue(actual) \ No newline at end of file + self.assertTrue(actual) + + def test_has_quality_summary(self): + """ + task 3 has both the quality.summary field and summary field filled + It is the quality.summary field that is used as the real source of truth. + """ + actual = self.task3.has_summary + self.assertTrue(actual) + + def test_has_plots(self): + """ + task 3 has quality.plots field to test the has_plots function + """ + actual = self.task3.has_plots + self.assertTrue(actual) + + def test_has_no_plots(self): + """ + task 4 has no quality.plots field to test the has_plots function + """ + actual = self.task4.has_plots + self.assertFalse(actual) + def test_predecessor_status(self): + """ + test prececessor_status + """ + actual = self.task3.predecessor_status + self.assertEqual(actual, "no_predecessor") \ No newline at end of file diff --git a/atdb/taskdatabase/tests/test_views_postprocessing_page.py b/atdb/taskdatabase/tests/test_views_postprocessing_page.py new file mode 100644 index 0000000000000000000000000000000000000000..69b603d4f01c582792f66256228e3cc63a24b211 --- /dev/null +++ b/atdb/taskdatabase/tests/test_views_postprocessing_page.py @@ -0,0 +1,19 @@ +from django.test import TestCase +from django.urls import reverse + +from taskdatabase.models import Task, Workflow +class PostProcessingPageViewTest(TestCase): + + + def test_url_exists_at_desired_location(self): + response = self.client.get('/atdb/postprocessing-tasks') + self.assertEqual(response.status_code, 200) + + def test_url_accessible_by_name(self): + response = self.client.get(reverse('postprocessing-tasks')) + self.assertEqual(response.status_code, 200) + + def test_uses_correct_template(self): + response = self.client.get(reverse('postprocessing-tasks')) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, 'taskdatabase/postprocessing.html') \ No newline at end of file