|
@@ 34-52 (lines=19) @@
|
| 31 |
|
|
| 32 |
|
request.addfinalizer(fin) |
| 33 |
|
return conn |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
@pytest.fixture |
| 37 |
|
def mock_game_connection(state=GameConnectionState.INITIALIZING, player=None): |
| 38 |
|
gc = mock.create_autospec(spec=GameConnection) |
| 39 |
|
gc.state = state |
| 40 |
|
gc.player = player |
| 41 |
|
return gc |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@pytest.fixture() |
| 45 |
|
def game_stats_service(): |
| 46 |
|
service = mock.Mock(spec=GameStatsService) |
| 47 |
|
service.process_game_stats = CoroMock() |
| 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): |
|
@@ 15-31 (lines=17) @@
|
| 12 |
|
def lobbythread(): |
| 13 |
|
return mock.Mock( |
| 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 |
|
|