avoid cleaning users when we are testing resume

This commit is contained in:
Min RK
2018-10-17 11:02:06 +02:00
parent 301fed30b2
commit b0116ee539
2 changed files with 8 additions and 5 deletions

View File

@@ -40,7 +40,7 @@ from tornado import gen
from tornado.concurrent import Future from tornado.concurrent import Future
from tornado.ioloop import IOLoop from tornado.ioloop import IOLoop
from traitlets import default from traitlets import Bool, default
from ..app import JupyterHub from ..app import JupyterHub
from ..auth import PAMAuthenticator from ..auth import PAMAuthenticator
@@ -282,9 +282,12 @@ class MockHub(JupyterHub):
self.db.expire(service) self.db.expire(service)
return super().init_services() return super().init_services()
clean_users = Bool(True)
def init_db(self): def init_db(self):
"""Ensure we start with a clean user list""" """Ensure we start with a clean user list"""
super().init_db() super().init_db()
if self.clean_users:
for user in self.db.query(orm.User): for user in self.db.query(orm.User):
self.db.delete(user) self.db.delete(user)
self.db.commit() self.db.commit()

View File

@@ -206,7 +206,7 @@ def test_resume_spawners(tmpdir, request):
ssl_enabled = getattr(request.module, "ssl_enabled", False) ssl_enabled = getattr(request.module, "ssl_enabled", False)
if ssl_enabled: if ssl_enabled:
kwargs['internal_certs_location'] = str(tmpdir) kwargs['internal_certs_location'] = str(tmpdir)
app = MockHub(**kwargs) app = MockHub(clean_users=False, **kwargs)
app.config.ConfigurableHTTPProxy.should_start = False app.config.ConfigurableHTTPProxy.should_start = False
app.config.ConfigurableHTTPProxy.auth_token = 'unused' app.config.ConfigurableHTTPProxy.auth_token = 'unused'
yield app.initialize([]) yield app.initialize([])