Skip to content

Commit a91aa59

Browse files
committed
test(workflow): include console.print for used warning
1 parent 789fc03 commit a91aa59

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

‎tests/unit/CodeEntropy/entropy/test_workflow.py‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
import types
44
from types import SimpleNamespace
5-
from unittest.mock import MagicMock, patch
5+
from unittest.mock import MagicMock, call, patch
66

77
import pytest
88

@@ -73,7 +73,16 @@ def test_execute_calls_level_dag_and_entropy_graph_and_logs_tables():
7373
wf._reporter.log_tables.assert_called_once()
7474

7575

76-
def test_execute_water_entropy_branch_calls_water_entropy_solver():
76+
@pytest.mark.parametrize(
77+
("nonwater_groups", "expect_warning"),
78+
[
79+
({0: [0]}, False),
80+
({}, True),
81+
],
82+
)
83+
def test_execute_water_entropy_branch_calls_water_entropy_solver(
84+
nonwater_groups, expect_warning
85+
):
7786
args = SimpleNamespace(
7887
start=0,
7988
end=-1,
@@ -106,15 +115,19 @@ def test_execute_water_entropy_branch_calls_water_entropy_solver():
106115
wf._build_reduced_universe = MagicMock(return_value=MagicMock())
107116
wf._detect_levels = MagicMock(return_value={0: ["united_atom"]})
108117

109-
wf._split_water_groups = MagicMock(return_value=({0: [0]}, {9: [1, 2]}))
118+
wf._split_water_groups = MagicMock(return_value=(nonwater_groups, {9: [1, 2]}))
110119
wf._finalize_molecule_results = MagicMock()
111120

112-
wf._group_molecules.grouping_molecules.return_value = {0: [0], 9: [1, 2]}
121+
wf._group_molecules.grouping_molecules.return_value = {
122+
**nonwater_groups,
123+
9: [1, 2],
124+
}
113125

114126
with (
115127
patch("CodeEntropy.entropy.workflow.WaterEntropy") as WaterCls,
116128
patch("CodeEntropy.entropy.workflow.LevelDAG") as LevelDAGCls,
117129
patch("CodeEntropy.entropy.workflow.EntropyGraph") as GraphCls,
130+
patch("CodeEntropy.entropy.workflow.console") as console,
118131
):
119132
water_instance = WaterCls.return_value
120133
water_instance.calculate_and_log = MagicMock()
@@ -126,6 +139,10 @@ def test_execute_water_entropy_branch_calls_water_entropy_solver():
126139

127140
water_instance.calculate_and_log.assert_called_once()
128141
_, kwargs = water_instance.calculate_and_log.call_args
142+
warning = call(
143+
"Warning: You are running waterEntropy on bulk water, this will be slow!"
144+
)
145+
assert (warning in console.print.call_args_list) is expect_warning
129146
assert kwargs["universe"] is universe
130147
assert kwargs["start"] == 0
131148
assert kwargs["end"] == 5

0 commit comments

Comments
 (0)