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

hotfix

parent 55d19a90
No related branches found
No related tags found
1 merge request!367update unit-tests branch with latest from master
Pipeline #91831 passed
...@@ -16,6 +16,7 @@ class State(Enum): ...@@ -16,6 +16,7 @@ class State(Enum):
AGGREGATE = "aggregate" AGGREGATE = "aggregate"
AGGREGATING = "aggregating" AGGREGATING = "aggregating"
AGGREGATED = "aggregated" AGGREGATED = "aggregated"
STORING = 'storing'
STORED = 'stored' STORED = 'stored'
VALIDATED = "validated" VALIDATED = "validated"
SCRUBBED = "scrubbed" SCRUBBED = "scrubbed"
...@@ -34,7 +35,7 @@ class State(Enum): ...@@ -34,7 +35,7 @@ class State(Enum):
VERIFIED_STATUSSES = [State.STORED.value, State.VALIDATED.value, State.SCRUBBED.value, State.PRE_ARCHIVED.value, VERIFIED_STATUSSES = [State.STORED.value, State.VALIDATED.value, State.SCRUBBED.value, State.PRE_ARCHIVED.value,
State.ARCHIVED.value, State.FINISHED.value, State.SUSPENDED.value, State.DISCARDED.value] State.ARCHIVED.value, State.FINISHED.value, State.SUSPENDED.value, State.DISCARDED.value]
PROCESSED_STATUSSES = [State.PROCESSED.value, State.AGGREGATE.value, State.AGGREGATING.value, State.AGGREGATED.value, State.STORED.value, PROCESSED_STATUSSES = [State.PROCESSED.value, State.AGGREGATE.value, State.AGGREGATING.value, State.AGGREGATED.value, State.STORED.value, State.STORING.value,
State.DISCARDED.value] State.DISCARDED.value]
INGEST_FRACTION_STATUSSES = [State.SCRUBBED.value, State.PRE_ARCHIVING.value, State.PRE_ARCHIVED.value, INGEST_FRACTION_STATUSSES = [State.SCRUBBED.value, State.PRE_ARCHIVING.value, State.PRE_ARCHIVED.value,
......
from django.test import TestCase, RequestFactory
from django.urls import reverse
from django.http import HttpResponse
from django.shortcuts import redirect
from taskdatabase.models import Task, Workflow
from taskdatabase.views import SortTasks
class TestViews(TestCase):
def setUp(self):
self.factory = RequestFactory()
# Create a test workflow
workflow_requantisation = Workflow(workflow_uri="psrfits_requantisation")
workflow_requantisation.save()
# Create a test task
self.task1 = Task.objects.create(filter='a',sas_id=456, status='stored', workflow=workflow_requantisation, priority=1)
self.task2 = Task.objects.create(filter='b',sas_id=123, status='stored', workflow=workflow_requantisation, priority=1)
# def test_sort(self):
# # Set up the URL for the view
# #url = reverse('sort-tasks', kwargs={'sort': 'sas_id', 'redirect_to_page': 'atdb'})
#
# # Create a request object
# request = self.factory.get('/dummy-url')
#
# # Call the function with sort='priority' and redirect_to_page='tasks_list'
# response = SortTasks(request, sort='sas_id', redirect_to_page='atdb')
#
# # Check if the sort field is correctly stored in the session
# self.assertEqual(request.session['sort'], 'name')
#
# # Check if it redirects to the 'index' page
# self.assertEqual(response.status_code, 302)
# self.assertEqual(response.url, reverse('atdb'))
\ No newline at end of file
...@@ -2,7 +2,7 @@ from django.test import TestCase ...@@ -2,7 +2,7 @@ from django.test import TestCase
from django.urls import reverse from django.urls import reverse
from django.http import JsonResponse, HttpResponse from django.http import JsonResponse, HttpResponse
from taskdatabase.models import Task, Workflow from taskdatabase.models import Task, Workflow, Activity
import taskdatabase.tests.test_calculated_qualities_outputs as outputs import taskdatabase.tests.test_calculated_qualities_outputs as outputs
import json import json
...@@ -12,8 +12,11 @@ class TestGetSummary(TestCase): ...@@ -12,8 +12,11 @@ class TestGetSummary(TestCase):
workflow_requantisation = Workflow(workflow_uri="psrfits_requantisation") workflow_requantisation = Workflow(workflow_uri="psrfits_requantisation")
workflow_requantisation.save() workflow_requantisation.save()
activity_54321 = Activity(sas_id=54321, calculated_quality="good")
activity_54321.save()
# rfi_percent=0 # rfi_percent=0
Task.objects.get_or_create(sas_id=54321, status='stored', Task.objects.get_or_create(sas_id=54321, status='stored', activity = activity_54321,
outputs=outputs.default_summary_flavour_with_rfi_percent_zero_1, outputs=outputs.default_summary_flavour_with_rfi_percent_zero_1,
workflow=workflow_requantisation, workflow=workflow_requantisation,
calculated_qualities = {"per_task": "good", "per_sasid": "good"}, calculated_qualities = {"per_task": "good", "per_sasid": "good"},
...@@ -33,10 +36,15 @@ class TestGetSummary(TestCase): ...@@ -33,10 +36,15 @@ class TestGetSummary(TestCase):
workflow=workflow_requantisation, workflow=workflow_requantisation,
calculated_qualities = {"per_task": "good", "per_sasid": "good"}) calculated_qualities = {"per_task": "good", "per_sasid": "good"})
# test image compression, rfi_percentage=1.7186448587105623 # test image compression, rfi_percentage=1.7186448587105623
workflow_imaging_compression = Workflow(workflow_uri="imaging_compress_pipeline_v011") workflow_imaging_compression = Workflow(workflow_uri="imaging_compress_pipeline_v011")
workflow_imaging_compression.save() workflow_imaging_compression.save()
Task.objects.get_or_create(sas_id=55555, status='stored',
activity_55555 = Activity(sas_id=55555, calculated_quality="good")
activity_55555.save()
Task.objects.get_or_create(sas_id=55555, status='stored', activity = activity_55555,
outputs=outputs.imaging_compression_summary_flavor_with_rfi_1, outputs=outputs.imaging_compression_summary_flavor_with_rfi_1,
workflow=workflow_imaging_compression, workflow=workflow_imaging_compression,
calculated_qualities={"per_task": "good", "per_sasid": "good"}, calculated_qualities={"per_task": "good", "per_sasid": "good"},
...@@ -152,7 +160,7 @@ class TestGetSummary(TestCase): ...@@ -152,7 +160,7 @@ class TestGetSummary(TestCase):
def test_summary_pdf_response(self): def test_summary_pdf_response(self):
# Mock request # Mock request
response = self.client.get(reverse('get-summary', args=['your_sas_id', 'pdf'])) response = self.client.get(reverse('get-summary', args=['54321', 'pdf']))
# Check if response is HttpResponse # Check if response is HttpResponse
self.assertIsInstance(response, HttpResponse) self.assertIsInstance(response, HttpResponse)
...@@ -191,3 +199,4 @@ class TestGetSummary(TestCase): ...@@ -191,3 +199,4 @@ class TestGetSummary(TestCase):
# Assert # Assert
# test a little bit of the html content # test a little bit of the html content
self.assertEqual(expected_title in html_data, True) self.assertEqual(expected_title in html_data, True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment