def testGeneralRecallFirstRace(self): # create three races # create three races raceManager = RaceManager() for i in range(3): raceManager.createRace() # start the race sequence with a five minute warning raceManager.startRaceSequenceWithWarning() # # we want to achieve the affect of moving forward so that the first # race has just started. This is # WARNING_SECONDS + START_SECONDS + 1 # decrement the times of the each race to be WARNING_SECONDS + START_SECONDS + 1 # this puts us into the position of 1 second past the first race for race in raceManager.races: race.startTime = race.startTime - \ datetime.timedelta(seconds = WARNING_SECONDS + START_SECONDS + 1) self.assertEqual(raceManager.races[0].status(), "Started") self.assertEqual(raceManager.races[1].status(), "Starting") self.assertEqual(raceManager.races[2].status(), "Waiting to start") raceToRecall = raceManager.races[0] # # now do a general recall # raceManager.generalRecall() # we should still have 3 races self.assertEqual(raceManager.numberRaces(),3) # the recalled race should be at the back self.assertEqual(raceManager.races[-1],raceToRecall) # and its start time should be START_SECONDS more than the second race self.assertEqual( raceToRecall.startTime, raceManager.races[1].startTime + datetime.timedelta(seconds = START_SECONDS)) # self.assertEqual(raceManager.races[0].status(), "Starting") self.assertEqual(raceManager.races[1].status(), "Waiting to start") self.assertEqual(raceManager.races[2].status(), "Waiting to start")
def testCreateUnnamedRace(self): raceManager = RaceManager() aRace = raceManager.createRace() self.assertEqual(raceManager.numberRaces(),1) self.assertEqual(aRace.name,"Race 1")
def testEmptyRaceManager(self): raceManager = RaceManager() self.assertEqual(raceManager.numberRaces(),0)
def testCreateThreeRaces(self): raceManager = RaceManager() for i in range(3): raceManager.createRace() self.assertEqual(raceManager.numberRaces(),3)
def testCreateNamedRace(self): raceManager = RaceManager() aRace = raceManager.createRace("Brass Monkey") self.assertEqual(raceManager.numberRaces(),1) self.assertEqual(aRace.name, "Brass Monkey")