コード例 #1
0
def test_gameminute_checkData():
    gm = GameMinute()
    required = ['GameID', 'TeamID', 'PlayerID']

    # This should raise a format error
    with pytest.raises(RuntimeError) as excinfo:
        needle = 'Foo'
        gm.checkData(needle, required)
    assert 'lookupID requires a dictionary' in str(excinfo.value)

    # This should raise a field error
    with pytest.raises(RuntimeError) as excinfo:
        needle = {
            'Foo': 'Bar'
        }
        gm.checkData(needle, required)
    assert 'Submitted data is missing the following fields' in str(excinfo.value)
コード例 #2
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
コード例 #3
0
ファイル: import_lineup.py プロジェクト: matt-bernhardt/trapp
 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
コード例 #4
0
def test_gameminute_saveDict():
    log = Log('test.log')
    gm = GameMinute()
    gm.connectDB()

    # Formats
    with pytest.raises(RuntimeError) as excinfo:
        data = 'foo'
        gm.saveDict(data, log)
    assert 'saveDict requires a dictionary' in str(excinfo.value)

    # Insert dummy data
    data = {
        'GameID': 1,
        'TeamID': 1,
        'PlayerID': 1,
        'TimeOn': 0,
        'TimeOff': 90,
        'Ejected': 314
    }
    assert gm.saveDict(data, log) is True
    assert gm.db.warnings() is None

    # Updates
    data = {
        'ID': 2,
        'GameID': 0,
        'TeamID': 0,
        'PlayerID': 0,
        'TimeOn': 0,
        'TimeOff': 0,
        'Ejected': 0
    }
    assert gm.saveDict(data, log) is True
    assert gm.db.warnings() is None

    # Delete dummy data
    sql = 'DELETE FROM tbl_gameminutes WHERE Ejected = 314'
    gm.db.query(sql, ())
コード例 #5
0
ファイル: compile_game.py プロジェクト: matt-bernhardt/trapp
 def getAppearanceList(self):
     gm = GameMinute()
     gm.connectDB()
     return gm.lookupIDlistByYear()
コード例 #6
0
def test_gameminute_disconnect():
    gm = GameMinute()
    gm.connectDB()
    assert hasattr(gm, 'db')
    gm.disconnectDB()
    assert hasattr(gm, 'db') is False