File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ try :
2+ from unittest import mock
3+ except ImportError :
4+ import mock
5+
6+ from graphql_ws .gevent import GeventConnectionContext , GeventSubscriptionServer
7+
8+
9+ class TestConnectionContext :
10+ def test_receive (self ):
11+ ws = mock .Mock ()
12+ connection_context = GeventConnectionContext (ws = ws )
13+ connection_context .receive ()
14+ ws .receive .assert_called ()
15+
16+ def test_send (self ):
17+ ws = mock .Mock ()
18+ ws .closed = False
19+ connection_context = GeventConnectionContext (ws = ws )
20+ connection_context .send ("test" )
21+ ws .send .assert_called_with ("test" )
22+
23+ def test_send_closed (self ):
24+ ws = mock .Mock ()
25+ ws .closed = True
26+ connection_context = GeventConnectionContext (ws = ws )
27+ connection_context .send ("test" )
28+ assert not ws .send .called
29+
30+ def test_close (self ):
31+ ws = mock .Mock ()
32+ connection_context = GeventConnectionContext (ws = ws )
33+ connection_context .close (123 )
34+ ws .close .assert_called_with (123 )
35+
36+
37+ def test_subscription_server_smoke ():
38+ GeventSubscriptionServer (schema = None )
You can’t perform that action at this time.
0 commit comments