From 68c17f65e882c7b069f842a5043b2dccab2b5a09 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 26 Apr 2022 11:23:44 +0200 Subject: [PATCH] add test for custom template opt-in test, only run when --helm is given --- .github/workflows/test.yml | 2 +- binderhub/tests/conftest.py | 23 ++++++++++++++++++++--- binderhub/tests/test_main.py | 9 +++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf37243e95..89f4f2869a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -248,7 +248,7 @@ jobs: if: matrix.test == 'helm' run: | export BINDER_URL=http://localhost:30901 - pytest -m "remote" -v --maxfail=10 --cov binderhub --durations=10 --color=yes + pytest --helm -m "remote" -v --maxfail=10 --cov binderhub --durations=10 --color=yes # GitHub Action reference: https://github.com/jupyterhub/action-k8s-namespace-report - name: Kubernetes namespace report diff --git a/binderhub/tests/conftest.py b/binderhub/tests/conftest.py index f5bcc92afa..cb2aee0291 100644 --- a/binderhub/tests/conftest.py +++ b/binderhub/tests/conftest.py @@ -48,15 +48,32 @@ def pytest_configure(config): config.addinivalue_line( "markers", "auth: mark test to run only on auth environments" ) - config.addinivalue_line( - "markers", "remote: mark test to run only on remote environments" - ) config.addinivalue_line( "markers", "github_api: mark test to run only with GitHub API credentials" ) config.addinivalue_line( "markers", "remote: mark test for when BinderHub is already running somewhere." ) + config.addinivalue_line( + "markers", + "helm: mark test to only run when BinderHub is launched with our k8s-binderhub test config.", + ) + + +def pytest_addoption(parser): + parser.addoption( + "--helm", + action="store_true", + default=False, + help="Run tests marked with pytest.mark.helm", + ) + + +def pytest_runtest_setup(item): + is_helm_test = any(mark for mark in item.iter_markers(name="helm")) + if not item.config.getoption("--helm"): + if is_helm_test: + pytest.skip("Skipping test marked as 'helm'") def pytest_terminal_summary(terminalreporter, exitstatus): diff --git a/binderhub/tests/test_main.py b/binderhub/tests/test_main.py index c29da9fc86..0a9865dfec 100644 --- a/binderhub/tests/test_main.py +++ b/binderhub/tests/test_main.py @@ -83,6 +83,15 @@ async def test_main_page(app): assert r.status_code == 200, f"{r.status_code} {url}" +@pytest.mark.remote +@pytest.mark.helm +async def test_custom_template(app): + """Check that our custom template config is applied via the helm chart""" + r = await async_requests.get(app.url) + assert r.status_code == 200 + assert "test-template" in r.text + + @pytest.mark.remote async def test_about_handler(app): # Check that the about page loads