Beispiel #1
0
def test_game_lookupDuration():
    g = Game()
    g.connectDB()
    log = Log('test_lookupDuration.log')

    # Standard-duration game is 90 minutes
    needle = 1
    assert g.lookupDuration(needle, log) == 90
Beispiel #2
0
    def importRecord(self, record):
        self.log.message('\nImporting lineup ' + str(record))

        # If the game hasn't been played yet, move to the next
        # Doesn't get recorded as a "skip" to keep reporting clean
        today = datetime.now()
        gamedate = datetime(
            record['Date'][0],
            record['Date'][1],
            record['Date'][2]
        )
        if (gamedate > today):
            self.log.message('Game has not been played yet')
            return True

        # Start working with game record
        g = Game()
        g.connectDB()

        # Lookup this gameID
        needle = {
            'MatchTime': record['Date'],
            'HTeamID': record['homeID'],
            'ATeamID': record['awayID'],
        }
        game = g.lookupID(needle, self.log)

        self.log.message('Found games: ' + str(game))

        if (len(game) != 1):
            self.log.message('Found wrong number of games: ' + str(len(game)))
            self.skipped += 1
            # If we didn't find one gameID, then we abort processing this game
            return False

        # Need to convert gameID from a list of 1 number to an integer
        game = game[0]

        # Lookup game duration
        duration = g.lookupDuration(game, self.log)

        # Parse lineup string
        self.parseLineup(record['Lineup'], game, record['teamID'], duration)

        # At this point we have self.players - but need to store them
        [self.importPlayer(player) for player in self.players]

        return True