示例#1
0
 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)
示例#2
0
 def get(self, player_id):
     player = Player.query.get_or_404(player_id)
     return jsonify(200, player = make_player_dict(player))
示例#3
0
 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))
示例#4
0
 def get(self):
     players = Player.query.all()
     player_dicts = [make_player_dict(p) for p in players]
     return jsonify(200, players = player_dicts)
示例#5
0
 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)