def test_make_lobby_dict(self): l = MagicMock() l.owner = self._make_player() l.id = 0 l.name = 'Lobby' l.game_map = 'cp_badlands' l.teams = [self._make_team()] l.spectators = [self._make_player()] p_dict = { 'id': 0, 'name': 'Name', 'steam_id': '0', } l_info = { 'id': 0, 'owner': p_dict, 'name': 'Lobby', 'game_map': 'cp_badlands', 'spectators': [p_dict], 'teams': [{ 'id': 0, 'name': 'Red', 'players': [{ 'class_id': 0, 'ready': True, 'player': p_dict, }] }], } from lobbypy.models.utils import make_lobby_dict rv = make_lobby_dict(l) self.assertEqual(rv, l_info)
def get(self, lobby_id): lobby = Lobby.query.get_or_404(lobby_id) return jsonify(200, lobby = make_lobby_dict(lobby))
def get(self): lobbies = Lobby.query.all() lobby_dicts = [make_lobby_dict(l) for l in lobbies] return jsonify(200, lobbies = lobby_dicts)