示例#1
0
 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)
示例#2
0
 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])
示例#3
0
 def get_gc_machine_state(self):
     _, machine = get_gc_and_machine(self.gopp, self.ptcp)
     return machine.stringify_machine_readable_state()
示例#4
0
 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)
示例#5
0
 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")
示例#6
0
 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)
示例#7
0
 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, [])
示例#8
0
 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, [])
示例#9
0
 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)