Skip to content

Commit 4baeba9

Browse files
committed
[test_OMCPath] update test case
* OMCPath & OMCSessionZMQ * OMCPath & OMCSessionLocal * OMCPath & OMCSessionDocker * OMCPath & OMCSessionWSL (not tested!) * OMPathLocal & OMCSessionRunner * OMPathBash & OMCSessionRunner * OMPathBash & OMCSessionRunner in docker * OMPathBash & OMCSessionRunner in WSL (not tested!)
1 parent f14d022 commit 4baeba9

File tree

1 file changed

+74
-24
lines changed

1 file changed

+74
-24
lines changed

tests/test_OMCPath.py

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,95 @@
1515
)
1616

1717

18-
def test_OMCPath_OMCProcessLocal():
19-
omcs = OMPython.OMCSessionLocal()
18+
# TODO: based on compatibility layer
19+
def test_OMCPath_OMCSessionZMQ():
20+
om = OMPython.OMCSessionZMQ()
2021

21-
_run_OMCPath_checks(omcs)
22+
_run_OMPath_checks(om)
23+
_run_OMPath_write_file(om)
2224

23-
del omcs
25+
26+
def test_OMCPath_OMCSessionLocal():
27+
oms = OMPython.OMCSessionLocal()
28+
29+
_run_OMPath_checks(oms)
30+
_run_OMPath_write_file(oms)
2431

2532

2633
@skip_on_windows
2734
@skip_python_older_312
28-
def test_OMCPath_OMCProcessDocker():
29-
omcs = OMPython.OMCSessionDocker(docker="openmodelica/openmodelica:v1.25.0-minimal")
30-
assert omcs.sendExpression("getVersion()") == "OpenModelica 1.25.0"
35+
def test_OMCPath_OMCSessionDocker():
36+
oms = OMPython.OMCSessionDocker(docker="openmodelica/openmodelica:v1.25.0-minimal")
37+
assert oms.get_version() == "OpenModelica 1.25.0"
3138

32-
_run_OMCPath_checks(omcs)
33-
34-
del omcs
39+
_run_OMPath_checks(oms)
40+
_run_OMPath_write_file(oms)
3541

3642

3743
@pytest.mark.skip(reason="Not able to run WSL on github")
3844
@skip_python_older_312
39-
def test_OMCPath_OMCProcessWSL():
40-
omcs = OMPython.OMCSessionWSL(
45+
def test_OMCPath_OMCSessionWSL():
46+
oms = OMPython.OMCSessionWSL(
4147
wsl_omc='omc',
4248
wsl_user='omc',
4349
timeout=30.0,
4450
)
4551

46-
_run_OMCPath_checks(omcs)
52+
_run_OMPath_checks(oms)
53+
_run_OMPath_write_file(oms)
54+
55+
56+
@skip_python_older_312
57+
def test_OMPathLocal_OMSessionRunner():
58+
oms = OMPython.OMSessionRunner()
59+
60+
_run_OMPath_checks(oms)
61+
_run_OMPath_write_file(oms)
62+
63+
64+
@skip_on_windows
65+
@skip_python_older_312
66+
def test_OMPathBash_OMSessionRunner():
67+
oms = OMPython.OMSessionRunner(
68+
ompath_runner=OMPython.OMPathRunnerBash,
69+
)
70+
71+
_run_OMPath_checks(oms)
72+
_run_OMPath_write_file(oms)
73+
74+
75+
@skip_on_windows
76+
@skip_python_older_312
77+
def test_OMPathBash_OMSessionRunner_Docker():
78+
oms_docker = OMPython.OMCSessionDocker(docker="openmodelica/openmodelica:v1.25.0-minimal")
79+
assert oms_docker.get_version() == "OpenModelica 1.25.0"
80+
81+
oms = OMPython.OMSessionRunner(
82+
cmd_prefix=oms_docker.get_cmd_prefix(),
83+
ompath_runner=OMPython.OMPathRunnerBash,
84+
)
85+
86+
_run_OMPath_checks(oms)
87+
_run_OMPath_write_file(oms)
88+
4789

48-
del omcs
90+
@pytest.mark.skip(reason="Not able to run WSL on github")
91+
@skip_python_older_312
92+
def test_OMPathBash_OMSessionRunner_WSL():
93+
oms_docker = OMPython.OMCSessionWSL()
94+
assert oms_docker.get_version() == "OpenModelica 1.25.0"
95+
96+
oms = OMPython.OMSessionRunner(
97+
cmd_prefix=oms_docker.get_cmd_prefix(),
98+
ompath_runner=OMPython.OMPathRunnerBash,
99+
)
49100

101+
_run_OMPath_checks(oms)
102+
_run_OMPath_write_file(oms)
50103

51-
def _run_OMCPath_checks(omcs: OMPython.OMCSessionABC):
52-
p1 = omcs.omcpath_tempdir()
104+
105+
def _run_OMPath_checks(om: OMPython.OMSessionABC):
106+
p1 = om.omcpath_tempdir()
53107
p2 = p1 / 'test'
54108
p2.mkdir()
55109
assert p2.is_dir()
@@ -58,24 +112,20 @@ def _run_OMCPath_checks(omcs: OMPython.OMCSessionABC):
58112
assert p3.write_text('test')
59113
assert p3.is_file()
60114
assert p3.size() > 0
61-
p3 = p3.resolve().absolute()
62-
assert str(p3) == str((p2 / 'test.txt').resolve().absolute())
115+
p3 = p3.resolve()
116+
assert str(p3) == str((p2 / 'test.txt').resolve())
63117
assert p3.read_text() == "test"
64118
assert p3.is_file()
65119
assert p3.parent.is_dir()
66120
p3.unlink()
67121
assert p3.is_file() is False
68122

69123

70-
def test_OMCPath_write_file(tmpdir):
71-
omcs = OMPython.OMCSessionLocal()
72-
124+
def _run_OMPath_write_file(om: OMPython.OMSessionABC):
73125
data = "abc # \\t # \" # \\n # xyz"
74126

75-
p1 = omcs.omcpath_tempdir()
127+
p1 = om.omcpath_tempdir()
76128
p2 = p1 / 'test.txt'
77129
p2.write_text(data=data)
78130

79131
assert data == p2.read_text()
80-
81-
del omcs

0 commit comments

Comments
 (0)