-
Notifications
You must be signed in to change notification settings - Fork 4
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 #355 from StochSS/system-testing
System testing
- Loading branch information
Showing
13 changed files
with
176 additions
and
7 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,30 @@ | ||
name: Run SpatialPy System Tests | ||
|
||
on: | ||
push: | ||
branches: [staging, develop] | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest ] | ||
|
||
steps: | ||
- name: Initialize environment | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.7' | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install -r requirements.txt | ||
python3 -m pip install coverage | ||
- name: Run tests | ||
run: coverage run --source=spatialpy test/run_system_tests.py |
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
Empty file.
Empty file.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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,50 @@ | ||
# SpatialPy is a Python 3 package for simulation of | ||
# spatial deterministic/stochastic reaction-diffusion-advection problems | ||
# Copyright (C) 2019 - 2023 SpatialPy developers. | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as | ||
# published by the Free Software Foundation. | ||
|
||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU GENERAL PUBLIC LICENSE Version 3 for more details. | ||
|
||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
''' spatialpy model file for the spatial birth death example. ''' | ||
import spatialpy | ||
|
||
def create_birth_death(): | ||
''' Create the spatial birth death model. ''' | ||
model = spatialpy.Model(name='Spatial Birth-Death') | ||
|
||
model.HABITAT = "Habitat" | ||
|
||
domain = spatialpy.Domain.create_2D_domain( | ||
xlim=(0, 1), ylim=(0, 1), numx=10, numy=10, type_id=model.HABITAT, fixed=True | ||
) | ||
model.add_domain(domain) | ||
|
||
rabbits = spatialpy.Species(name='Rabbits', diffusion_coefficient=0.1) | ||
model.add_species(rabbits) | ||
|
||
init_rabbit_pop = spatialpy.ScatterInitialCondition(species='Rabbits', count=100) | ||
model.add_initial_condition(init_rabbit_pop) | ||
|
||
k_birth = spatialpy.Parameter(name='k_birth', expression=10) | ||
k_death = spatialpy.Parameter(name='k_death', expression=0.1) | ||
model.add_parameter([k_birth, k_death]) | ||
|
||
birth = spatialpy.Reaction( | ||
name='birth', reactants={}, products={"Rabbits":1}, rate="k_birth" | ||
) | ||
death = spatialpy.Reaction( | ||
name='death', reactants={"Rabbits":1}, products={}, rate="k_death" | ||
) | ||
model.add_reaction([birth, death]) | ||
|
||
tspan = spatialpy.TimeSpan.linspace(t=10, num_points=11, timestep_size=1) | ||
model.timespan(tspan) | ||
return model |
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,47 @@ | ||
#!/usr/bin/env python3 | ||
# SpatialPy is a Python 3 package for simulation of | ||
# spatial deterministic/stochastic reaction-diffusion-advection problems | ||
# Copyright (C) 2019 - 2023 SpatialPy developers. | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as | ||
# published by the Free Software Foundation. | ||
|
||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU GENERAL PUBLIC LICENSE Version 3 for more details. | ||
|
||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
''' Testing suite for system tests. ''' | ||
import os | ||
import sys | ||
import unittest | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-m', '--mode', default='develop', choices=['develop', 'release'], | ||
help='Run system tests in develop mode or release mode.') | ||
|
||
if __name__ == '__main__': | ||
args = parser.parse_args() | ||
if args.mode == 'develop': | ||
print('Running system tests in develop mode. Appending repository directory to system path.') | ||
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | ||
|
||
from test.system_tests import test_compiler | ||
|
||
modules = [ | ||
test_compiler | ||
] | ||
|
||
for module in modules: | ||
suite = unittest.TestLoader().loadTestsFromModule(module) | ||
runner = unittest.TextTestRunner(failfast=args.mode == 'develop') | ||
|
||
print(f"Executing: {module}") | ||
result = runner.run(suite) | ||
print('=' * 70) | ||
if not result.wasSuccessful(): | ||
sys.exit(not result.wasSuccessful()) |
Empty file.
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,39 @@ | ||
#!/usr/bin/env python3 | ||
# SpatialPy is a Python 3 package for simulation of | ||
# spatial deterministic/stochastic reaction-diffusion-advection problems | ||
# Copyright (C) 2019 - 2023 SpatialPy developers. | ||
|
||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU GENERAL PUBLIC LICENSE Version 3 as | ||
# published by the Free Software Foundation. | ||
|
||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU GENERAL PUBLIC LICENSE Version 3 for more details. | ||
|
||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
''' Tests from the compiler. ''' | ||
import os | ||
import sys | ||
import unittest | ||
|
||
sys.path.insert(1, os.path.abspath(os.getcwd())) | ||
from test.models.birth_death import create_birth_death # pylint: disable=wrong-import-position | ||
|
||
class TestCompiler(unittest.TestCase): | ||
''' | ||
################################################################################################ | ||
System test for compiler. | ||
################################################################################################ | ||
''' | ||
def setUp(self): | ||
self.model = create_birth_death() | ||
|
||
def test_constructor(self): | ||
""" Test the compiler. """ | ||
_ = self.model.run() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |