Example #1
0
 def test_complete_qualification(self):
     self.qualification = Qualification.objects.get(pk=1)
     self.audit = CompletionAudit(
         obj=self.qualification,
         rules=QUALIFICATION_COMPLETION_RULES)
     completion_rate = self.audit.run()
     self.assertEqual(completion_rate, 100)
Example #2
0
class TestQualificationCompletionAudit(TestCase):
    fixtures = ['groups', 'sa_provinces', 'test_provider_users',
                'test_providers', 'test_campus', 'test_qualification',
                'test_requirement']

    def test_complete_qualification(self):
        self.qualification = Qualification.objects.get(pk=1)
        self.audit = CompletionAudit(
            obj=self.qualification,
            rules=QUALIFICATION_COMPLETION_RULES)
        completion_rate = self.audit.run()
        self.assertEqual(completion_rate, 100)

    def test_incomplete_qualification(self):
        self.qualification = Qualification.objects.get(pk=2)

        self.audit = CompletionAudit(
            obj=self.qualification,
            rules=QUALIFICATION_COMPLETION_RULES)

        completion_rate = self.audit.run()

        self.assertEqual(completion_rate, 28)
        self.qualification.assessment = True
        self.qualification.save()

        self.audit = CompletionAudit(
            obj=self.qualification,
            rules=QUALIFICATION_COMPLETION_RULES)

        completion_rate = self.audit.run()

        self.assertEqual(completion_rate, 31)
Example #3
0
    def test_incomplete_campus(self):
        self.campus = Campus.objects.get(pk=2)

        self.audit = CompletionAudit(
            obj=self.campus,
            rules=CAMPUS_COMPLETION_RULES)

        completion_rate = self.audit.run()

        self.assertEqual(completion_rate, 16)
Example #4
0
    def test_incomplete_qualification(self):
        self.qualification = Qualification.objects.get(pk=2)

        self.audit = CompletionAudit(
            obj=self.qualification,
            rules=QUALIFICATION_COMPLETION_RULES)

        completion_rate = self.audit.run()

        self.assertEqual(completion_rate, 28)
        self.qualification.assessment = True
        self.qualification.save()

        self.audit = CompletionAudit(
            obj=self.qualification,
            rules=QUALIFICATION_COMPLETION_RULES)

        completion_rate = self.audit.run()

        self.assertEqual(completion_rate, 31)
Example #5
0
class TestCampusCompletionAudit(TestCase):
    fixtures = ['groups', 'sa_provinces', 'test_provider_users', 'test_providers', 'test_campus'] # noqa

    def test_complete_campus(self):
        self.campus = Campus.objects.get(pk=1)

        self.audit = CompletionAudit(
            obj=self.campus,
            rules=CAMPUS_COMPLETION_RULES)

        completion_rate = self.audit.run()

        self.assertEqual(completion_rate, 100)

    def test_incomplete_campus(self):
        self.campus = Campus.objects.get(pk=2)

        self.audit = CompletionAudit(
            obj=self.campus,
            rules=CAMPUS_COMPLETION_RULES)

        completion_rate = self.audit.run()

        self.assertEqual(completion_rate, 16)
Example #6
0
def completion_audit(sender, instance, created, **kwargs):
    completion_rate = CompletionAudit(instance, sender.COMPLETION_RULES).run()

    # prevent infinite loop
    sender.objects.filter(pk=instance.pk).update(
        completion_rate=completion_rate)