mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-16 06:22:59 +00:00
minor fixes to testing utils
This commit is contained in:
@@ -38,12 +38,12 @@ def db():
|
|||||||
@fixture
|
@fixture
|
||||||
def io_loop():
|
def io_loop():
|
||||||
"""Get the current IOLoop"""
|
"""Get the current IOLoop"""
|
||||||
ioloop.IOLoop.clear_current()
|
loop = ioloop.IOLoop()
|
||||||
return ioloop.IOLoop.current()
|
loop.make_current()
|
||||||
|
return loop
|
||||||
|
|
||||||
|
|
||||||
|
@fixture(scope='module')
|
||||||
@fixture
|
|
||||||
def app(request):
|
def app(request):
|
||||||
app = MockHubApp()
|
app = MockHubApp()
|
||||||
app.start([])
|
app.start([])
|
||||||
|
@@ -58,12 +58,13 @@ class MockHubApp(JupyterHubApp):
|
|||||||
self.io_loop = IOLoop.current()
|
self.io_loop = IOLoop.current()
|
||||||
# put initialize in start for SQLAlchemy threading reasons
|
# put initialize in start for SQLAlchemy threading reasons
|
||||||
super(MockHubApp, self).initialize(argv=argv)
|
super(MockHubApp, self).initialize(argv=argv)
|
||||||
user = orm.User(name=getpass.getuser())
|
|
||||||
|
# add some initial users - 1 admin, 1 non-admin
|
||||||
|
admin = orm.User(name='admin', admin=True)
|
||||||
|
user = orm.User(name='user')
|
||||||
|
self.db.add(admin)
|
||||||
self.db.add(user)
|
self.db.add(user)
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
token = user.new_api_token()
|
|
||||||
self.db.add(token)
|
|
||||||
self.db.commit()
|
|
||||||
self.io_loop.add_callback(evt.set)
|
self.io_loop.add_callback(evt.set)
|
||||||
super(MockHubApp, self).start()
|
super(MockHubApp, self).start()
|
||||||
|
|
||||||
@@ -72,6 +73,6 @@ class MockHubApp(JupyterHubApp):
|
|||||||
evt.wait(timeout=5)
|
evt.wait(timeout=5)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.io_loop.stop()
|
self.io_loop.add_callback(self.io_loop.stop)
|
||||||
self._thread.join()
|
self._thread.join()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user