Example #1
0
    def test_DoesNotAcceptDnfIfBibIsNotRegistered(self):
        some_participant = 7
        sut = Race(laps=3, bibs=[some_participant])
        sut.start('12:00:00')

        not_a_participant = 13
        with self.assertRaises(BibIsNotRegistered):
            sut.dnf(not_a_participant)
Example #2
0
 def test_TheOneWhoDNFsStandsLower(self):
     participant1 = 7
     participant2 = 9
     sut = Race(laps=3, bibs=[participant1, participant2])
     sut.start('12:00:00')
     sut.split(participant2, '12:10:00')
     sut.split(participant1, '12:12:00')
     sut.split(participant2, '12:15:00')
     sut.dnf(participant2)
     standings = [result.bib for result in sut.results]
     self.assertSequenceEqual([participant1, participant2], standings)
Example #3
0
    def test_DoesNotAcceptDnfIfBibHasAlreadyFinished(self):
        some_participant = 7
        sut = Race(laps=3, bibs=[some_participant])
        sut.start('12:00:00')

        sut.split(some_participant, '12:10:10')
        sut.split(some_participant, '12:15:20')
        sut.split(some_participant, '12:20:00')

        with self.assertRaises(BibHasAlreadyFinished):
            sut.dnf(some_participant)
Example #4
0
    def test_ReturnsNumberOfRidersOnTheCourse(self):
        sut = Race(laps=1, bibs=[1, 2, 3])
        self.assertEqual(0, sut.riders_on_course)

        sut.start('12:00:00')
        self.assertEqual(3, sut.riders_on_course)

        sut.split(1, '12:01:00')
        sut.split(2, '12:01:03')
        self.assertEqual(1, sut.riders_on_course)

        sut.dnf(3)
        self.assertEqual(0, sut.riders_on_course)
Example #5
0
    def test_DnfRidesHasDnfInResultsTable(self):
        some_participant = 7
        sut = Race(laps=3, bibs=[some_participant])
        sut.start('12:00:00')

        sut.split(some_participant, '12:10:10')
        sut.split(some_participant, '12:15:20')

        sut.dnf(some_participant)

        result = sut.results[0]

        self.assertEqual(ParticipantState.DNF, result.state)
Example #6
0
 def test_DoesNotAcceptsDnfIfRaceHasNotStartedYet(self):
     some_participant = 7
     sut = Race(laps=5, bibs=[some_participant])
     with self.assertRaises(RaceHasNotStartedYet):
         sut.dnf(some_participant)