-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathtest_ModelicaSystemCmd.py
More file actions
54 lines (43 loc) · 1016 Bytes
/
test_ModelicaSystemCmd.py
File metadata and controls
54 lines (43 loc) · 1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import pytest
import OMPython
@pytest.fixture
def model_firstorder(tmp_path):
mod = tmp_path / "M.mo"
mod.write_text("""model M
Real x(start = 1, fixed = true);
parameter Real a = -1;
equation
der(x) = x*a;
end M;
""")
return mod
@pytest.fixture
def mscmd_firstorder(model_firstorder):
mod = OMPython.ModelicaSystem()
mod.model(
model_file=model_firstorder,
model_name="M",
)
mscmd = OMPython.ModelicaSystemCmd(
session=mod.get_session(),
runpath=mod.getWorkDirectory(),
modelname=mod._model_name,
)
return mscmd
def test_simflags(mscmd_firstorder):
mscmd = mscmd_firstorder
mscmd.args_set({
"noEventEmit": None,
"override": {'b': 2, 'a': 4},
})
assert mscmd.get_cmd_args() == [
'-noEventEmit',
'-override=a=4,b=2',
]
mscmd.args_set({
"override": {'b': None},
})
assert mscmd.get_cmd_args() == [
'-noEventEmit',
'-override=a=4',
]