mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Merge pull request #599 from GeorgianaElena/update-hubtraf-calls
This commit is contained in:
@@ -16,9 +16,9 @@ async def test_admin_login():
|
|||||||
password = "admin"
|
password = "admin"
|
||||||
|
|
||||||
async with User(username, hub_url, partial(login_dummy, password=password)) as u:
|
async with User(username, hub_url, partial(login_dummy, password=password)) as u:
|
||||||
await u.login()
|
await u.login()
|
||||||
await u.ensure_server()
|
# If user is not logged in, this will raise an exception
|
||||||
|
await u.ensure_server_simulate()
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@@ -35,11 +35,7 @@ async def test_unsuccessful_login(username, password):
|
|||||||
"""
|
"""
|
||||||
hub_url = 'http://localhost'
|
hub_url = 'http://localhost'
|
||||||
|
|
||||||
try:
|
async with User(username, hub_url, partial(login_dummy, password="")) as u:
|
||||||
async with User(username, hub_url, partial(login_dummy, password="")) as u:
|
user_logged_in = await u.login()
|
||||||
await u.login()
|
|
||||||
except Exception:
|
assert user_logged_in == False
|
||||||
# This is what we except to happen
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ async def test_user_code_execute():
|
|||||||
|
|
||||||
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
||||||
await u.login()
|
await u.login()
|
||||||
await u.ensure_server()
|
await u.ensure_server_simulate()
|
||||||
await u.start_kernel()
|
await u.start_kernel()
|
||||||
await u.assert_code_output("5 * 4", "20", 5, 5)
|
await u.assert_code_output("5 * 4", "20", 5, 5)
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ async def test_user_admin_add():
|
|||||||
|
|
||||||
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
||||||
await u.login()
|
await u.login()
|
||||||
await u.ensure_server()
|
await u.ensure_server_simulate()
|
||||||
|
|
||||||
# Assert that the user exists
|
# Assert that the user exists
|
||||||
assert pwd.getpwnam(f'jupyter-{username}') is not None
|
assert pwd.getpwnam(f'jupyter-{username}') is not None
|
||||||
@@ -91,7 +91,7 @@ async def test_user_admin_remove():
|
|||||||
|
|
||||||
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
||||||
await u.login()
|
await u.login()
|
||||||
await u.ensure_server()
|
await u.ensure_server_simulate()
|
||||||
|
|
||||||
# Assert that the user exists
|
# Assert that the user exists
|
||||||
assert pwd.getpwnam(f'jupyter-{username}') is not None
|
assert pwd.getpwnam(f'jupyter-{username}') is not None
|
||||||
@@ -103,7 +103,7 @@ async def test_user_admin_remove():
|
|||||||
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'reload')).wait()
|
assert 0 == await (await asyncio.create_subprocess_exec(*TLJH_CONFIG_PATH, 'reload')).wait()
|
||||||
|
|
||||||
await u.stop_server()
|
await u.stop_server()
|
||||||
await u.ensure_server()
|
await u.ensure_server_simulate()
|
||||||
|
|
||||||
# Assert that the user does *not* have admin rights
|
# Assert that the user does *not* have admin rights
|
||||||
assert f'jupyter-{username}' not in grp.getgrnam('jupyterhub-admins').gr_mem
|
assert f'jupyter-{username}' not in grp.getgrnam('jupyterhub-admins').gr_mem
|
||||||
@@ -125,7 +125,7 @@ async def test_long_username():
|
|||||||
try:
|
try:
|
||||||
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
||||||
await u.login()
|
await u.login()
|
||||||
await u.ensure_server()
|
await u.ensure_server_simulate()
|
||||||
|
|
||||||
# Assert that the user exists
|
# Assert that the user exists
|
||||||
system_username = generate_system_username(f'jupyter-{username}')
|
system_username = generate_system_username(f'jupyter-{username}')
|
||||||
@@ -162,7 +162,7 @@ async def test_user_group_adding():
|
|||||||
try:
|
try:
|
||||||
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
||||||
await u.login()
|
await u.login()
|
||||||
await u.ensure_server()
|
await u.ensure_server_simulate()
|
||||||
|
|
||||||
# Assert that the user exists
|
# Assert that the user exists
|
||||||
system_username = generate_system_username(f'jupyter-{username}')
|
system_username = generate_system_username(f'jupyter-{username}')
|
||||||
@@ -207,7 +207,7 @@ async def test_idle_server_culled():
|
|||||||
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
||||||
await u.login()
|
await u.login()
|
||||||
# Start user's server
|
# Start user's server
|
||||||
await u.ensure_server()
|
await u.ensure_server_simulate()
|
||||||
# Assert that the user exists
|
# Assert that the user exists
|
||||||
assert pwd.getpwnam(f'jupyter-{username}') is not None
|
assert pwd.getpwnam(f'jupyter-{username}') is not None
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ async def test_active_server_not_culled():
|
|||||||
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
||||||
await u.login()
|
await u.login()
|
||||||
# Start user's server
|
# Start user's server
|
||||||
await u.ensure_server()
|
await u.ensure_server_simulate()
|
||||||
# Assert that the user exists
|
# Assert that the user exists
|
||||||
assert pwd.getpwnam(f'jupyter-{username}') is not None
|
assert pwd.getpwnam(f'jupyter-{username}') is not None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user