def test_dismissed(self): c = HighJumpCompetition() c.add_jumper(bib='A',first_name='Harald',last_name='England') c.add_jumper(bib='B',first_name='William',last_name='Norman') self.assertRaises(RuleViolation,c.cleared,'A') self.assertRaises(RuleViolation,c.passed,'A') self.assertRaises(RuleViolation,c.failed,'A') self.assertRaises(RuleViolation,c.retired,'A') c.set_bar_height(Decimal('2.00')) A=c.jumpers_by_bib['A'] B=c.jumpers_by_bib['B'] self.assertEquals(A.dismissed,False) self.assertEquals(B.dismissed,False) c.cleared('A') c.passed('B') self.assertEquals(A.dismissed,True) self.assertEquals(B.dismissed,True) c.set_bar_height(Decimal('2.02')) self.assertEquals(A.dismissed,False) self.assertEquals(B.dismissed,False) c.cleared('A') c.failed('B') self.assertEquals(A.dismissed,True) self.assertEquals(B.dismissed,False) c.passed('B') self.assertEquals(B.dismissed,True)
def test_dismissed(self): c = HighJumpCompetition() c.add_jumper(bib='A', first_name='Harald', last_name='England') c.add_jumper(bib='B', first_name='William', last_name='Norman') self.assertRaises(RuleViolation, c.cleared, 'A') self.assertRaises(RuleViolation, c.passed, 'A') self.assertRaises(RuleViolation, c.failed, 'A') self.assertRaises(RuleViolation, c.retired, 'A') c.set_bar_height(Decimal('2.00')) A = c.jumpers_by_bib['A'] B = c.jumpers_by_bib['B'] self.assertEqual(A.dismissed, False) self.assertEqual(B.dismissed, False) c.cleared('A') c.passed('B') self.assertEqual(A.dismissed, True) self.assertEqual(B.dismissed, True) c.set_bar_height(Decimal('2.02')) self.assertEqual(A.dismissed, False) self.assertEqual(B.dismissed, False) c.cleared('A') c.failed('B') self.assertEqual(A.dismissed, True) self.assertEqual(B.dismissed, False) c.passed('B') self.assertEqual(B.dismissed, True)
def test_trials(self): c = HighJumpCompetition() c.add_jumper(bib='A', first_name='Harald', last_name='England') c.add_jumper(bib='B', first_name='William', last_name='Norman') h1 = Decimal('1.10') h2 = Decimal('1.15') h3 = Decimal('1.14') c.set_bar_height(h1) self.assertEqual(c.state, 'started', 'state should be started') self.assertEqual(c.is_finished, False, 'not finished') self.assertEqual(c.is_running, True, 'is running') c.cleared('A') c.cleared('B') c.set_bar_height(h2) c.failed('A') c.failed('B') c.failed('A') c.failed('B') c.failed('A') c.failed('B') self.assertEqual(c.state, 'jumpoff', 'jumpoff state should be reached') self.assertEqual(c.is_finished, False, "jumpoff competition is not finished") self.assertEqual(c.is_running, True, "jumpoff competition is running") c.set_bar_height(h3) self.assertEqual(c.trials, [('A', h1, 'o'), ('B', h1, 'o'), ('A', h2, 'x'), ('B', h2, 'x'), ('A', h2, 'x'), ('B', h2, 'x'), ('A', h2, 'x'), ('B', h2, 'x')], 'trials in jumpoff state') c.failed('A') self.assertEqual(c.state, 'jumpoff', 'still in jumpoff after A fails at 1.14') self.assertEqual(c.trials, [('A', h1, 'o'), ('B', h1, 'o'), ('A', h2, 'x'), ('B', h2, 'x'), ('A', h2, 'x'), ('B', h2, 'x'), ('A', h2, 'x'), ('B', h2, 'x'), ('A', h3, 'x')], 'trials after A fails at 1.14') c.cleared('B') self.assertEqual(c.state, 'finished', 'state finished after B clears at 1.14') fal = [('A', h1, 'o'), ('B', h1, 'o'), ('A', h2, 'x'), ('B', h2, 'x'), ('A', h2, 'x'), ('B', h2, 'x'), ('A', h2, 'x'), ('B', h2, 'x'), ('A', h3, 'x'), ('B', h3, 'o')] fadl = [dict(bib=a[0], height=a[1], result=a[2]) for a in fal] self.assertEqual(c.trials, fal, 'final trials') self.assertEqual(c.trial_objs, fadl, 'final trial_objs') self.assertEqual(c.from_actions().trials, fal, 'd.from_actions().trials should match c.trials') self.assertEqual( c.from_actions().trial_objs, fadl, 'd.from_actions().trial_objs should match c.trial_objs')