Skip to content

Commit

Permalink
testing main for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bknueven committed Nov 18, 2022
1 parent 1f79651 commit d8f2796
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion watertap/examples/flowsheets/oaro/oaro.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def erd_type_not_found(erd_type):
)


def main(erd_type=ERDtype.pump_as_turbine):
def main(erd_type=ERDtype.pump_as_turbine, raise_on_failure=False):
# set up solver
solver = get_solver()

Expand All @@ -77,6 +77,12 @@ def main(erd_type=ERDtype.pump_as_turbine):
initialize_system(m, solver=solver)

results = solve(m, solver=solver)
if not check_optimal_termination(results):
msg = "Simulation did not converge"
if raise_on_failure:
raise RuntimeError(msg)
else:
print(f"WARNING: {msg}")

print("\n***---Simulation results---***")
display_system(m)
Expand Down
5 changes: 5 additions & 0 deletions watertap/examples/flowsheets/oaro/tests/test_oaro.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from watertap.unit_models.pressure_changer import Pump, EnergyRecoveryDevice
from watertap.examples.flowsheets.oaro.oaro import (
main,
build,
set_operating_conditions,
initialize_system,
Expand Down Expand Up @@ -118,3 +119,7 @@ def test_solution(self, system_frame):
def test_config_error(self, system_frame):
with pytest.raises(Exception):
build(erd_type="not_a_configuration")

@pytest.mark.component
def test_main(self):
main(raise_on_failure=True)

0 comments on commit d8f2796

Please sign in to comment.