diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 495f357..a0514b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,11 @@ name: Test on: + schedule: + # run once a month at midnight of the first day of the month + - cron: 0 0 1 * * workflow_call: + workflow_dispatch: # run manually from actions tab # Set permissions at the job level. permissions: {} @@ -34,6 +38,9 @@ jobs: run: just cov env: TERM: dumb # keep rich from printing escape sequences, which made testing CLI outputs messy + - name: Run e2e tests + run: just e2e-test + if: matrix.python-version == '3.13' - name: Generate coverage report run: | export TOTAL_COV=$(hatch run cov-total) diff --git a/justfile b/justfile index 8f86dbd..bb38809 100644 --- a/justfile +++ b/justfile @@ -33,6 +33,10 @@ check: lint typecheck test: uv run pytest tests +[group('test')] +e2e-test: + uv run pytest -m e2e + [group('test')] cov: uv run pytest --cov=src diff --git a/pyproject.toml b/pyproject.toml index 5b2892d..8601f4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -170,6 +170,7 @@ addopts = [ "--showlocals", "--strict-markers", "--strict-config", + "-m not e2e", # default behaviour: do not run e2e tests ] asyncio_mode = "auto" filterwarnings = [ @@ -178,6 +179,9 @@ filterwarnings = [ log_cli_level = "INFO" xfail_strict = true testpaths = "tests" +markers = [ + "e2e: marks tests as end-to-end tests, requesting the live api", +] [tool.coverage.run] # Ref: https://coverage.readthedocs.io/en/latest/config.html branch = true diff --git a/tests/e2e/test_live_api.py b/tests/e2e/test_live_api.py new file mode 100644 index 0000000..0e08b50 --- /dev/null +++ b/tests/e2e/test_live_api.py @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2025 Heinz-Alexander Fütterer +# +# SPDX-License-Identifier: MIT + +from __future__ import annotations + +import pytest + +import re3data +from re3data._resources import Repository, RepositoryName, RepositorySummary + +pytestmark = pytest.mark.e2e + + +def test_get_single_repository(zenodo_id: str) -> None: + response = re3data.repositories.get(zenodo_id) + assert isinstance(response, Repository) + assert response.id == zenodo_id + assert isinstance(response.repository_name, RepositoryName) + assert response.repository_name.value == "Zenodo" + + +def test_list_repositories_query_string() -> None: + response = re3data.repositories.list(query="biosharing") + assert isinstance(response, list) + assert isinstance(response[0], RepositorySummary)