def test_gc_last_extension(self): GCFactory.create(**(self.gc(points=6))) gc2 = GCFactory.create(**(self.gc(points=0, state=g_state.extension, due_time=self.time+timedelta(days=1)))) _, machine = get_gc_and_machine(self.gopp, self.ptcp) self.assertGradeChangeStateEqual("6") self.assertEqual(machine.due_time, gc2.due_time)
def test_gc_without_attempt_id(self): gc = GCFactory.create(**(self.gc(points=6))) gc.attempt_id = None gc.save() _, machine = get_gc_and_machine(self.gopp, self.ptcp) self.assertGradeChangeStateEqual(6) self.assertEqual(machine.valid_percentages, [6])
def get_gc_machine_state(self): _, machine = get_gc_and_machine(self.gopp, self.ptcp) return machine.stringify_machine_readable_state()
def test_gc_last_non_exist_state(self): GCFactory.create(**(self.gc(points=6))) GCFactory.create(**(self.gc(points=0, state="some_state"))) with self.assertRaises(RuntimeError): get_gc_and_machine(self.gopp, self.ptcp)
def test_gc_last_retrieved(self): GCFactory.create(**(self.gc(points=6))) GCFactory.create(**(self.gc(points=0, state=g_state.retrieved))) _, machine = get_gc_and_machine(self.gopp, self.ptcp) self.assertGradeChangeStateEqual("6")
def test_gc_last_report_sent(self): GCFactory.create(**(self.gc(points=6))) gc2 = GCFactory.create(**(self.gc(points=0, state=g_state.report_sent))) _, machine = get_gc_and_machine(self.gopp, self.ptcp) self.assertGradeChangeStateEqual("6") self.assertEqual(machine.last_report_time, gc2.grade_time)
def test_gc_last_do_over(self): GCFactory.create(**(self.gc(points=6))) GCFactory.create(**(self.gc(points=0, state=g_state.do_over))) _, machine = get_gc_and_machine(self.gopp, self.ptcp) self.assertGradeChangeStateEqual("NONE") self.assertEqual(machine.valid_percentages, [])
def test_gc_last_unavailable(self): GCFactory.create(**(self.gc(points=6))) GCFactory.create(**(self.gc(points=0, state=g_state.unavailable))) _, machine = get_gc_and_machine(self.gopp, self.ptcp) self.assertGradeChangeStateEqual("OTHER_STATE") self.assertEqual(machine.valid_percentages, [])
def test_gc_consume_failure2(self): GCFactory.create(**(self.gc(points=5, state=g_state.exempt))) GCFactory.create(**(self.gc(points=6))) with self.assertRaises(ValueError): get_gc_and_machine(self.gopp, self.ptcp)