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

add unittests

parent 8949bd7a
No related branches found
No related tags found
3 merge requests!333get all the new changes from master into the branch,!330still a bug,!328Solving Feature SDCP-239
Pipeline #68342 passed
from django.test import TestCase
from taskdatabase.models import Task, Workflow
class TestIngestFraction(TestCase):
def setUp(self):
# create a list of Tasks with various values of rfi_percent to test the quality algorithms
workflow_requantisation = Workflow(workflow_uri="psrfits_requantisation")
workflow_requantisation.save()
Task.objects.get_or_create(filter='a',sas_id=54321, status='stored', workflow=workflow_requantisation)
Task.objects.get_or_create(filter='a',sas_id=54321, status='scrubbed', workflow=workflow_requantisation)
Task.objects.get_or_create(filter='b',sas_id=54321, status='scrubbed', workflow=workflow_requantisation)
Task.objects.get_or_create(filter='a',sas_id=54321, status='archiving', workflow=workflow_requantisation)
Task.objects.get_or_create(filter='a',sas_id=54321, status='archived', workflow=workflow_requantisation)
Task.objects.get_or_create(filter='a',sas_id=54321, status='finished', workflow=workflow_requantisation)
Task.objects.get_or_create(filter='b',sas_id=54321, status='finished', workflow=workflow_requantisation)
def test_ingest_fraction(self):
# collapse all tasks into a single task for this sas_id
task = Task.objects.filter(sas_id=54321).distinct('sas_id')[0]
# get the list of statusses and level of completion
statusses = task.sasid_ingested_fraction['status']
completion = task.sasid_ingested_fraction['completion']
self.assertEqual(statusses, {'scrubbed': 2, 'archiving': 1, 'archived': 1, 'finished': 2})
self.assertEqual(completion,50)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment