Skip to content

Commit 1a3a5ce

Browse files
committed
add github actions
1 parent 5c00cb9 commit 1a3a5ce

4 files changed

Lines changed: 81 additions & 12 deletions

File tree

.github/workflows/main.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: CI
2+
3+
# We can specify which Github events will trigger a CI build
4+
on: push
5+
6+
# now define a single job 'build' (but could define more)
7+
jobs:
8+
9+
build:
10+
11+
# we can also specify the OS to run tests on
12+
runs-on: ubuntu-latest
13+
14+
# a job is a seq of steps
15+
steps:
16+
17+
# Next we need to checkout out repository, and set up Python
18+
# A 'name' is just an optional label shown in the log - helpful to clarify progress - and can be anything
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python 3.11
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.11"
26+
27+
- name: Install Python dependencies
28+
run: |
29+
python3 -m pip install --upgrade pip
30+
python3 -m pip install -r requirements.txt
31+
32+
- name: Test with PyTest
33+
run: |
34+
python3 -m pytest --cov=inflammation.models tests/test_models.py

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
astroid==3.3.5
22
colorama==0.4.6
33
contourpy==1.3.1
4+
coverage==7.6.8
45
cycler==0.12.1
56
dill==0.3.9
67
fonttools==4.55.0
@@ -17,6 +18,7 @@ pluggy==1.5.0
1718
pylint==3.3.1
1819
pyparsing==3.2.0
1920
pytest==8.3.3
21+
pytest-cov==6.0.0
2022
python-dateutil==2.9.0.post0
2123
six==1.16.0
2224
tomlkit==0.13.2

tests/test_models.py

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@
22

33
import numpy as np
44
import numpy.testing as npt
5+
import pytest
56

6-
from inflammation.models import daily_mean
7+
from inflammation.models import daily_mean, daily_max, daily_min
78

8-
def test_daily_mean_zeros():
9+
@pytest.mark.parametrize(
10+
"test, expected",
11+
[
12+
([[0,0],[0,0],[0,0]],[0,0]),
13+
([[0, 0],[0, 0],[0, 0]], [0, 0]),
14+
([[-1, -1],[-1, -1],[-1, -1]],[-1, -1]),
15+
([[1, 2],[3, 4],[5, 6]],[3, 4]),
16+
([[1, 2],[3, 4],[5, 6]], [6, 7])
17+
]
18+
)
19+
#not sure why pytest seems to be required here. error says it should be test but doesn't seem to work
20+
def pytest_daily_mean_zeros():
921
"""Test that mean function works for an array of zeros."""
1022

1123
test_input = np.array([[0, 0],
@@ -46,3 +58,34 @@ def test_daily_mean():
4658
test_result = np.array([3, 4])
4759

4860
npt.assert_array_equal(daily_mean(test_input), test_result)
61+
"""
62+
def test_daily_mean_string():
63+
test_input = np.array([["this is something incorrect", 2],
64+
[3, 4],
65+
[5, 6]])
66+
test_result = np.array([3, 4])
67+
68+
npt.assert_array_equal(daily_mean(test_input), test_result)
69+
"""
70+
71+
72+
"""
73+
def test_daily_min_string():
74+
#test for typeerror when passing strings
75+
76+
#with pytest.raises(TypeError):
77+
# error_expected = daily_min([["one", "two"],["3","4"]])
78+
"""
79+
80+
81+
"""Tests for the Patient model - class/file in this folder
82+
83+
from inflammation.models import Patient
84+
85+
def test_create_patient():
86+
87+
name = 'Alice'
88+
p = Patient(name=name)
89+
90+
assert p.name == name
91+
"""

tests/test_patient.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)