Example #1
0
    def testStartRaceManagerSequence(self):
        # create three races
        raceManager = RaceManager()
        for i in range(3):
            raceManager.createRace()
            
        # start the race sequence with a five minute warning
        raceManager.startRaceSequenceWithWarning()

        # check that the time deltas for the three races are correct
        self.assertEqual(raceManager.races[0].startTime, self.createDateTimeFromNow(
            WARNING_SECONDS + START_SECONDS))
        self.assertEqual(raceManager.races[1].startTime, self.createDateTimeFromNow(
            WARNING_SECONDS + START_SECONDS * 2))
        self.assertEqual(raceManager.races[2].startTime, self.createDateTimeFromNow(
            WARNING_SECONDS + START_SECONDS * 3))
Example #2
0
    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")