|
@@ 51-69 (lines=19) @@
|
| 48 |
|
return service |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
@pytest.fixture |
| 52 |
|
def connections(loop, player_service, game_service, transport, game): |
| 53 |
|
from server import GameConnection |
| 54 |
|
|
| 55 |
|
def make_connection(player, connectivity): |
| 56 |
|
lc = LobbyConnection(loop) |
| 57 |
|
lc.protocol = mock.Mock() |
| 58 |
|
conn = GameConnection(loop=loop, |
| 59 |
|
lobby_connection=lc, |
| 60 |
|
player_service=player_service, |
| 61 |
|
games=game_service) |
| 62 |
|
conn.player = player |
| 63 |
|
conn.game = game |
| 64 |
|
conn._transport = transport |
| 65 |
|
conn._connectivity_state.set_result(connectivity) |
| 66 |
|
return conn |
| 67 |
|
|
| 68 |
|
return mock.Mock( |
| 69 |
|
make_connection=make_connection |
| 70 |
|
) |
| 71 |
|
|
| 72 |
|
def add_connected_player(game: Game, player): |
|
@@ 17-33 (lines=17) @@
|
| 14 |
|
sendJSON=lambda obj: None |
| 15 |
|
) |
| 16 |
|
|
| 17 |
|
@pytest.fixture |
| 18 |
|
def game_connection(request, game, loop, player_service, players, game_service, transport): |
| 19 |
|
from server import GameConnection, LobbyConnection |
| 20 |
|
conn = GameConnection(loop=loop, |
| 21 |
|
lobby_connection=mock.create_autospec(LobbyConnection(loop)), |
| 22 |
|
player_service=player_service, |
| 23 |
|
games=game_service) |
| 24 |
|
conn._transport = transport |
| 25 |
|
conn.player = players.hosting |
| 26 |
|
conn.game = game |
| 27 |
|
conn.lobby = mock.Mock(spec=LobbyConnection) |
| 28 |
|
|
| 29 |
|
def fin(): |
| 30 |
|
conn.abort() |
| 31 |
|
|
| 32 |
|
request.addfinalizer(fin) |
| 33 |
|
return conn |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
@pytest.fixture |