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

Fix no_diff with missing pre and post snapfile #414

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions lib/jnpr/jsnapy/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,8 @@ def not_exists(
count_pass = count_pass + 1
node_value_passed = {
"id": id_val,
"PRE": predict,
"POST": postdict,
"pre": predict,
"post": postdict,
"message": message,
}
tresult["passed"].append(deepcopy(node_value_passed))
Expand Down Expand Up @@ -2739,6 +2739,18 @@ def no_diff(
+ "ERROR!! 'no-diff' operator requires node value to test !!",
extra=self.log_detail,
)
elif xml1 is None or xml2 is None:
self._error_nodes_logger("Xpath for snapshot", x_path)
res = False
count_fail = count_fail + 1
node_value_failed = {
"id": iddict,
"pre": predict,
"post": postdict,
"actual_node_value": None,
"xpath_error": True,
}
tresult["failed"].append(deepcopy(node_value_failed))
else:
if (not pre_nodes) or (not post_nodes):
# if ignore_null is True, just skip
Expand Down Expand Up @@ -2873,7 +2885,8 @@ def no_diff(
else:
# mapping id name to its value
for length in range(len(k)):
id_val[id_list[length]] = k[length][0].strip()
if len(k[0]) > 0:
id_val[id_list[length]] = k[length][0].strip()
if k in data1:
predict, postdict = self._get_nodevalue(
predict,
Expand Down
Loading