Skip to content

Commit 770600b

Browse files
committed
Refactor setup.py test dependencies
Also minor changes to test_susbcription_transport module
1 parent ed6b71a commit 770600b

2 files changed

Lines changed: 18 additions & 24 deletions

File tree

setup.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
except (IOError, ImportError):
77
long_description = open('README.md').read()
88

9+
tests_dep = [
10+
'pytest', 'pytest-mock', 'fakeredis', 'graphene', 'subprocess32',
11+
'flask', 'flask-graphql', 'flask-sockets', 'multiprocess', 'requests'
12+
]
13+
914
setup(
1015
name='graphql-subscriptions',
1116
version='0.1.8',
@@ -27,11 +32,11 @@
2732
'License :: OSI Approved :: MIT License'
2833
],
2934
install_requires=[
30-
'gevent-websocket', 'redis', 'promise==1.0.1', 'graphql-core'
35+
'gevent-websocket', 'redis', 'graphql-core', 'promise<=1.0.1'
3136
],
3237
test_suite='pytest',
33-
tests_require=[
34-
'pytest', 'pytest-mock', 'fakeredis', 'graphene', 'subprocess32',
35-
'flask', 'flask-graphql', 'flask-sockets', 'multiprocess', 'requests'
36-
],
38+
tests_require=tests_dep,
39+
extras_require={
40+
'test': tests_dep
41+
},
3742
include_package_data=True)

tests/test_subscription_transport.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
from graphql_subscriptions import (RedisPubsub, SubscriptionManager,
2828
SubscriptionServer)
2929

30-
from graphql_subscriptions.subscription_transport_ws import (
31-
SUBSCRIPTION_FAIL, SUBSCRIPTION_DATA)
30+
from graphql_subscriptions.subscription_transport_ws import (SUBSCRIPTION_FAIL,
31+
SUBSCRIPTION_DATA)
3232

3333
if os.name == 'posix' and sys.version_info[0] < 3:
3434
import subprocess32 as subprocess
@@ -338,8 +338,7 @@ def test_should_trigger_on_connect_if_client_connect_valid(server_with_mocks):
338338
require('subscriptions-transport-ws').SubscriptionClient
339339
new SubscriptionClient('ws://localhost:{1}/socket')
340340
'''.format(
341-
os.path.join(os.path.dirname(__file__), 'node_modules'),
342-
TEST_PORT)
341+
os.path.join(os.path.dirname(__file__), 'node_modules'), TEST_PORT)
343342
try:
344343
subprocess.check_output(
345344
['node', '-e', node_script], stderr=subprocess.STDOUT, timeout=.2)
@@ -360,8 +359,7 @@ def test_should_trigger_on_connect_with_correct_cxn_params(server_with_mocks):
360359
connectionParams,
361360
}})
362361
'''.format(
363-
os.path.join(os.path.dirname(__file__), 'node_modules'),
364-
TEST_PORT)
362+
os.path.join(os.path.dirname(__file__), 'node_modules'), TEST_PORT)
365363
try:
366364
subprocess.check_output(
367365
['node', '-e', node_script], stderr=subprocess.STDOUT, timeout=.2)
@@ -381,8 +379,7 @@ def test_trigger_on_disconnect_when_client_disconnects(server_with_mocks):
381379
const client = new SubscriptionClient('ws://localhost:{1}/socket')
382380
client.client.close()
383381
'''.format(
384-
os.path.join(os.path.dirname(__file__), 'node_modules'),
385-
TEST_PORT)
382+
os.path.join(os.path.dirname(__file__), 'node_modules'), TEST_PORT)
386383
subprocess.check_output(['node', '-e', node_script])
387384
mock = server_with_mocks.get_nowait()
388385
assert mock.name == 'on_disconnect'
@@ -415,8 +412,7 @@ def test_should_call_unsubscribe_when_client_closes_cxn(server_with_mocks):
415412
client.client.close()
416413
}}, 500)
417414
'''.format(
418-
os.path.join(os.path.dirname(__file__), 'node_modules'),
419-
TEST_PORT)
415+
os.path.join(os.path.dirname(__file__), 'node_modules'), TEST_PORT)
420416
try:
421417
subprocess.check_output(
422418
['node', '-e', node_script], stderr=subprocess.STDOUT, timeout=1)
@@ -450,8 +446,7 @@ def test_should_trigger_on_subscribe_when_client_subscribes(server_with_mocks):
450446
// nothing
451447
}})
452448
'''.format(
453-
os.path.join(os.path.dirname(__file__), 'node_modules'),
454-
TEST_PORT)
449+
os.path.join(os.path.dirname(__file__), 'node_modules'), TEST_PORT)
455450
try:
456451
subprocess.check_output(
457452
['node', '-e', node_script], stderr=subprocess.STDOUT, timeout=.2)
@@ -487,8 +482,7 @@ def test_should_trigger_on_unsubscribe_when_client_unsubscribes(
487482
}})
488483
client.unsubscribe(subId)
489484
'''.format(
490-
os.path.join(os.path.dirname(__file__), 'node_modules'),
491-
TEST_PORT)
485+
os.path.join(os.path.dirname(__file__), 'node_modules'), TEST_PORT)
492486
try:
493487
subprocess.check_output(
494488
['node', '-e', node_script], stderr=subprocess.STDOUT, timeout=.2)
@@ -960,7 +954,6 @@ def test_rejects_client_that_does_not_specifiy_a_supported_protocol(server):
960954
stdin=subprocess.PIPE,
961955
stdout=subprocess.PIPE,
962956
stderr=subprocess.STDOUT)
963-
time.sleep(.2)
964957
q = Queue.Queue()
965958
t = threading.Thread(target=enqueue_output, args=(p.stdout, q))
966959
t.daemon = True
@@ -1003,7 +996,6 @@ def test_rejects_unparsable_message(server):
1003996
stdin=subprocess.PIPE,
1004997
stdout=subprocess.PIPE,
1005998
stderr=subprocess.STDOUT)
1006-
time.sleep(.2)
1007999
q = Queue.Queue()
10081000
t = threading.Thread(target=enqueue_output, args=(p.stdout, q))
10091001
t.daemon = True
@@ -1047,7 +1039,6 @@ def test_rejects_nonsense_message(server):
10471039
stdin=subprocess.PIPE,
10481040
stdout=subprocess.PIPE,
10491041
stderr=subprocess.STDOUT)
1050-
time.sleep(.2)
10511042
q = Queue.Queue()
10521043
t = threading.Thread(target=enqueue_output, args=(p.stdout, q))
10531044
t.daemon = True
@@ -1094,7 +1085,6 @@ def test_does_not_crash_on_unsub_from_unknown_sub(server):
10941085
stdin=subprocess.PIPE,
10951086
stdout=subprocess.PIPE,
10961087
stderr=subprocess.STDOUT)
1097-
time.sleep(.2)
10981088
q = Queue.Queue()
10991089
t = threading.Thread(target=enqueue_output, args=(p.stdout, q))
11001090
t.daemon = True
@@ -1245,7 +1235,6 @@ def test_sends_a_keep_alive_signal_in_the_socket(server_with_keep_alive):
12451235
stdin=subprocess.PIPE,
12461236
stdout=subprocess.PIPE,
12471237
stderr=subprocess.STDOUT)
1248-
time.sleep(.5)
12491238
q = Queue.Queue()
12501239
t = threading.Thread(target=enqueue_output, args=(p.stdout, q))
12511240
t.daemon = True

0 commit comments

Comments
 (0)