mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Add full integration test with hubtraf
- Fully simulates what a user would be doing - Also tests tljh-config set and reload functionality
This commit is contained in:
@@ -1,5 +1,32 @@
|
||||
import requests
|
||||
from hubtraf.user import User
|
||||
from hubtraf.auth.dummy import login_dummy
|
||||
import secrets
|
||||
import pytest
|
||||
from functools import partial
|
||||
import pwd
|
||||
|
||||
|
||||
def test_hub_up():
|
||||
r = requests.get('http://127.0.0.1')
|
||||
r.raise_for_status()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_user_code_execute():
|
||||
"""
|
||||
User logs in, starts a server & executes code
|
||||
"""
|
||||
# This *must* be localhost, not an IP
|
||||
# aiohttp throws away cookies if we are connecting to an IP!
|
||||
hub_url = 'http://localhost'
|
||||
username = secrets.token_hex(8)
|
||||
|
||||
async with User(username, hub_url, partial(login_dummy, password='')) as u:
|
||||
await u.login()
|
||||
await u.ensure_server()
|
||||
await u.start_kernel()
|
||||
await u.assert_code_output("5 * 4", "20", 5, 5)
|
||||
|
||||
# Assert that the user exists
|
||||
assert pwd.getpwnam(f'jupyter-{username}') is not None
|
||||
Reference in New Issue
Block a user