Skip to content

Commit 92ad802

Browse files
committed
test: add e2e tests requesting live api
1 parent 6c54e4b commit 92ad802

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

.github/workflows/e2e_test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: End-to-end tests
2+
3+
on:
4+
schedule:
5+
# run once a month at midnight of the first day of the month
6+
- cron: 0 0 1 * *
7+
workflow_dispatch: # run manually from actions tab
8+
9+
# Set permissions at the job level.
10+
permissions: {}
11+
12+
env:
13+
PYTHONUNBUFFERED: 1
14+
FORCE_COLOR: 1
15+
UV_LOCKED: true # do not update the lockfile during `uv sync` and `uv run` commands
16+
17+
jobs:
18+
test:
19+
name: Python ${{ matrix.python-version }}
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- name: Set up just
23+
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
24+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
- name: Set up uv
26+
uses: astral-sh/setup-uv@f94ec6bedd8674c4426838e6b50417d36b6ab231 # v5.3.1
27+
with:
28+
python-version: '3.13'
29+
enable-cache: true
30+
prune-cache: false
31+
- name: Install project, including dev dependencies
32+
run: just sync
33+
- name: Run e2e tests
34+
run: just e2e-test

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
run: just cov
3535
env:
3636
TERM: dumb # keep rich from printing escape sequences, which made testing CLI outputs messy
37+
- name: Run e2e tests
38+
run: just e2e-test
39+
if: matrix.python-version == '3.13'
3740
- name: Generate coverage report
3841
run: |
3942
export TOTAL_COV=$(hatch run cov-total)

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ check: lint typecheck
3131
test:
3232
uv run pytest tests
3333

34+
[group('test')]
35+
e2e-test:
36+
uv run pytest -m e2e
37+
3438
[group('test')]
3539
cov:
3640
uv run pytest --cov=src

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ addopts = [
170170
"--showlocals",
171171
"--strict-markers",
172172
"--strict-config",
173+
"-m not e2e", # default behaviour: do not run e2e tests
173174
]
174175
asyncio_mode = "auto"
175176
filterwarnings = [
@@ -178,6 +179,9 @@ filterwarnings = [
178179
log_cli_level = "INFO"
179180
xfail_strict = true
180181
testpaths = "tests"
182+
markers = [
183+
"e2e: marks tests as end-to-end tests, requesting the live api",
184+
]
181185

182186
[tool.coverage.run] # Ref: https://coverage.readthedocs.io/en/latest/config.html
183187
branch = true

tests/e2e/test_live_api.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-FileCopyrightText: 2025 Heinz-Alexander Fütterer
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
from __future__ import annotations
6+
7+
import pytest
8+
9+
import re3data
10+
from re3data._resources import Repository, RepositoryName, RepositorySummary
11+
12+
pytestmark = pytest.mark.e2e
13+
14+
15+
def test_get_single_repository(zenodo_id: str) -> None:
16+
response = re3data.repositories.get(zenodo_id)
17+
assert isinstance(response, Repository)
18+
assert response.id == zenodo_id
19+
assert isinstance(response.repository_name, RepositoryName)
20+
assert response.repository_name.value == "Zenodo"
21+
22+
23+
def test_list_repositories_query_string() -> None:
24+
response = re3data.repositories.list(query="biosharing")
25+
assert isinstance(response, list)
26+
assert isinstance(response[0], RepositorySummary)

0 commit comments

Comments
 (0)