def test_get_game_tables(self): games = Games([ Game('1A', 'Game 1A', 'Author 1A', 'System 1A', 'Blurb 1A', 1, 2), ]) players = Players([ Player('Gary Gygax', 'TSR', {'1A': 'G'}), Player('Dave Arneson', None, {'1A': 'P'}), ]) self.assertEqual([], db.get_game_tables('1A', games['1A'], players)) db.query_db( 'INSERT INTO game_tables (slot, data) VALUES (?, ?);', ('1A', '{"gm": "Gary Gygax", "players": ["Dave Arneson"]}')) game_table = GameTable( games['1A'], list(players)[0], list(players)[1:]) self.assertEqual( [game_table], db.get_game_tables('1A', games['1A'], players))
def game(slot): try: game = db.get_game(slot) except db.NotFound: abort(404) game_tables = db.get_game_tables(slot) return render_template( 'game.html', game=game, game_tables=game_tables, player_name=player_name, len=len)
def game_table_list_csv(slot): try: game = db.get_game(slot) except db.NotFound: abort(404) players = db.get_players_for_game(slot) game_tables = GameTables([game], players, {slot: db.get_game_tables(slot)}) table_list_csv = StringIO() game_tables.to_list_csv(table_list_csv) resp = make_response(table_list_csv.getvalue()) resp.headers['Content-Type'] = 'text/csv' return resp