diff --git a/atdb/taskdatabase/tests.py b/atdb/taskdatabase/tests.py index 9d7ac6b00c7156b83b2aded7325ca1a2944da993..b8870daabfd591e208c0915ab60534ea9d9a5621 100644 --- a/atdb/taskdatabase/tests.py +++ b/atdb/taskdatabase/tests.py @@ -334,4 +334,37 @@ class TestCalculatedQualities(TestCase): self.assertEqual(quality_values,{'poor': 0, 'moderate': 1, 'good': 3}) # 3 out of 4 are 'good', 75% is above the 50% threshold, so 'good' - self.assertEqual(quality_per_sasid,'good') \ No newline at end of file + self.assertEqual(quality_per_sasid,'good') + + 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