Skip to content

Commit d086190

Browse files
committed
Add test for ModelicaSystem.setSimulationOptions()
1 parent d85e41e commit d086190

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/test_ModelicaSystem.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,28 @@ def test_setParameters(self):
5454
assert mod.getParameters(["e", "g"]) == ["21.3", "0.12"]
5555
assert mod.getParameters(["g", "e"]) == ["0.12", "21.3"]
5656

57+
def test_setSimulationOptions(self):
58+
omc = OMPython.OMCSessionZMQ()
59+
model_path = omc.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels/"
60+
mod = OMPython.ModelicaSystem(model_path + "BouncingBall.mo", "BouncingBall", raiseerrors=True)
61+
62+
# method 1
63+
mod.setSimulationOptions("stopTime=1.234")
64+
mod.setSimulationOptions("tolerance=1.1e-08")
65+
assert mod.getSimulationOptions("stopTime") == ["1.234"]
66+
assert mod.getSimulationOptions("tolerance") == ["1.1e-08"]
67+
assert mod.getSimulationOptions(["tolerance", "stopTime"]) == ["1.1e-08", "1.234"]
68+
d = mod.getSimulationOptions()
69+
assert isinstance(d, dict)
70+
assert d["stopTime"] == "1.234"
71+
assert d["tolerance"] == "1.1e-08"
72+
73+
# method 2
74+
mod.setSimulationOptions(["stopTime=2.1", "tolerance=1.2e-08"])
75+
d = mod.getSimulationOptions()
76+
assert d["stopTime"] == "2.1"
77+
assert d["tolerance"] == "1.2e-08"
78+
5779

5880
if __name__ == '__main__':
5981
unittest.main()

0 commit comments

Comments
 (0)