From 4288f5b307a833070f0dcb4a5e12e7add6ae7891 Mon Sep 17 00:00:00 2001 From: Pierre Poulain Date: Tue, 27 Jan 2026 18:57:34 +0100 Subject: [PATCH 1/5] test: Mark network as 'network', hence slow --- pytest.toml | 5 +++++ tests/core/test_network.py | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 pytest.toml diff --git a/pytest.toml b/pytest.toml new file mode 100644 index 0000000..6240b87 --- /dev/null +++ b/pytest.toml @@ -0,0 +1,5 @@ +[pytest] +addopts = ["--strict-markers"] +markers = [ + "network: network tests that require internet access and could be slow", +] diff --git a/tests/core/test_network.py b/tests/core/test_network.py index 1c45306..d321cfc 100644 --- a/tests/core/test_network.py +++ b/tests/core/test_network.py @@ -2,11 +2,14 @@ import json +import pytest + import mdverse_scrapers.core.network as network import mdverse_scrapers.core.toolbox as toolbox from mdverse_scrapers.core.logger import create_logger +@pytest.mark.network def test_make_http_get_request_with_retries_200(): """Test the make_http_get_request_with_retries function.""" url = "https://httpbin.org/get" @@ -20,6 +23,7 @@ def test_make_http_get_request_with_retries_200(): assert response.status_code == 200 +@pytest.mark.network def test_make_http_get_request_with_retries_202(): """Test the make_http_get_request_with_retries function.""" url = "https://httpbin.org/status/202" @@ -32,6 +36,7 @@ def test_make_http_get_request_with_retries_202(): assert response is None +@pytest.mark.network def test_make_http_get_request_with_retries_404(): """Test the make_http_get_request_with_retries function.""" url = "https://httpbin.org/status/404" @@ -44,6 +49,7 @@ def test_make_http_get_request_with_retries_404(): assert response is None +@pytest.mark.network def test_get_html_page_with_selenium_good_url(): """Test the get_html_page_with_selenium function with a bad URL.""" url = "https://figshare.com/ndownloader/files/21988230/preview/21988230/structure.json" @@ -67,6 +73,7 @@ def test_get_html_page_with_selenium_good_url(): assert json.loads(content) == expected_json +@pytest.mark.network def test_get_html_page_with_selenium_bad_url(capsys) -> None: """Test the get_html_page_with_selenium function with a bad URL.""" url = "https://figshare.com/ndownloader/files/28089615/preview/28089615/structure.json" From 122ec683ec76487d5cf3028279ad0a64d6c71244 Mon Sep 17 00:00:00 2001 From: Pierre Poulain Date: Tue, 27 Jan 2026 18:59:36 +0100 Subject: [PATCH 2/5] test: Add tests into CI --- .github/workflows/ci.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d35e57b..793a40c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,9 +21,30 @@ jobs: - name: Install Python run: uv python install - + - name: Install python dependencies run: uv sync --locked --dev - name: Run pre-commit hooks run: uv run prek + + tests: + runs-on: ubuntu-24.04 + timeout-minutes: 15 + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + enable-cache: true + + - name: Install Python + run: uv python install + + - name: Install python dependencies + run: uv sync --locked --dev + + - name: Run pre-commit hooks + run: uv run pytest -m "not network" From 0135869771da335eab83c40bedf81141f1f74466 Mon Sep 17 00:00:00 2001 From: Pierre Poulain Date: Tue, 27 Jan 2026 19:14:33 +0100 Subject: [PATCH 3/5] test: Update doctring --- tests/core/test_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/test_network.py b/tests/core/test_network.py index d321cfc..7193dba 100644 --- a/tests/core/test_network.py +++ b/tests/core/test_network.py @@ -51,7 +51,7 @@ def test_make_http_get_request_with_retries_404(): @pytest.mark.network def test_get_html_page_with_selenium_good_url(): - """Test the get_html_page_with_selenium function with a bad URL.""" + """Test the get_html_page_with_selenium function with a good URL.""" url = "https://figshare.com/ndownloader/files/21988230/preview/21988230/structure.json" expected_json = { "files": [], From f6e05729a8954db7dc1dfa0b6d34c59790dd88b4 Mon Sep 17 00:00:00 2001 From: Pierre Poulain Date: Tue, 27 Jan 2026 19:20:06 +0100 Subject: [PATCH 4/5] docs: Fix typo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ea1db97..8883865 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -24,7 +24,7 @@ uv sync --dev ``` -6. Install pre-commit hook: +6. Install pre-commit hooks: ```sh uv run prek install From 9011c5f4f76f4bac33f755a3c0ccdaae62e9573a Mon Sep 17 00:00:00 2001 From: Pierre Poulain Date: Tue, 27 Jan 2026 19:20:26 +0100 Subject: [PATCH 5/5] test: Fix name step in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 793a40c..7380c29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,5 +46,5 @@ jobs: - name: Install python dependencies run: uv sync --locked --dev - - name: Run pre-commit hooks + - name: Run tests run: uv run pytest -m "not network"