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

adding more unittests

parent 37458db1
No related branches found
No related tags found
1 merge request!361SDC-1423 use aggregation strategy
Pipeline #89156 passed
......@@ -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):
......
......@@ -44,7 +44,7 @@
{% endif %}
{% else %}
<td>-</td><td>-</td><td>-</td><td>-</td><td>-</td>
<td>-</td><td>-</td>
{% endif %}
......
......@@ -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
......@@ -92,3 +99,31 @@ class TestProcessedSummary(TestCase):
"""
actual = self.task3.is_summary
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment