Skip to content

Commit

Permalink
Merge pull request #415 from chidanandpujar/issue_393_fix1
Browse files Browse the repository at this point in the history
Issue 393 fix1
  • Loading branch information
dineshbaburam91 authored Jul 19, 2024
2 parents f1a5e70 + 59d4e77 commit c7d2487
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion lib/jnpr/jsnapy/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def testname_results(self):
test["command"] = cmd
testname_result_dict.setdefault(test["test_name"], [])
testname_result_dict[test["test_name"]].append(test)
del test["test_name"]
return testname_result_dict

def define_operator(
Expand Down Expand Up @@ -118,6 +117,16 @@ def _print_result(self, testmssg, result):
colorama.Fore.GREEN + "PASS | " + testmssg, extra=self.log_detail
)

def _print_msg(self, testmssg, result):
if result is False:
self.logger_testop.info(
colorama.Fore.RED + "FAIL | " + testmssg, extra=self.log_detail
)
else:
self.logger_testop.info(
colorama.Fore.GREEN + "PASS | " + testmssg, extra=self.log_detail
)

def print_testmssg(self, testname):
"""
Print info and error messages
Expand Down Expand Up @@ -420,13 +429,17 @@ def exists(
% (element, x_path, count_pass, count_fail)
)
self._print_result(msg, res)
self._print_msg(err_mssg, res)
tresult["err"] = err_mssg # Updating the user specified err message
elif res is True:
msg = 'All "%s" exists at xpath "%s" [ %d value matched ]' % (
element,
x_path,
count_pass,
)
self._print_result(msg, res)
self._print_msg(info_mssg, res)
tresult["info"] = info_mssg # Updating the user specified info message

# tresult['info'] = info_mssg
# tresult['err'] = err_mssg
Expand Down
4 changes: 2 additions & 2 deletions tools/jsnap2py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def msg_change(x):
data = (data[0],data[1][1:])
if data[0] in ['id', 'ID']:
data = (data[0], int(data[1])-1)
msg = "{{%s_%s}}" % (data)
msg = "{{%s_%s}}" % (data)
elif data[0] in ['PRE', 'POST']:
msg = '{{%s["%s"]}}' % (data)
else:
Expand Down Expand Up @@ -120,7 +120,7 @@ else:
'\$id\.\d|\$pre\s?/?\.?/\s?[\w-]+/?[\w-]*|\$post\s?/?\.?/\s?[\w-]+/?[\w-]*|,\s?\.{0,2}/?\.{0,2}/?[\w-]+/?[\w-]*/?[\w-]*',
data.group(2),
re.I)
inputs = map(msg_change, inputs)
inputs = list(map(msg_change, inputs))
to_format = re.search('"(.*?)"', obj.group(2))
if len(inputs) > 0:
if to_format:
Expand Down

0 comments on commit c7d2487

Please sign in to comment.