Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Commit 6465782

Browse files
authored
Merge pull request #76 from MDverse/add-tests-in-ci
test: Mark network as 'network', hence slow
2 parents cbf69fb + 9011c5f commit 6465782

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,30 @@ jobs:
2121

2222
- name: Install Python
2323
run: uv python install
24-
24+
2525
- name: Install python dependencies
2626
run: uv sync --locked --dev
2727

2828
- name: Run pre-commit hooks
2929
run: uv run prek
30+
31+
tests:
32+
runs-on: ubuntu-24.04
33+
timeout-minutes: 15
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v6
37+
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@v7
40+
with:
41+
enable-cache: true
42+
43+
- name: Install Python
44+
run: uv python install
45+
46+
- name: Install python dependencies
47+
run: uv sync --locked --dev
48+
49+
- name: Run tests
50+
run: uv run pytest -m "not network"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
uv sync --dev
2525
```
2626

27-
6. Install pre-commit hook:
27+
6. Install pre-commit hooks:
2828

2929
```sh
3030
uv run prek install

pytest.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[pytest]
2+
addopts = ["--strict-markers"]
3+
markers = [
4+
"network: network tests that require internet access and could be slow",
5+
]

tests/core/test_network.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import json
44

5+
import pytest
6+
57
import mdverse_scrapers.core.network as network
68
import mdverse_scrapers.core.toolbox as toolbox
79
from mdverse_scrapers.core.logger import create_logger
810

911

12+
@pytest.mark.network
1013
def test_make_http_get_request_with_retries_200():
1114
"""Test the make_http_get_request_with_retries function."""
1215
url = "https://httpbin.org/get"
@@ -20,6 +23,7 @@ def test_make_http_get_request_with_retries_200():
2023
assert response.status_code == 200
2124

2225

26+
@pytest.mark.network
2327
def test_make_http_get_request_with_retries_202():
2428
"""Test the make_http_get_request_with_retries function."""
2529
url = "https://httpbin.org/status/202"
@@ -32,6 +36,7 @@ def test_make_http_get_request_with_retries_202():
3236
assert response is None
3337

3438

39+
@pytest.mark.network
3540
def test_make_http_get_request_with_retries_404():
3641
"""Test the make_http_get_request_with_retries function."""
3742
url = "https://httpbin.org/status/404"
@@ -44,8 +49,9 @@ def test_make_http_get_request_with_retries_404():
4449
assert response is None
4550

4651

52+
@pytest.mark.network
4753
def test_get_html_page_with_selenium_good_url():
48-
"""Test the get_html_page_with_selenium function with a bad URL."""
54+
"""Test the get_html_page_with_selenium function with a good URL."""
4955
url = "https://figshare.com/ndownloader/files/21988230/preview/21988230/structure.json"
5056
expected_json = {
5157
"files": [],
@@ -67,6 +73,7 @@ def test_get_html_page_with_selenium_good_url():
6773
assert json.loads(content) == expected_json
6874

6975

76+
@pytest.mark.network
7077
def test_get_html_page_with_selenium_bad_url(capsys) -> None:
7178
"""Test the get_html_page_with_selenium function with a bad URL."""
7279
url = "https://figshare.com/ndownloader/files/28089615/preview/28089615/structure.json"

0 commit comments

Comments
 (0)