Skip to content

Commit

Permalink
Add full integration test with hubtraf
Browse files Browse the repository at this point in the history
- Fully simulates what a user would be doing
- Also tests tljh-config set and reload functionality
  • Loading branch information
yuvipanda committed Jul 28, 2018
1 parent fad3e70 commit 396deb9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ jobs:
python3 .circleci/integration-test.py copy . /srv/src
python3 .circleci/integration-test.py run 'python3 /srv/src/bootstrap/bootstrap.py'
- run:
name: switch to dummyauthenticator
command: |
python3 .circleci/integration-test.py run '/opt/tljh/hub/bin/tljh-config set auth.type dummyauthenticator.DummyAuthenticator'
python3 .circleci/integration-test.py run '/opt/tljh/hub/bin/tljh-config reload'
- run:
name: print systemd status + logs
command: |
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pytest
requests
pytest-asyncio
git+https://github.com/yuvipanda/hubtraf.git
21 changes: 21 additions & 0 deletions integration-tests/test_hub.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
import requests
from hubtraf.user import User
from hubtraf.auth.dummy import login_dummy
import secrets
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_login():
hub_url = 'http://127.0.0.1'
username = secrets.token_hex(16)

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

0 comments on commit 396deb9

Please sign in to comment.