File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ try :
2+ from aiohttp import WSMsgType
3+ from graphql_ws .aiohttp import AiohttpConnectionContext , AiohttpSubscriptionServer
4+ except ImportError : # pragma: no cover
5+ WSMsgType = None
6+
17from unittest import mock
28
39import pytest
4- from aiohttp import WSMsgType
510
6- from graphql_ws .aiohttp import AiohttpConnectionContext , AiohttpSubscriptionServer
711from graphql_ws .base import ConnectionClosedException
812
13+ if_aiohttp_installed = pytest .mark .skipif (
14+ WSMsgType is None , reason = "aiohttp is not installed"
15+ )
16+
917
1018class AsyncMock (mock .Mock ):
1119 def __call__ (self , * args , ** kwargs ):
12-
1320 async def coro ():
1421 return super (AsyncMock , self ).__call__ (* args , ** kwargs )
1522
@@ -24,6 +31,7 @@ def mock_ws():
2431 return ws
2532
2633
34+ @if_aiohttp_installed
2735@pytest .mark .asyncio
2836class TestConnectionContext :
2937 async def test_receive_good_data (self , mock_ws ):
@@ -69,5 +77,6 @@ async def test_close(self, mock_ws):
6977 mock_ws .close .assert_called_with (code = 123 )
7078
7179
80+ @if_aiohttp_installed
7281def test_subscription_server_smoke ():
7382 AiohttpSubscriptionServer (schema = None )
You can’t perform that action at this time.
0 commit comments