def test_league_printStandings(): log = Log('test.log') l = League() l.connectDB() l.lookupTeamsBySeason(1900, 'foo', '1900-01-01', log) output = l.printStandings() assert output == 'Team Pts GP\n' l.lookupTeamsBySeason(1996, 'mls', '1996-01-01', log) output = l.printStandings() assert len(output) > 0
def main(mode, competition, model, batch, season, start): settings = Settings(mode, competition, model, batch, season, start) # Reflect back the configuration being used click.echo(settings.output()) # Initialize tooling click.echo('Initializing tooling...') filename = date.today().strftime("%y%m%d") + '-' + mode + '-' + model log = Log('logs/' + filename + '.log') log.message('Started') output = Log('output/' + filename + '.csv') db = Database() db.connect() log.message('Database connected') # Initialize data click.echo('Initializing data...') league = League() league.connectDB() league.lookupTeamsBySeason(settings.values['season'], settings.values['competition'], settings.values['start'], log) game = Game() game.connectDB() game.lookupGamesBySeason(settings.values['season'], settings.values['competition'], settings.values['start'], log) # Output the starting point for simulation, including the standings. click.echo(league.printStandings()) log.message(league.printStandings()) # Write top lines of output/labels once output.message(league.outputLine('Conference', league.teams)) output.message(league.outputLine('Abbv', league.teams)) # Iterate over games for i in range(settings.values['batch']): log.message("Season " + str(i)) league.simulateSeason(game, settings.values['model'], log) output.message(league.outputLine('Points', league.standings)) # Teardown click.echo('Finishing...') db.disconnect() log.message('Database disconnected') log.end()