Skip to content

Commit 14ee301

Browse files
committed
[test] add unit test in ci workflow
1 parent 9b21ff1 commit 14ee301

21 files changed

Lines changed: 536 additions & 54 deletions

.github/workflows/docker.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,32 @@ on:
77
- actions
88

99
jobs:
10+
unit_tests:
11+
name: Unit Tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.10'
20+
cache: 'pip'
21+
22+
- name: Install test dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -e .
26+
pip install pytest
27+
28+
- name: Run unit tests
29+
run: |
30+
python -m pytest tests/unit -q
31+
1032
publish_package:
1133
name: Build and Publish
1234
runs-on: ubuntu-latest
35+
needs: unit_tests
1336

1437
steps:
1538
- uses: actions/checkout@v3

pyproject.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
[tool.pytest.ini_options]
2-
testpaths = ["tests"]
3-
addopts = "-ra"
4-
pythonpath = ["."]
2+
testpaths = ["tests/unit"]
3+
addopts = "-ra --strict-markers"
4+
pythonpath = [".", "tests/cases"]
5+
markers = [
6+
"network: tests that require external network access",
7+
"case: end-to-end usage cases that may train, predict, or download assets",
8+
"integration: tests that exercise multiple subsystems together",
9+
"slow: tests that are expected to take longer than unit tests",
10+
]

tests/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Test Layout
2+
3+
The test suite is split by purpose:
4+
5+
- `unit/`: fast, deterministic tests that run locally without downloading data or model weights. This is the default pytest target.
6+
- `cases/`: end-to-end usage cases for training, prediction, representation extraction, and dataset/model downloads. These are not run by default.
7+
8+
Run the default unit tests:
9+
10+
```bash
11+
python -m pytest
12+
```
13+
14+
Run the case tests without network access. Network-dependent tests will be collected but skipped:
15+
16+
```bash
17+
python -m pytest tests/cases
18+
```
19+
20+
Run network-dependent cases explicitly:
21+
22+
```bash
23+
python -m pytest tests/cases --run-network
24+
```
25+
26+
Markers:
27+
28+
- `network`: requires external network access.
29+
- `case`: user-facing end-to-end usage case.
30+
- `integration`: exercises multiple subsystems together.
31+
- `slow`: expected to take longer than unit tests.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from unimol_tools import MolTrain, MolPredict
88

9+
pytestmark = [pytest.mark.case, pytest.mark.integration, pytest.mark.slow]
10+
911
DATA_URL = 'https://weilab.math.msu.edu/DataLibrary/2D/Downloads/Ames_smi.zip'
1012

1113

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from unimol_tools import MolTrain, MolPredict
99

10+
pytestmark = [pytest.mark.case, pytest.mark.integration, pytest.mark.slow]
11+
1012
DATA_URL = 'https://weilab.math.msu.edu/DataLibrary/2D/Downloads/ESOL_smi.zip'
1113

1214

tests/test_multilabel_classification.py renamed to tests/cases/test_multilabel_classification.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
from unimol_tools import MolTrain, MolPredict
1010

11+
pytestmark = [pytest.mark.case, pytest.mark.integration, pytest.mark.slow]
12+
1113
CSV_URL = 'https://deepchemdata.s3-us-west-1.amazonaws.com/datasets/tox21.csv.gz'
1214
SDF_URL = 'https://tripod.nih.gov/tox21/challenge/download?id=tox21_10k_data_allsdf'
1315

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from unimol_tools import MolTrain, MolPredict
99

10+
pytestmark = [pytest.mark.case, pytest.mark.integration, pytest.mark.slow]
11+
1012
DATA_URL = 'https://weilab.math.msu.edu/DataLibrary/2D/Downloads/FreeSolv_smi.zip'
1113

1214

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from unimol_tools import MolTrain, MolPredict
88

9+
pytestmark = [pytest.mark.case, pytest.mark.integration, pytest.mark.slow]
10+
911
ESOL_TRAIN_URL = 'https://huggingface.co/datasets/HR-machine/ESol/resolve/main/train_data.csv?download=true'
1012
ESOL_TEST_URL = 'https://huggingface.co/datasets/HR-machine/ESol/resolve/main/test_data.csv?download=true'
1113
VQM24_URL = 'https://zenodo.org/records/15442257/files/DMC.npz?download=1'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
from unimol_tools import UniMolRepr
1010

11+
pytestmark = [pytest.mark.case, pytest.mark.integration, pytest.mark.slow]
12+
1113
VQM24_URL = 'https://zenodo.org/records/15442257/files/DMC.npz?download=1'
1214
TOX21_CSV_URL = 'https://deepchemdata.s3-us-west-1.amazonaws.com/datasets/tox21.csv.gz'
1315
TOX21_SDF_URL = 'https://tripod.nih.gov/tox21/challenge/download?id=tox21_10k_data_allsdf'

0 commit comments

Comments
 (0)