Skip to content

Commit

Permalink
add test for custom template
Browse files Browse the repository at this point in the history
opt-in test, only run when --helm is given
  • Loading branch information
minrk committed Apr 26, 2022
1 parent fa071b4 commit e87e25a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions binderhub/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,23 @@ 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_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):
Expand Down
9 changes: 9 additions & 0 deletions binderhub/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""top-level pytest config
options can only be defined here,
not in binderhub/tests/conftest.py
"""


def pytest_addoption(parser):
parser.addoption(
"--helm",
action="store_true",
default=False,
help="Run tests marked with pytest.mark.helm",
)

0 comments on commit e87e25a

Please sign in to comment.