Skip to content

Commit 24db477

Browse files
authored
test: add e2e tests requesting live api (#271)
Fixes #230
1 parent 0995dea commit 24db477

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: Test
22

33
on:
4+
schedule:
5+
# run once a month at midnight of the first day of the month
6+
- cron: 0 0 1 * *
47
workflow_call:
8+
workflow_dispatch: # run manually from actions tab
59

610
# Set permissions at the job level.
711
permissions: {}
@@ -34,6 +38,9 @@ jobs:
3438
run: just cov
3539
env:
3640
TERM: dumb # keep rich from printing escape sequences, which made testing CLI outputs messy
41+
- name: Run e2e tests
42+
run: just e2e-test
43+
if: matrix.python-version == '3.13'
3744
- name: Generate coverage report
3845
run: |
3946
export TOTAL_COV=$(hatch run cov-total)

justfile

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

36+
[group('test')]
37+
e2e-test:
38+
uv run pytest -m e2e
39+
3640
[group('test')]
3741
cov:
3842
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)