Example #1
0
def test_gameminute_lookupID():
    log = Log('test.log')
    gm = GameMinute()
    gm.connectDB()

    needle = {
        'GameID': 1,
        'TeamID': 2,
        'PlayerID': 3
    }
    result = gm.lookupID(needle, log)
    assert len(result) == 1

    needle = {
        'GameID': -1,
        'TeamID': -1,
        'PlayerID': -1
    }
    result = gm.lookupID(needle, log)
    assert len(result) == 0
Example #2
0
 def importPlayer(self, player):
     self.log.message(str(player))
     gm = GameMinute()
     gm.connectDB()
     appearanceID = gm.lookupID(player, self.log)
     if (len(appearanceID) > 1):
         # We have more than one record of this player/team/game.
         # This is a problem.
         self.errored += 1
     elif (len(appearanceID) == 1):
         # We already have a record of this player/team/game.
         # We add that appearanceID, to ensure an update operation.
         player['ID'] = appearanceID[0]
         gm.saveDict(player, self.log)
         self.updated += 1
     else:
         gm.saveDict(player, self.log)
         self.imported += 1
     return True