Skip to content

Commit f8ebef7

Browse files
author
thomasZen
committed
Add a test github workflow
1 parent 0ae992b commit f8ebef7

File tree

3 files changed

+42
-9
lines changed

3 files changed

+42
-9
lines changed

.github/workflows/unit-tests.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
unit-tests:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.10"
21+
22+
- name: Install uv
23+
run: |
24+
curl -LsSf https://astral.sh/uv/install.sh | sh
25+
echo "${HOME}/.local/bin" >> $GITHUB_PATH
26+
27+
- name: Install openretina with dependencies
28+
run: |
29+
uv sync --extra dev
30+
uv pip install pytest
31+
32+
- name: Run Unit Tests
33+
run: make test-unittests

tests/test_data.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import pytest
12
import numpy as np
23

34
from gcl_classifier.data import load_data, prepare_baden_data
45

56

67
class TestDataLoader:
78

8-
def test_model_load(self, force_download=True):
9-
"""Test that data downloads without errors."""
9+
10+
@pytest.mark.parametrize("force_download", [True, False])
11+
def test_data_load(self, force_download: bool):
12+
"""Test that data downloads without errors with both force_download options."""
1013
data = load_data(force_download=force_download)
1114
assert data is not None
1215
assert isinstance(data, dict)
@@ -17,9 +20,6 @@ def test_model_load(self, force_download=True):
1720
assert isinstance(data['bar_feats'], np.ndarray)
1821
assert isinstance(data['chirp_feats'], np.ndarray)
1922

20-
def test_model_load_from_cache(self):
21-
self.test_model_load(force_download=False)
22-
2323
def test_extract_baden_data(self):
2424
"""Test that data extracts without errors."""
2525
data = load_data(force_download=False)

tests/test_model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from gcl_classifier.model import load_model
1+
from gcl_classifier.model import load_model, get_model
22

33

44
class TestModelLoader:
@@ -10,18 +10,18 @@ def test_model_download(self):
1010

1111
def test_model_load(self):
1212
"""Test that model loads without errors."""
13-
model, model_dict = load_model(force_download=False)
13+
model = get_model()
1414
assert model is not None
1515

1616
def test_model_type(self):
1717
"""Test that loaded model is correct type."""
1818
from sklearn.calibration import CalibratedClassifierCV
19-
model, model_dict = load_model(force_download=False)
19+
model = get_model()
2020
assert isinstance(model, CalibratedClassifierCV)
2121

2222
def test_model_has_predict_methods(self):
2323
"""Test that model has required methods."""
24-
model, model_dict = load_model(force_download=False)
24+
model = get_model()
2525
assert hasattr(model, 'predict')
2626
assert hasattr(model, 'predict_proba')
2727
assert callable(model.predict)

0 commit comments

Comments
 (0)