def test_uniqueness(self): visit = factories.FlowPageVisitFactory( page_data=self.fpdata, answer=None, visit_time=datetime(2019, 1, 1, tzinfo=pytz.UTC), ) factories.FlowPageVisitGradeFactory(visit=visit) from django.db import IntegrityError with self.assertRaises(IntegrityError): factories.FlowPageVisitGradeFactory(visit=visit)
def test_unicode(self): visit = factories.FlowPageVisitFactory( page_data=self.fpdata, answer=None, visit_time=datetime(2019, 1, 1, tzinfo=pytz.UTC), ) visit2 = factories.FlowPageVisitFactory( page_data=self.fpdata, answer=None, visit_time=datetime(2019, 1, 2, tzinfo=pytz.UTC), ) fpvg = factories.FlowPageVisitGradeFactory(visit=visit) fpvg2 = factories.FlowPageVisitGradeFactory(visit=visit2) self.assertEqual(fpvg.percentage(), None) self.assertNotEqual(str(fpvg), str(fpvg2))
def test_percentage(self): visit = factories.FlowPageVisitFactory( page_data=self.fpdata, answer={"answer": "hi"}, visit_time=datetime(2019, 1, 1, tzinfo=pytz.UTC), ) fpvg = factories.FlowPageVisitGradeFactory(visit=visit, correctness=0.5) self.assertEqual(fpvg.percentage(), 50)