forked from OpenModelica/OMPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ZMQ.py
More file actions
43 lines (31 loc) · 1.02 KB
/
test_ZMQ.py
File metadata and controls
43 lines (31 loc) · 1.02 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
import OMPython
import pathlib
import os
import pytest
@pytest.fixture
def model_time_str():
return """model M
Real r = time;
end M;
"""
@pytest.fixture
def om(tmp_path):
origDir = pathlib.Path.cwd()
os.chdir(tmp_path)
om = OMPython.OMCSessionZMQ()
os.chdir(origDir)
return om
def testHelloWorld(om):
assert om.sendExpression('"HelloWorld!"') == "HelloWorld!"
def test_Translate(om, model_time_str):
assert om.sendExpression(model_time_str) == ("M",)
assert om.sendExpression('translateModel(M)') is True
def test_Simulate(om, model_time_str):
assert om.sendExpression(f'loadString("{model_time_str}")') is True
om.sendExpression('res:=simulate(M, stopTime=2.0)')
assert om.sendExpression('res.resultFile')
def test_execute(om):
with pytest.deprecated_call():
assert om.execute('"HelloWorld!"') == '"HelloWorld!"\n'
assert om.sendExpression('"HelloWorld!"', parsed=False) == '"HelloWorld!"\n'
assert om.sendExpression('"HelloWorld!"', parsed=True) == 'HelloWorld!'