Skip to content

Commit 63a366b

Browse files
committed
Add initial gevent tests
1 parent d8abc01 commit 63a366b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/test_gevent.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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)

0 commit comments

Comments
 (0)