Skip to content

Commit

Permalink
mutest: fix match_step_json to doc and allow objects not just str
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hopps <[email protected]>
  • Loading branch information
choppsv1 committed Mar 27, 2024
1 parent fbdca48 commit 504dab8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions munet/mutest/userapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ def _match_command_json(
return expect_fail, {}

try:
# Convert to string to validate the input is valid JSON
if not isinstance(match, str):
match = json.dumps(match)
expect = json.loads(match)
except Exception as error:
expect = {}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "munet"
version = "0.13.15"
version = "0.13.16"
description = "A package to facilitate network simulations"
authors = ["Christian Hopps <[email protected]>"]
license = "GPL-2.0-or-later"
Expand Down
4 changes: 2 additions & 2 deletions tests/mutest/mutest_matchwait_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from munet.mutest.userapi import wait_step_json


js = step_json("r1", 'echo { "name": "chopps" }')
js = step_json("r1", """printf '{ "name": "chopps" }'""")
log("SIMPLE JSON: %s", js)

# expect passing tests
Expand Down Expand Up @@ -201,7 +201,7 @@

json1 = '[{"foo":"foo"}]'
json2 = '[{"foo":"foo"}, {"bar":"bar"}]'
json3 = '[{"bar":"bar"}, {"foo":"foo"}]'
json3 = [{"bar": "bar"}, {"foo": "foo"}]

_, ret = match_step_json(
"r1",
Expand Down

0 comments on commit 504dab8

Please sign in to comment.