Exemple #1
0
def test_clear_disconnected_should_clear_game_when_no_players_left_in_room():
    controller = GameController()

    controller.handle(HelloServerMsg(0, 'Piotr'), 0)
    controller.handle(WantToJoinMsg(0), 0)
    controller.disconnected(0)
    controller.clear_disconnected()

    actual = controller.handle(HelloServerMsg(2, 'Piotr'), 2)

    assert actual == MsgToSend(2,
                               message='hello client',
                               status='can create',
                               list_of_players_in_room=[])
Exemple #2
0
def test_clear_disconnected_should_remove_players_from_room():
    controller = GameController()

    controller.handle(HelloServerMsg(0, 'Piotr'), 0)
    controller.handle(HelloServerMsg(1, 'Marta'), 1)
    controller.handle(WantToJoinMsg(0), 0)
    controller.handle(WantToJoinMsg(1), 1)
    controller.disconnected(0)
    controller.clear_disconnected()

    actual = controller.handle(HelloServerMsg(2, 'Piotr'), 2)

    assert actual == MsgToSend(2,
                               message='hello client',
                               status='can join',
                               list_of_players_in_room=['Marta'])