Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
simstadtpy
Commits
c47561f3
Commit
c47561f3
authored
Aug 04, 2026
by
Eric Duminil
Browse files
Working on mocks
parent
84e5967f
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/conftest.py
View file @
c47561f3
...
...
@@ -34,6 +34,7 @@ def test_project_path() -> Path:
# SimStadt mock (replaces subprocess call with fixture file copying)
# ---------------------------------------------------------------------------
def
_find_fixture_flow
(
provider
:
str
)
->
Path
|
None
:
"""Find a .flow directory in test data that matches the given provider and has output files."""
for
flow_dir
in
TEST_REPOSITORY
.
rglob
(
"*.flow"
):
...
...
@@ -43,7 +44,9 @@ def _find_fixture_flow(provider: str) -> Path | None:
root
=
et
.
parse
(
params_xml
).
getroot
()
elem
=
root
.
find
(
".//void[@property='workflowProvider']/object"
)
if
elem
is
not
None
and
elem
.
get
(
"class"
)
==
provider
:
non_params
=
[
f
for
f
in
flow_dir
.
rglob
(
"*"
)
if
f
.
is_file
()
and
f
.
name
!=
"params.xml"
]
non_params
=
[
f
for
f
in
flow_dir
.
rglob
(
"*"
)
if
f
.
is_file
()
and
f
.
name
!=
"params.xml"
]
if
non_params
:
return
flow_dir
return
None
...
...
@@ -53,7 +56,7 @@ def _find_fixture_flow(provider: str) -> Path | None:
def
mock_simstadt
(
monkeypatch
):
"""Mock run_simstadt by copying fixture output files instead of running SimStadt."""
def
_mock
(
workflow_path
:
Path
,
name
:
str
)
->
str
:
def
_mock
(
workflow_path
:
Path
,
name
:
str
,
csv_export
:
bool
=
False
)
->
str
:
root
=
et
.
parse
(
workflow_path
/
"params.xml"
).
getroot
()
elem
=
root
.
find
(
".//void[@property='workflowProvider']/object"
)
provider
=
elem
.
get
(
"class"
)
if
elem
is
not
None
else
None
...
...
@@ -74,13 +77,13 @@ def mock_simstadt(monkeypatch):
# Live fixtures (require SimStadt to be installed)
# ---------------------------------------------------------------------------
@
pytest
.
fixture
(
scope
=
"session"
)
def
simstadt_folder
():
"""Skip the test if SimStadt is not installed."""
from
simstadt.runner
import
get_simstadt_folder
try
:
return
get_simstadt_folder
()
except
ValueError
as
e
:
pytest
.
skip
(
str
(
e
))
tests/test_cli.py
View file @
c47561f3
...
...
@@ -91,7 +91,7 @@ def test_run_files_flag(mock_simstadt, run_cli, capsys, tmp_path):
assert
"Mean Uvalue"
in
out
def
_broken_simstadt
(
_workflow_path
:
Path
,
_name
:
str
)
->
str
:
def
_broken_simstadt
(
_workflow_path
:
Path
,
_name
:
str
,
_csv_export
:
bool
=
False
)
->
str
:
raise
ValueError
(
"BOOM!"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment