diff --git a/binderhub/tests/test_legacy.py b/binderhub/tests/test_legacy.py new file mode 100644 index 000000000..bb65ef683 --- /dev/null +++ b/binderhub/tests/test_legacy.py @@ -0,0 +1,28 @@ +"""Test legacy redirects""" + +import pytest + +from .utils import async_requests + + +@pytest.mark.parametrize( + "old_url, new_url", + [ + ( + "/repo/binderhub-ci-repos/requirements", + "/v2/gh/binderhub-ci-repos/requirements/master", + ), + ( + "/repo/binderhub-ci-repos/requirements/", + "/v2/gh/binderhub-ci-repos/requirements/master", + ), + ( + "/repo/binderhub-ci-repos/requirements/notebooks/index.ipynb", + "/v2/gh/binderhub-ci-repos/requirements/master?urlpath=%2Fnotebooks%2Findex.ipynb", + ), + ], +) +async def test_legacy_redirect(app, old_url, new_url): + r = await async_requests.get(app.url + old_url, allow_redirects=False) + assert r.status_code == 302 + assert r.headers["location"] == new_url diff --git a/binderhub/tests/test_main.py b/binderhub/tests/test_main.py index 4b56aa4ac..1201e3f41 100644 --- a/binderhub/tests/test_main.py +++ b/binderhub/tests/test_main.py @@ -7,34 +7,9 @@ import pytest from bs4 import BeautifulSoup -from binderhub import __version__ as binder_version - from .utils import async_requests -@pytest.mark.parametrize( - "old_url, new_url", - [ - ( - "/repo/binderhub-ci-repos/requirements", - "/v2/gh/binderhub-ci-repos/requirements/master", - ), - ( - "/repo/binderhub-ci-repos/requirements/", - "/v2/gh/binderhub-ci-repos/requirements/master", - ), - ( - "/repo/binderhub-ci-repos/requirements/notebooks/index.ipynb", - "/v2/gh/binderhub-ci-repos/requirements/master?urlpath=%2Fnotebooks%2Findex.ipynb", - ), - ], -) -async def test_legacy_redirect(app, old_url, new_url): - r = await async_requests.get(app.url + old_url, allow_redirects=False) - assert r.status_code == 302 - assert r.headers["location"] == new_url - - @pytest.mark.remote @pytest.mark.helm async def test_custom_template(app): @@ -44,26 +19,6 @@ async def test_custom_template(app): assert "test-template" in r.text -@pytest.mark.remote -async def test_versions_handler(app): - # Check that the about page loads - r = await async_requests.get(app.url + "/versions") - assert r.status_code == 200 - - data = r.json() - # builder_info is different for KubernetesExecutor and LocalRepo2dockerBuild - try: - import repo2docker - - allowed_builder_info = [{"repo2docker-version": repo2docker.__version__}] - except ImportError: - allowed_builder_info = [] - allowed_builder_info.append({"build_image": app.build_image}) - - assert data["builder_info"] in allowed_builder_info - assert data["binderhub"].split("+")[0] == binder_version.split("+")[0] - - @pytest.mark.parametrize( "origin,host,expected_origin", [ diff --git a/binderhub/tests/test_version.py b/binderhub/tests/test_version.py new file mode 100644 index 000000000..65037f497 --- /dev/null +++ b/binderhub/tests/test_version.py @@ -0,0 +1,27 @@ +"""Test version handler""" + +import pytest + +from binderhub import __version__ as binder_version + +from .utils import async_requests + + +@pytest.mark.remote +async def test_versions_handler(app): + # Check that the about page loads + r = await async_requests.get(app.url + "/versions") + assert r.status_code == 200 + + data = r.json() + # builder_info is different for KubernetesExecutor and LocalRepo2dockerBuild + try: + import repo2docker + + allowed_builder_info = [{"repo2docker-version": repo2docker.__version__}] + except ImportError: + allowed_builder_info = [] + allowed_builder_info.append({"build_image": app.build_image}) + + assert data["builder_info"] in allowed_builder_info + assert data["binderhub"].split("+")[0] == binder_version.split("+")[0]