def test_make_player_dict(self): p = MagicMock() p.id = 0 p.steam_id = '0' p.name = 'Name' p_info = { 'id': 0, 'steam_id': '0', 'name': 'Name', } from lobbypy.models.utils import make_player_dict rv = make_player_dict(p) self.assertEqual(rv, p_info)
def get(self, player_id): player = Player.query.get_or_404(player_id) return jsonify(200, player = make_player_dict(player))
def get(self, lobby_id, player_id): lobby = Lobby.query.get_or_404(lobby_id) player = Player.query.get_or_404(player_id) if player not in lobby.spectators: abort(404) return jsonify(200, spectator = make_player_dict(player))
def get(self): players = Player.query.all() player_dicts = [make_player_dict(p) for p in players] return jsonify(200, players = player_dicts)
def get(self, lobby_id): lobby = Lobby.query.get_or_404(lobby_id) player_dicts = [make_player_dict(p) for p in lobby.spectators] return jsonify(200, spectators = player_dicts)