-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathtest_ModelicaSystemCmd.py
More file actions
62 lines (49 loc) · 1.35 KB
/
test_ModelicaSystemCmd.py
File metadata and controls
62 lines (49 loc) · 1.35 KB
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
55
56
57
58
59
60
61
62
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.ModelicaSystemOMC()
mod.model(
model_file=model_firstorder,
model_name="M",
)
mscmd = OMPython.ModelExecutionCmd(
runpath=mod.getWorkDirectory(),
cmd_local=mod.get_session().model_execution_local,
cmd_windows=mod.get_session().model_execution_windows,
cmd_prefix=mod.get_session().model_execution_prefix(cwd=mod.getWorkDirectory()),
model_name=mod._model_name,
)
return mscmd
def test_simflags(mscmd_firstorder):
mscmd = mscmd_firstorder
mscmd.args_set({
"noEventEmit": None,
"override": {'b': 2}
})
with pytest.deprecated_call():
mscmd.args_set(args=mscmd.parse_simflags(simflags="-noEventEmit -noRestart -override=a=1,x=3"))
assert mscmd.get_cmd_args() == [
'-noEventEmit',
'-noRestart',
'-override=a=1,b=2,x=3',
]
mscmd.args_set({
"override": {'b': None},
})
assert mscmd.get_cmd_args() == [
'-noEventEmit',
'-noRestart',
'-override=a=1,x=3',
]