Skip to content

Commit

Permalink
fix partial match for non dictionary items
Browse files Browse the repository at this point in the history
currenlty with partial match `[{"foo":"foo"}]` is considered a subset of
`[{"foo":"foo"}, {"bar":"bar"}]`. However `[1]` is not considered a subset
of `[1,2]`. This fixes the behavior so that partial match rules apply
to non dictionary items within a list.

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
  • Loading branch information
Jafaral committed Jan 19, 2025
1 parent 8f7649c commit df5cadc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions munet/mutest/userapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,7 @@ def _match_command_json(
if (new_items := json_diff.get("iterable_item_added")) is not None:
new_item_paths = list(new_items.keys())
for path in new_item_paths:
if type(new_items[path]) is dict:
del new_items[path]
del new_items[path]
if len(new_items) == 0:
del json_diff["iterable_item_added"]

Expand Down
6 changes: 2 additions & 4 deletions tests/mutest/mutest_matchwait_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@
"r1",
f"echo '{json2}'",
json1,
"Data in different arrays don't match",
expect_fail=True,
"Data in one array is a subest of another"
)
test_step(
ret == {'iterable_item_added': {'root[1]': 'bar'}},
Expand Down Expand Up @@ -300,8 +299,7 @@
"r1",
f"echo '{json4}'",
json1,
"Data in different arrays don't match (nested)",
expect_fail=True
"Data in one array is a subest of another"
)
test_step(
ret == {'iterable_item_added': {"root['level1'][1]['level3'][1]": 'l4'}},
Expand Down

0 comments on commit df5cadc

Please sign in to comment.