5
5
import mock
6
6
7
7
import pytest
8
+ from graphql .execution .executors .sync import SyncExecutor
8
9
9
- from graphql_ws import base , constants
10
+ from graphql_ws import base , base_sync , constants
10
11
11
12
12
13
@pytest .fixture
@@ -18,7 +19,7 @@ def cc():
18
19
19
20
@pytest .fixture
20
21
def ss ():
21
- return base . BaseSubscriptionServer (schema = None )
22
+ return base_sync . BaseSyncSubscriptionServer (schema = None )
22
23
23
24
24
25
class TestConnectionContextOperation :
@@ -137,7 +138,9 @@ def test_get_graphql_params(ss, cc):
137
138
"operationName" : "query" ,
138
139
"context" : "ctx" ,
139
140
}
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 == {
141
144
"request_string" : "req" ,
142
145
"variable_values" : "vars" ,
143
146
"operation_name" : "query" ,
@@ -189,34 +192,10 @@ def test_send_message(ss, cc):
189
192
cc .send = mock .Mock ()
190
193
cc .send .return_value = "returned"
191
194
assert "returned" == ss .send_message (cc )
192
- cc .send .assert_called_with (' {"mess": "age"}' )
195
+ cc .send .assert_called_with ({"mess" : "age" })
193
196
194
197
195
198
class TestSSNotImplemented :
196
199
def test_handle (self , ss ):
197
200
with pytest .raises (NotImplementedError ):
198
201
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