Skip to content

Commit e6d58cf

Browse files
committed
Fix tests to match deduplication changes
1 parent ca463c9 commit e6d58cf

File tree

4 files changed

+11
-32
lines changed

4 files changed

+11
-32
lines changed

tests/test_aiohttp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def test_receive_closed(self, mock_ws):
5555
async def test_send(self, mock_ws):
5656
connection_context = AiohttpConnectionContext(ws=mock_ws)
5757
await connection_context.send("test")
58-
mock_ws.send_str.assert_called_with("test")
58+
mock_ws.send_str.assert_called_with('"test"')
5959

6060
async def test_send_closed(self, mock_ws):
6161
mock_ws.closed = True

tests/test_django_channels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_send(self):
1414
msg = mock.Mock()
1515
connection_context = DjangoChannelConnectionContext(message=msg)
1616
connection_context.send("test")
17-
msg.reply_channel.send.assert_called_with("test")
17+
msg.reply_channel.send.assert_called_with({'text': '"test"'})
1818

1919
def test_close(self):
2020
msg = mock.Mock()

tests/test_gevent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def test_send(self):
1717
ws = mock.Mock()
1818
ws.closed = False
1919
connection_context = GeventConnectionContext(ws=ws)
20-
connection_context.send("test")
21-
ws.send.assert_called_with("test")
20+
connection_context.send({"text": "test"})
21+
ws.send.assert_called_with('{"text": "test"}')
2222

2323
def test_send_closed(self):
2424
ws = mock.Mock()

tests/test_graphql_ws.py

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import mock
66

77
import pytest
8+
from graphql.execution.executors.sync import SyncExecutor
89

9-
from graphql_ws import base, constants
10+
from graphql_ws import base, base_sync, constants
1011

1112

1213
@pytest.fixture
@@ -18,7 +19,7 @@ def cc():
1819

1920
@pytest.fixture
2021
def ss():
21-
return base.BaseSubscriptionServer(schema=None)
22+
return base_sync.BaseSyncSubscriptionServer(schema=None)
2223

2324

2425
class TestConnectionContextOperation:
@@ -137,7 +138,9 @@ def test_get_graphql_params(ss, cc):
137138
"operationName": "query",
138139
"context": "ctx",
139140
}
140-
assert ss.get_graphql_params(cc, payload) == {
141+
params = ss.get_graphql_params(cc, payload)
142+
assert isinstance(params.pop("executor"), SyncExecutor)
143+
assert params == {
141144
"request_string": "req",
142145
"variable_values": "vars",
143146
"operation_name": "query",
@@ -189,34 +192,10 @@ def test_send_message(ss, cc):
189192
cc.send = mock.Mock()
190193
cc.send.return_value = "returned"
191194
assert "returned" == ss.send_message(cc)
192-
cc.send.assert_called_with('{"mess": "age"}')
195+
cc.send.assert_called_with({"mess": "age"})
193196

194197

195198
class TestSSNotImplemented:
196199
def test_handle(self, ss):
197200
with pytest.raises(NotImplementedError):
198201
ss.handle(ws=None, request_context=None)
199-
200-
def test_on_open(self, ss):
201-
with pytest.raises(NotImplementedError):
202-
ss.on_open(connection_context=None)
203-
204-
def test_on_connect(self, ss):
205-
with pytest.raises(NotImplementedError):
206-
ss.on_connect(connection_context=None, payload=None)
207-
208-
def test_on_close(self, ss):
209-
with pytest.raises(NotImplementedError):
210-
ss.on_close(connection_context=None)
211-
212-
def test_on_connection_init(self, ss):
213-
with pytest.raises(NotImplementedError):
214-
ss.on_connection_init(connection_context=None, op_id=None, payload=None)
215-
216-
def test_on_stop(self, ss):
217-
with pytest.raises(NotImplementedError):
218-
ss.on_stop(connection_context=None, op_id=None)
219-
220-
def test_on_start(self, ss):
221-
with pytest.raises(NotImplementedError):
222-
ss.on_start(connection_context=None, op_id=None, params=None)

0 commit comments

Comments
 (0)