mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 15:03:02 +00:00
sync with master
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Test the JupyterHub entry point"""
|
||||
import binascii
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@@ -329,3 +330,41 @@ def test_url_config(hub_config, expected):
|
||||
# validate additional properties
|
||||
for key, value in expected.items():
|
||||
assert getattr(app, key) == value
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"base_url, hub_routespec, expected_routespec, should_warn, bad_prefix",
|
||||
[
|
||||
(None, None, "/", False, False),
|
||||
("/", "/", "/", False, False),
|
||||
("/base", "/base", "/base/", False, False),
|
||||
("/", "/hub", "/hub/", True, False),
|
||||
(None, "hub/api", "/hub/api/", True, False),
|
||||
("/base", "/hub/", "/hub/", True, True),
|
||||
(None, "/hub/api/health", "/hub/api/health/", True, True),
|
||||
],
|
||||
)
|
||||
def test_hub_routespec(
|
||||
base_url, hub_routespec, expected_routespec, should_warn, bad_prefix, caplog
|
||||
):
|
||||
cfg = Config()
|
||||
if base_url:
|
||||
cfg.JupyterHub.base_url = base_url
|
||||
if hub_routespec:
|
||||
cfg.JupyterHub.hub_routespec = hub_routespec
|
||||
with caplog.at_level(logging.WARNING):
|
||||
app = JupyterHub(config=cfg, log=logging.getLogger())
|
||||
app.init_hub()
|
||||
hub = app.hub
|
||||
assert hub.routespec == expected_routespec
|
||||
|
||||
if should_warn:
|
||||
assert "custom route for Hub" in caplog.text
|
||||
assert hub_routespec in caplog.text
|
||||
else:
|
||||
assert "custom route for Hub" not in caplog.text
|
||||
|
||||
if bad_prefix:
|
||||
assert "may not receive" in caplog.text
|
||||
else:
|
||||
assert "may not receive" not in caplog.text
|
||||
|
Reference in New Issue
Block a user