Skip to content

Commit 27eb418

Browse files
committed
tests from v4.0.0
1 parent f4246b8 commit 27eb418

13 files changed

Lines changed: 957 additions & 0 deletions

tests_v400/__init__.py

Whitespace-only changes.

tests_v400/test_ArrayDimension.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import OMPython
2+
3+
4+
def test_ArrayDimension(tmp_path):
5+
omc = OMPython.OMCSessionZMQ()
6+
7+
omc.sendExpression(f'cd("{tmp_path.as_posix()}")')
8+
9+
omc.sendExpression('loadString("model A Integer x[5+1,1+6]; end A;")')
10+
omc.sendExpression("getErrorString()")
11+
12+
result = omc.sendExpression("getComponents(A)")
13+
assert result[0][-1] == (6, 7), "array dimension does not match"
14+
15+
omc.sendExpression('loadString("model A Integer y = 5; Integer x[y+1,1+9]; end A;")')
16+
omc.sendExpression("getErrorString()")
17+
18+
result = omc.sendExpression("getComponents(A)")
19+
assert result[-1][-1] == ('y+1', 10), "array dimension does not match"

tests_v400/test_FMIExport.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import OMPython
2+
import shutil
3+
import os
4+
5+
6+
def test_CauerLowPassAnalog():
7+
mod = OMPython.ModelicaSystem(modelName="Modelica.Electrical.Analog.Examples.CauerLowPassAnalog",
8+
lmodel=["Modelica"])
9+
tmp = mod.getWorkDirectory()
10+
try:
11+
fmu = mod.convertMo2Fmu(fileNamePrefix="CauerLowPassAnalog")
12+
assert os.path.exists(fmu)
13+
finally:
14+
shutil.rmtree(tmp, ignore_errors=True)
15+
16+
17+
def test_DrumBoiler():
18+
mod = OMPython.ModelicaSystem(modelName="Modelica.Fluid.Examples.DrumBoiler.DrumBoiler", lmodel=["Modelica"])
19+
tmp = mod.getWorkDirectory()
20+
try:
21+
fmu = mod.convertMo2Fmu(fileNamePrefix="DrumBoiler")
22+
assert os.path.exists(fmu)
23+
finally:
24+
shutil.rmtree(tmp, ignore_errors=True)

tests_v400/test_FMIRegression.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import OMPython
2+
import tempfile
3+
import pathlib
4+
import shutil
5+
import os
6+
7+
8+
def buildModelFMU(modelName):
9+
omc = OMPython.OMCSessionZMQ()
10+
11+
tempdir = pathlib.Path(tempfile.mkdtemp())
12+
try:
13+
omc.sendExpression(f'cd("{tempdir.as_posix()}")')
14+
15+
omc.sendExpression("loadModel(Modelica)")
16+
omc.sendExpression("getErrorString()")
17+
18+
fileNamePrefix = modelName.split(".")[-1]
19+
exp = f'buildModelFMU({modelName}, fileNamePrefix="{fileNamePrefix}")'
20+
fmu = omc.sendExpression(exp)
21+
assert os.path.exists(fmu)
22+
finally:
23+
del omc
24+
shutil.rmtree(tempdir, ignore_errors=True)
25+
26+
27+
def test_Modelica_Blocks_Examples_Filter():
28+
buildModelFMU("Modelica.Blocks.Examples.Filter")
29+
30+
31+
def test_Modelica_Blocks_Examples_RealNetwork1():
32+
buildModelFMU("Modelica.Blocks.Examples.RealNetwork1")
33+
34+
35+
def test_Modelica_Electrical_Analog_Examples_CauerLowPassAnalog():
36+
buildModelFMU("Modelica.Electrical.Analog.Examples.CauerLowPassAnalog")
37+
38+
39+
def test_Modelica_Electrical_Digital_Examples_FlipFlop():
40+
buildModelFMU("Modelica.Electrical.Digital.Examples.FlipFlop")
41+
42+
43+
def test_Modelica_Mechanics_Rotational_Examples_FirstGrounded():
44+
buildModelFMU("Modelica.Mechanics.Rotational.Examples.FirstGrounded")
45+
46+
47+
def test_Modelica_Mechanics_Rotational_Examples_CoupledClutches():
48+
buildModelFMU("Modelica.Mechanics.Rotational.Examples.CoupledClutches")
49+
50+
51+
def test_Modelica_Mechanics_MultiBody_Examples_Elementary_DoublePendulum():
52+
buildModelFMU("Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum")
53+
54+
55+
def test_Modelica_Mechanics_MultiBody_Examples_Elementary_FreeBody():
56+
buildModelFMU("Modelica.Mechanics.MultiBody.Examples.Elementary.FreeBody")
57+
58+
59+
def test_Modelica_Fluid_Examples_PumpingSystem():
60+
buildModelFMU("Modelica.Fluid.Examples.PumpingSystem")
61+
62+
63+
def test_Modelica_Fluid_Examples_TraceSubstances_RoomCO2WithControls():
64+
buildModelFMU("Modelica.Fluid.Examples.TraceSubstances.RoomCO2WithControls")
65+
66+
67+
def test_Modelica_Clocked_Examples_SimpleControlledDrive_ClockedWithDiscreteTextbookController():
68+
buildModelFMU("Modelica.Clocked.Examples.SimpleControlledDrive.ClockedWithDiscreteTextbookController")

0 commit comments

Comments
 (0)