예제 #1
0
    def importRecord(self, record):
        self.log.message('Importing game ' + str(record))
        g = Game()
        g.connectDB()

        # Does the record exist?
        found = g.lookupID(record, self.log)
        if (len(found) == 0):
            # Nothing found, so we import
            g.saveDict(record, self.log)
            self.imported += 1
        elif (len(found) == 1):
            record['MatchID'] = found[0]
            g.saveDict(record, self.log)
            self.imported += 1
        else:
            # Something(s) found, so we skip
            self.processMissingRecord(found, len(found))

        return True
예제 #2
0
def test_game_saveDict():
    # Setup
    log = Log('test.log')
    g = Game()
    g.connectDB()

    # This should raise an error
    with pytest.raises(RuntimeError) as excinfo:
        testRecord = "fake player record"
        g.saveDict(testRecord, log)
    assert 'saveDict requires a dictionary' in str(excinfo.value)

    # This should work
    sample = {
        'MatchTime': (1980, 1, 1, 19, 30, 0, 0, 0, 0),
        'MatchTypeID': 21,
        'HTeamID': 11,
        'HScore': 0,
        'ATeamID': 12,
        'AScore': 0,
        'VenueID': 1,
    }
    assert g.saveDict(sample, log) is True
    assert g.db.warnings() is None