Skip to content

Commit 0593439

Browse files
committed
[test_ModelicaSystem] copy test_setParameters() as test_setParameter()
1 parent 6cd65ea commit 0593439

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_ModelicaSystem.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,35 @@ def test_setParameters():
5858
mod.getParameters(["g", "thisParameterDoesNotExist"])
5959

6060

61+
def test_setParameter():
62+
omc = OMPython.OMCSessionZMQ()
63+
model_path = omc.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels/"
64+
mod = OMPython.ModelicaSystem(model_path + "BouncingBall.mo", "BouncingBall")
65+
66+
# method 1
67+
mod.setParameter(e=1.234)
68+
mod.setParameter(g=321.0)
69+
assert mod.getParameters("e") == ["1.234"]
70+
assert mod.getParameters("g") == ["321.0"]
71+
assert mod.getParameters() == {
72+
"e": "1.234",
73+
"g": "321.0",
74+
}
75+
with pytest.raises(KeyError):
76+
mod.getParameters("thisParameterDoesNotExist")
77+
78+
# method 2
79+
mod.setParameter(e=21.3, g=0.12)
80+
assert mod.getParameters() == {
81+
"e": "21.3",
82+
"g": "0.12",
83+
}
84+
assert mod.getParameters(["e", "g"]) == ["21.3", "0.12"]
85+
assert mod.getParameters(["g", "e"]) == ["0.12", "21.3"]
86+
with pytest.raises(KeyError):
87+
mod.getParameters(["g", "thisParameterDoesNotExist"])
88+
89+
6190
def test_setSimulationOptions():
6291
omc = OMPython.OMCSessionZMQ()
6392
model_path = omc.sendExpression("getInstallationDirectoryPath()") + "/share/doc/omc/testmodels/"

0 commit comments

Comments
 (0)