-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from RangamaniLabUCSD/finsberg/add-first-tests
Add first unit tests
- Loading branch information
Showing
10 changed files
with
277 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Run examples | ||
|
||
on: | ||
push: | ||
# The CI is executed on every push on every branch | ||
branches: | ||
- development | ||
pull_request: | ||
# The CI is executed on every pull request to the main branch | ||
branches: | ||
- development | ||
|
||
schedule: | ||
# The CI is executed every day at 8am | ||
- cron: "0 8 * * *" | ||
jobs: | ||
check-code: | ||
runs-on: ubuntu-22.04 | ||
# Runs against FEniCS main branch built the 16-01-2023 | ||
container: ghcr.io/scientificcomputing/fenics-gmsh:2023-02-17a | ||
steps: | ||
# This action sets the current path to the root of your github repo | ||
- uses: actions/checkout@v3 | ||
|
||
- name: "Install code" | ||
run: python3 -m pip install --no-binary=h5py .[dev] jupytext | ||
|
||
- name: Run example 1 | ||
run: | | ||
cd examples/example1/ | ||
jupytext example1.ipynb --to py | ||
python3 example1.py | ||
# - name: Run tests | ||
# run: | | ||
# cd tests/ | ||
# python3 -m pytest . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[pytest] | ||
addopts = --cov=stubs --cov-report html --cov-report term-missing -v | ||
testpaths = | ||
tests | ||
integration | ||
markers = | ||
stubs_model_init: tests for model initialiation (deselect with '-m "not slow"') | ||
filterwarnings = | ||
ignore::UserWarning | ||
ignore::DeprecationWarning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import pytest | ||
|
||
import stubs | ||
|
||
|
||
@pytest.fixture(name="Cyto_kwargs") | ||
def example_compartment(): | ||
kwargs = dict( | ||
dimensionality=3, | ||
name="Cyto", | ||
compartment_units=stubs.unit.um, | ||
cell_marker=1, | ||
) | ||
|
||
Cyto = stubs.model_assembly.Compartment(**kwargs) | ||
return (Cyto, kwargs) | ||
|
||
|
||
def test_Compartment_initialization(Cyto_kwargs): | ||
Cyto, kwargs = Cyto_kwargs | ||
|
||
assert Cyto.V is None | ||
assert Cyto.cell_marker == kwargs["cell_marker"] | ||
assert Cyto.dimensionality == kwargs["dimensionality"] | ||
assert Cyto.name == kwargs["name"] | ||
assert Cyto.num_dofs == 0 | ||
assert Cyto.num_dofs_local == 0 | ||
assert Cyto.species == {} | ||
assert Cyto.u == {} | ||
assert Cyto.v is None | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_Compartment_access_dolfin_mesh(Cyto_kwargs): | ||
Cyto, kwargs = Cyto_kwargs | ||
Cyto.dolfin_mesh | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_Compartment_access_mesh_id(Cyto_kwargs): | ||
Cyto, kwargs = Cyto_kwargs | ||
Cyto.mesh_id | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_Compartment_access_num_cells(Cyto_kwargs): | ||
Cyto, kwargs = Cyto_kwargs | ||
Cyto.num_cells | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_Compartment_access_num_facets(Cyto_kwargs): | ||
Cyto, kwargs = Cyto_kwargs | ||
Cyto.num_facets | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_Compartment_access_num_vertices(Cyto_kwargs): | ||
Cyto, kwargs = Cyto_kwargs | ||
Cyto.num_vertices | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_Compartment_access_nvolume(Cyto_kwargs): | ||
Cyto, kwargs = Cyto_kwargs | ||
Cyto.nvolume |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import math | ||
|
||
import pytest | ||
|
||
import stubs | ||
|
||
|
||
@pytest.fixture(name="A_kwargs") | ||
def example_species(): | ||
kwargs = dict( | ||
concentration_units=stubs.unit.uM, | ||
diffusion_units=stubs.unit.um**2 / stubs.unit.sec, | ||
initial_condition=0.01, | ||
D=2.0, | ||
name="A", | ||
compartment_name="Cyto", | ||
group="Some group", | ||
) | ||
|
||
A = stubs.model_assembly.Species(**kwargs) | ||
return (A, kwargs) | ||
|
||
|
||
def test_Species_initialization(A_kwargs): | ||
A, kwargs = A_kwargs | ||
assert A.name == kwargs["name"] | ||
assert A.latex_name == kwargs["name"] | ||
assert str(A.sym) == kwargs["name"] | ||
|
||
assert math.isclose(A.initial_condition, kwargs["initial_condition"]) | ||
assert ( | ||
A.initial_condition_quantity | ||
== kwargs["initial_condition"] * kwargs["concentration_units"] | ||
) | ||
assert A.concentration_units == stubs.common.pint_unit_to_quantity( | ||
kwargs["concentration_units"] | ||
) | ||
assert math.isclose(A.D, kwargs["D"]) | ||
assert A.diffusion_units == stubs.common.pint_unit_to_quantity( | ||
kwargs["diffusion_units"] | ||
) | ||
assert A.D_quantity == kwargs["D"] * kwargs["diffusion_units"] | ||
|
||
assert A.compartment_name == kwargs["compartment_name"] | ||
assert A.group == kwargs["group"] | ||
assert A.dof_map is None | ||
assert A.ut is None | ||
assert A.v is None | ||
assert A.u == {} | ||
assert A.is_an_added_species is False | ||
assert A.is_in_a_reaction is False | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_access_vscalar(A_kwargs): | ||
A, kwargs = A_kwargs | ||
# We should have proper error handling here | ||
A.vscalar | ||
|
||
|
||
@pytest.mark.xfail | ||
def test_access_dolfin_quatity(A_kwargs): | ||
A, kwargs = A_kwargs | ||
# We should have proper error handling here | ||
A.dolfin_quantity |
Oops, something went wrong.