Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .github/workflows/main.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/run-integration-tests.yaml
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'
21 changes: 21 additions & 0 deletions .github/workflows/run-unit-tests.yml
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'
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ test: create_working_dir
-v $(DOCKER_WORKING_DIR):/home/jovyan/ \
-p 8888:8888 \
$(DOCKER_STOCHSS_IMAGE):latest \
/stochss/stochss/tests/run_tests.py
/stochss/stochss/tests/run_all_tests.py

build_and_test: build test

Expand Down
Empty file added stochss/tests/__init__.py
Empty file.
750 changes: 429 additions & 321 deletions stochss/tests/example_models.py

Large diffs are not rendered by default.

Empty file.
158 changes: 158 additions & 0 deletions stochss/tests/integration_tests/test_gillespy2.py
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)
38 changes: 38 additions & 0 deletions stochss/tests/run_all_tests.py
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)
54 changes: 54 additions & 0 deletions stochss/tests/run_integration_tests.py
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)
43 changes: 22 additions & 21 deletions stochss/tests/run_tests.py → stochss/tests/run_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,44 @@
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 unittest
import sys
import os
import sys
import unittest
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__))

import test_model_template
import test_settings_template
import test_stochss_base
import test_stochss_file
import test_gillespy2

parser.add_argument(
'-m', '--mode', default='staging', choices=['staging', 'release'],
help='Run unit tests in staging mode or release mode.'
)

def run(mode=None):
''' Run the unit tests. '''
from unit_tests import test_model_template
from unit_tests import test_settings_template
from unit_tests import test_stochss_base
from unit_tests import test_stochss_file

modules = [
test_model_template,
test_settings_template,
test_gillespy2,
test_stochss_base,
test_stochss_file
]

for module in modules:
suite = unittest.TestLoader().loadTestsFromModule(module)
runner = unittest.TextTestRunner(failfast=args.mode == 'staging', verbosity=1)
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)
Loading