Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mutest: new exact_match flag for match and wait step #25

Merged
merged 3 commits into from
Aug 4, 2023

Conversation

liambrady
Copy link
Contributor

@liambrady liambrady commented Jul 17, 2023

Adds in new exact_match flag for (in)exact matching. This results in the following states:

For the match and wait steps (non-json):

  • If true, then search for the provided string exactly within the command output (substring match). (new behavior)
  • If false, then perform a regex search on the command output using the provided pattern.

For the match_json and wait_json steps:

  • If true, then exactly match the provided and output json against each other.
  • If false, then both search for and match the provided json's fields against those in the cmd output (but not vice versa). (new behavior)
    • The exact rules for matching in this case have been added to the munet documentation source files

And the new default behavior of munet is for exact matching to be set to false.

  • This changes the default behavior of json matching, which previously was always an exact match

@liambrady liambrady added documentation Improvements or additions to documentation enhancement New feature or request mutest mutest related item labels Jul 17, 2023
doc/source/mutest.rst Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Patch coverage has no change and project coverage change: -0.02% ⚠️

Comparison is base (0869d8f) 60.17% compared to head (1a8b4be) 60.16%.
Report is 1 commits behind head on main.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
- Coverage   60.17%   60.16%   -0.02%     
==========================================
  Files          17       17              
  Lines        5153     5154       +1     
==========================================
  Hits         3101     3101              
- Misses       2052     2053       +1     

see 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

doc/source/mutest.rst Outdated Show resolved Hide resolved
doc/source/mutest.rst Outdated Show resolved Hide resolved
doc/source/mutest.rst Show resolved Hide resolved
doc/source/mutest.rst Outdated Show resolved Hide resolved
doc/source/mutest.rst Outdated Show resolved Hide resolved
doc/source/mutest.rst Show resolved Hide resolved
munet/mutest/userapi.py Outdated Show resolved Hide resolved
json_diff = json.loads(deep_diff.to_json())
# Remove new fields in json object from diff
if json_diff.get('dictionary_item_added') is not None:
del json_diff['dictionary_item_added']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does json_cmp always return these key-valus at the top level? i.e., what if you have a diff in a dict in a dict?

json1 = '{ "foo": { "bar": { "one": 1 } } }'
json2 = '{ "foo": { "bar": { "one": 1, "two": 2 } } }'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my testing, it always appeared that they did. The top-level key value is then associated with an array of paths locating any differences of the specified key value type.

For example, json_diff(json.loads(json1), json.loads(json2)) returns the DeepDiff object which, when converted to a dict or list at all levels, is equivalent to {'dictionary_item_added':["root['foo']['bar']['two']"]}

Similarly, json_diff(json.loads(json2), json.loads(json1)) returns the DeepDiff object which, when converted to a dict or list at all levels, is equivalent to {'dictionary_item_removed':["root['foo']['bar']['two']"]}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks

@choppsv1 choppsv1 merged commit e5630c9 into LabNConsulting:main Aug 4, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request mutest mutest related item
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants