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

adding unittests

parent 6f8c5c0d
No related branches found
No related tags found
2 merge requests!304update branch with master,!302automatic quality validation
Pipeline #52209 passed
...@@ -334,4 +334,37 @@ class TestCalculatedQualities(TestCase): ...@@ -334,4 +334,37 @@ class TestCalculatedQualities(TestCase):
self.assertEqual(quality_values,{'poor': 0, 'moderate': 1, 'good': 3}) self.assertEqual(quality_values,{'poor': 0, 'moderate': 1, 'good': 3})
# 3 out of 4 are 'good', 75% is above the 50% threshold, so 'good' # 3 out of 4 are 'good', 75% is above the 50% threshold, so 'good'
self.assertEqual(quality_per_sasid,'good') self.assertEqual(quality_per_sasid,'good')
\ No newline at end of file
def test_faulty_thresholds(self):
"""
what happens if the user makes a typo in the threshold?
"""
# faulty thresholds
quality_thresholds = {
"moderate": "a",
"poor": 50,
"overall_poor": 50,
"overall_good": 90,
}
# get the tasks for sas_id 54321
tasks_for_this_sasid = Task.objects.filter(sas_id=54321)
# run the algorithms and gather the values
quality_values = {'poor': 0, 'moderate': 0, 'good': 0}
quality_per_sasid = None
for task in tasks_for_this_sasid:
q = qualities.calculate_qualities(task, tasks_for_this_sasid, quality_thresholds)
try:
key = task.calculated_qualities['per_task']
quality_values[key] = quality_values[key] + 1
quality_per_sasid = task.calculated_qualities['per_sasid']
except:
# ignore the tasks that have no calculated quality.
pass
self.assertEqual(quality_values, {'poor': 0, 'moderate': 0, 'good': 0})
self.assertEqual(quality_per_sasid, None)
\ No newline at end of file
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