From ba8be20abc81316edabf12abcdbb7a18054a7ecd Mon Sep 17 00:00:00 2001 From: GeorgianaElena Date: Tue, 21 Jul 2020 12:04:54 +0300 Subject: [PATCH 1/3] ensure_server is now ensure_server_simulate --- integration-tests/test_hub.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/integration-tests/test_hub.py b/integration-tests/test_hub.py index d47893d..22dfbbf 100644 --- a/integration-tests/test_hub.py +++ b/integration-tests/test_hub.py @@ -38,7 +38,7 @@ async def test_user_code_execute(): async with User(username, hub_url, partial(login_dummy, password='')) as u: await u.login() - await u.ensure_server() + await u.ensure_server_simulate() await u.start_kernel() 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: await u.login() - await u.ensure_server() + await u.ensure_server_simulate() # Assert that the user exists 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: await u.login() - await u.ensure_server() + await u.ensure_server_simulate() # Assert that the user exists 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() await u.stop_server() - await u.ensure_server() + await u.ensure_server_simulate() # Assert that the user does *not* have admin rights assert f'jupyter-{username}' not in grp.getgrnam('jupyterhub-admins').gr_mem @@ -125,7 +125,7 @@ async def test_long_username(): try: async with User(username, hub_url, partial(login_dummy, password='')) as u: await u.login() - await u.ensure_server() + await u.ensure_server_simulate() # Assert that the user exists system_username = generate_system_username(f'jupyter-{username}') @@ -162,7 +162,7 @@ async def test_user_group_adding(): try: async with User(username, hub_url, partial(login_dummy, password='')) as u: await u.login() - await u.ensure_server() + await u.ensure_server_simulate() # Assert that the user exists 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: await u.login() # Start user's server - await u.ensure_server() + await u.ensure_server_simulate() # Assert that the user exists 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: await u.login() # Start user's server - await u.ensure_server() + await u.ensure_server_simulate() # Assert that the user exists assert pwd.getpwnam(f'jupyter-{username}') is not None From 3e62ee347a586cea058696714e9ccce3ab305daf Mon Sep 17 00:00:00 2001 From: GeorgianaElena Date: Tue, 21 Jul 2020 13:33:20 +0300 Subject: [PATCH 2/3] one more place to ensure_server_simulate --- integration-tests/test_admin_installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/test_admin_installer.py b/integration-tests/test_admin_installer.py index 3fcc169..dd6e2e8 100644 --- a/integration-tests/test_admin_installer.py +++ b/integration-tests/test_admin_installer.py @@ -17,7 +17,7 @@ async def test_admin_login(): async with User(username, hub_url, partial(login_dummy, password=password)) as u: await u.login() - await u.ensure_server() + await u.ensure_server_simulate() @pytest.mark.asyncio From c79df23873de27ceca471eb4a857a082e50ef9e4 Mon Sep 17 00:00:00 2001 From: GeorgianaElena Date: Tue, 21 Jul 2020 16:58:54 +0300 Subject: [PATCH 3/3] hubtraf user login doesn't raise exceptions anymore --- integration-tests/test_admin_installer.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/integration-tests/test_admin_installer.py b/integration-tests/test_admin_installer.py index dd6e2e8..1f6f38a 100644 --- a/integration-tests/test_admin_installer.py +++ b/integration-tests/test_admin_installer.py @@ -16,9 +16,9 @@ async def test_admin_login(): password = "admin" async with User(username, hub_url, partial(login_dummy, password=password)) as u: - await u.login() - await u.ensure_server_simulate() - + await u.login() + # If user is not logged in, this will raise an exception + await u.ensure_server_simulate() @pytest.mark.asyncio @pytest.mark.parametrize( @@ -35,11 +35,7 @@ async def test_unsuccessful_login(username, password): """ hub_url = 'http://localhost' - try: - async with User(username, hub_url, partial(login_dummy, password="")) as u: - await u.login() - except Exception: - # This is what we except to happen - pass - else: - raise + async with User(username, hub_url, partial(login_dummy, password="")) as u: + user_logged_in = await u.login() + + assert user_logged_in == False