-
Notifications
You must be signed in to change notification settings - Fork 21
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 #1445 from StochSS/testing-refactor
Testing Refactor
- Loading branch information
Showing
17 changed files
with
746 additions
and
543 deletions.
There are no files selected for viewing
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,23 @@ | ||
name: Run StochSS Integration Tests | ||
|
||
on: | ||
push: | ||
branches: [main, develop] | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-20.04 ] | ||
|
||
steps: | ||
- name: Initialize environment | ||
id: checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run Integration Tests | ||
id: run_integration_tests | ||
uses: ./ | ||
with: | ||
testin: '/stochss/stochss/tests/run_integration_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Run StochSS Unit Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-20.04 ] | ||
|
||
steps: | ||
- name: Initialize environment | ||
id: checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run Unit Tests | ||
id: run_unit_tests | ||
uses: ./ | ||
with: | ||
testin: '/stochss/stochss/tests/run_unit_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.
Large diffs are not rendered by default.
Oops, something went wrong.
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,158 @@ | ||
''' | ||
StochSS is a platform for simulating biochemical systems | ||
Copyright (C) 2019-2023 StochSS developers. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
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 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/>. | ||
''' | ||
import os | ||
import unittest | ||
|
||
import gillespy2 | ||
|
||
from example_models import ( | ||
create_vilar_oscillator, create_dimerization, create_trichloroethylene, create_lac_operon, create_schlogl, | ||
create_michaelis_menten, create_toggle_switch, create_decay, create_tyson_2_state_oscillator, | ||
create_oregonator, create_opioid, create_telegraph_model | ||
) | ||
|
||
os.chdir('/stochss') | ||
|
||
# pylint: disable=import-outside-toplevel | ||
class TestGillesPy2Dependency(unittest.TestCase): | ||
''' | ||
#################################################################################################################### | ||
Unit tests for GillesPy2 dependency. | ||
#################################################################################################################### | ||
''' | ||
def setUp(self): | ||
''' Create a list of common example paths for each test. ''' | ||
self.test_ode_models = [ | ||
create_vilar_oscillator, create_dimerization, create_trichloroethylene, create_lac_operon, create_schlogl, | ||
create_michaelis_menten, create_toggle_switch, create_decay, create_tyson_2_state_oscillator, | ||
create_oregonator, create_opioid, create_telegraph_model | ||
] | ||
self.test_ssa_models = [ | ||
create_vilar_oscillator, create_dimerization, create_trichloroethylene, create_schlogl, | ||
create_michaelis_menten, create_toggle_switch, create_decay, create_tyson_2_state_oscillator, | ||
create_opioid, create_telegraph_model | ||
] | ||
self.test_hybrid_models = [ | ||
create_dimerization, create_trichloroethylene, create_schlogl, create_michaelis_menten, | ||
create_toggle_switch, create_decay, create_opioid, create_telegraph_model | ||
] | ||
|
||
#################################################################################################################### | ||
# Unit tests for GillesPy2 dependency check_cpp_support. | ||
#################################################################################################################### | ||
|
||
def test_check_cpp_support(self): | ||
''' Check if the check cpp support functions works in StochSS. ''' | ||
from gillespy2.solvers.utilities.cpp_support_test import check_cpp_support | ||
|
||
self.assertIsInstance(check_cpp_support(), bool) | ||
|
||
#################################################################################################################### | ||
# Unit tests for GillesPy2 dependency get_best_solver. | ||
#################################################################################################################### | ||
|
||
def test_get_best_solver(self): | ||
''' Check if the get best solver function works in StochSS. ''' | ||
test_model = self.test_ode_models[0]() | ||
test_solver = test_model.get_best_solver() | ||
self.assertIsInstance(test_solver(model=test_model), gillespy2.GillesPySolver) | ||
|
||
#################################################################################################################### | ||
# Unit tests for GillesPy2 dependency get_best_solver_algo. | ||
#################################################################################################################### | ||
|
||
def test_get_best_solver_algo(self): | ||
''' Check if the get best solver algo function works in StochSS. ''' | ||
test_algos = ["ODE", "SSA", "CLE", "Tau-Leaping", "Tau-Hybrid"] | ||
test_model = self.test_ode_models[0]() | ||
for test_algo in test_algos: | ||
with self.subTest(test_algo=test_algo): | ||
test_solver = test_model.get_best_solver_algo(algorithm=test_algo) | ||
self.assertIsInstance(test_solver(model=test_model), gillespy2.GillesPySolver) | ||
|
||
#################################################################################################################### | ||
# Unit tests for GillesPy2 dependency solvers. | ||
#################################################################################################################### | ||
|
||
def test_ode_solver(self): | ||
''' Check if the test_models run with the ODESolver. ''' | ||
for model in self.test_ode_models: | ||
test_model = model() | ||
msg = f"Running {test_model.name} using {gillespy2.ODESolver.name} failed!" | ||
with self.subTest(msg=msg): | ||
test_model.run(solver=gillespy2.ODESolver, timeout=30) | ||
|
||
def test_ode_c_solver(self): | ||
''' Check if the test_models run with the ODECSolver. ''' | ||
for model in self.test_ode_models: | ||
test_model = model() | ||
test_solver = gillespy2.ODECSolver(model=test_model) | ||
msg = f"Running {test_model.name} using {gillespy2.ODECSolver.name} failed!" | ||
with self.subTest(msg=msg): | ||
test_model.run(solver=test_solver, timeout=30) | ||
|
||
def test_numpy_ssa_solver(self): | ||
''' Check if the test_models run with the NumPySSASolver. ''' | ||
for model in self.test_ssa_models: | ||
test_model = model() | ||
msg = f"Running {test_model.name} using {gillespy2.NumPySSASolver.name} failed!" | ||
with self.subTest(msg=msg): | ||
test_model.run(solver=gillespy2.NumPySSASolver, timeout=30) | ||
|
||
def test_ssa_c_solver(self): | ||
''' Check if the test_models run with the SSACSolver. ''' | ||
for model in self.test_ssa_models: | ||
test_model = model() | ||
test_solver = gillespy2.SSACSolver(model=test_model) | ||
msg = f"Running {test_model.name} using {gillespy2.SSACSolver.name} failed!" | ||
with self.subTest(msg=msg): | ||
test_model.run(solver=test_solver, timeout=30) | ||
|
||
def test_tau_leaping_solver(self): | ||
''' Check if the test_models run with the TauLeapingSolver. ''' | ||
for model in self.test_ssa_models: | ||
test_model = model() | ||
msg = f"Running {test_model.name} using {gillespy2.TauLeapingSolver.name} failed!" | ||
with self.subTest(msg=msg): | ||
test_model.run(solver=gillespy2.TauLeapingSolver, timeout=30) | ||
|
||
def test_tau_leaping_c_solver(self): | ||
''' Check if the test_models run with the TauLeapingCSolver. ''' | ||
for model in self.test_ssa_models: | ||
test_model = model() | ||
test_solver = gillespy2.TauLeapingCSolver(model=test_model) | ||
msg = f"Running {test_model.name} using {gillespy2.TauLeapingCSolver.name} failed!" | ||
with self.subTest(msg=msg): | ||
test_model.run(solver=test_solver, timeout=30) | ||
|
||
def test_tau_hybrid_solver(self): | ||
''' Check if the test_models run with the TauHybridSolver. ''' | ||
for model in self.test_hybrid_models: | ||
test_model = model() | ||
msg = f"Running {test_model.name} using {gillespy2.TauHybridSolver.name} failed!" | ||
with self.subTest(msg=msg): | ||
test_model.run(solver=gillespy2.TauHybridSolver, timeout=30) | ||
|
||
def test_tau_hybrid_c_solver(self): | ||
''' Check if the test_models run with the TauHybridCSolver. ''' | ||
for model in self.test_hybrid_models: | ||
test_model = model() | ||
test_solver = gillespy2.TauHybridCSolver(model=test_model) | ||
msg = f"Running {test_model.name} using {gillespy2.TauHybridCSolver.name} failed!" | ||
with self.subTest(msg=msg): | ||
test_model.run(solver=test_solver, timeout=30) |
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,38 @@ | ||
#!/usr/bin/env python3 | ||
|
||
''' | ||
StochSS is a platform for simulating biochemical systems | ||
Copyright (C) 2019-2023 StochSS developers. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
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 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/>. | ||
''' | ||
import os | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'-m', '--mode', default='staging', choices=['staging', 'release'], | ||
help='Run tests in staging mode or release mode.' | ||
) | ||
|
||
if __name__ == "__main__": | ||
os.chdir('/stochss') | ||
args = parser.parse_args() | ||
print(os.path.dirname(__file__)) | ||
|
||
from run_unit_tests import run as run_unit | ||
from run_integration_tests import run as run_integration | ||
|
||
run_unit(mode=args.mode) | ||
run_integration(mode=args.mode) |
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,54 @@ | ||
#!/usr/bin/env python3 | ||
|
||
''' | ||
StochSS is a platform for simulating biochemical systems | ||
Copyright (C) 2019-2023 StochSS developers. | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
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 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/>. | ||
''' | ||
import os | ||
import sys | ||
import unittest | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'-m', '--mode', default='staging', choices=['staging', 'release'], | ||
help='Run integration tests in staging mode or release mode.' | ||
) | ||
|
||
def run(mode=None): | ||
''' Run the integration tests. ''' | ||
from integration_tests import test_gillespy2 | ||
|
||
modules = [ | ||
test_gillespy2 | ||
] | ||
|
||
for module in modules: | ||
suite = unittest.TestLoader().loadTestsFromModule(module) | ||
runner = unittest.TextTestRunner(failfast=mode == 'staging', verbosity=1) | ||
|
||
print("Executing: {}".format(module)) | ||
result = runner.run(suite) | ||
print('=' * 70) | ||
if not result.wasSuccessful(): | ||
sys.exit(not result.wasSuccessful()) | ||
|
||
if __name__ == "__main__": | ||
os.chdir('/stochss') | ||
args = parser.parse_args() | ||
print(os.path.dirname(__file__)) | ||
|
||
run(mode=args.mode) |
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
Oops, something went wrong.