async def test_command_game_join_calls_join_game(mocker, database, lobbyconnection, game_service, test_game_info, players, game_stats_service): lobbyconnection.game_service = game_service game = Game(42, database, game_service, game_stats_service) game.state = GameState.LOBBY game.password = None game.game_mode = 'faf' game.id = 42 game.name = "Test Game Name" game_service._games[42] = game lobbyconnection.player = players.hosting test_game_info['uid'] = 42 await lobbyconnection.on_message_received({ "command": "game_join", **test_game_info }) expected_reply = { "command": "game_launch", "args": ["/numgames", players.hosting.game_count[RatingType.GLOBAL]], "uid": 42, "mod": "faf", "name": "Test Game Name", "init_mode": InitMode.NORMAL_LOBBY.value, } lobbyconnection.protocol.send_message.assert_called_with(expected_reply)
async def test_command_game_join_uid_as_str(mocker, database, lobbyconnection, game_service, test_game_info, players, game_stats_service): lobbyconnection.game_service = game_service game = Game(42, database, game_service, game_stats_service) game.state = GameState.LOBBY game.password = None game.game_mode = 'faf' game.id = 42 game.name = "Test Game Name" game_service._games[42] = game lobbyconnection.player = players.hosting test_game_info['uid'] = '42' # Pass in uid as string await lobbyconnection.on_message_received({ "command": "game_join", **test_game_info }) expected_reply = { 'command': 'game_launch', 'args': ['/numgames', players.hosting.game_count[RatingType.GLOBAL]], 'mod': 'faf', 'uid': 42, 'name': 'Test Game Name', 'init_mode': InitMode.NORMAL_LOBBY.value, } lobbyconnection.protocol.send_message.assert_called_with(expected_reply)
async def test_command_game_join_uid_as_str(mocker, database, lobbyconnection, game_service, test_game_info, players, game_stats_service): lobbyconnection.send = CoroutineMock() lobbyconnection.game_service = game_service game = Game(42, database, game_service, game_stats_service) game.state = GameState.LOBBY game.password = None game.game_mode = "faf" game.id = 42 game.name = "Test Game Name" game_service._games[42] = game lobbyconnection.player = players.hosting players.hosting.state = PlayerState.IDLE players.hosting.in_game = False test_game_info["uid"] = "42" # Pass in uid as string await lobbyconnection.on_message_received({ "command": "game_join", **test_game_info }) expected_reply = { "command": "game_launch", "args": ["/numgames", players.hosting.game_count[RatingType.GLOBAL]], "mod": "faf", "uid": 42, "name": "Test Game Name", "init_mode": InitMode.NORMAL_LOBBY.value, "rating_type": "global", } lobbyconnection.send.assert_called_with(expected_reply)