Skip to content

Commit

Permalink
give the server a second to notice that the websocket closed
Browse files Browse the repository at this point in the history
because travis is slow
  • Loading branch information
minrk committed Jan 13, 2017
1 parent 0cc6665 commit e0a0d28
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions notebook/services/kernels/tests/test_kernels_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Test the kernels service API."""

import json
import time

import requests
from tornado.websocket import websocket_connect
Expand Down Expand Up @@ -159,11 +160,18 @@ def test_kernel_handler(self):
def test_connections(self):
kid = self.kern_api.start().json()['id']
model = self.kern_api.get(kid).json()
assert model['connections'] == 0
self.assertEqual(model['connections'], 0)

ws = self.kern_api.websocket(kid)
model = self.kern_api.get(kid).json()
assert model['connections'] == 1
self.assertEqual(model['connections'], 1)
ws.close()
# give it some time to close on the other side:
for i in range(10):
model = self.kern_api.get(kid).json()
if model['connections'] > 0:
time.sleep(0.1)
else:
break
model = self.kern_api.get(kid).json()
assert model['connections'] == 0
self.assertEqual(model['connections'], 0)

0 comments on commit e0a0d28

Please sign in to comment.