Skip to content

Commit

Permalink
test: return None instead of 404 Exception for missing XPaths
Browse files Browse the repository at this point in the history
Fixes to following exception calling iface.interface_exist(target, veth0): requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://[fe80::2a0:85ff:fe00:201%d2a]:443/restconf/ds/ietf-datastores%3Aoperational/ietf-interfaces%3Ainterfaces/interface=veth0a/name

Removing interface veth0a, and then checking operational if it has been
properly removed, should not cause an exception.  Better to return None
object instead.

Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Sep 27, 2024
1 parent acb8443 commit 652f1e7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/infamy/restconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ def get_datastore(self, datastore="operational", path="", parse=True):
dspath = f"{dspath}/{path}"

url = f"{self.restconf_url}{dspath}"
return self._get_raw(url, parse)
try:
return self._get_raw(url, parse)
except Exception as e:
if e.response.status_code == 404:
return None
else:
raise e

def get_running(self, path=None):
"""Wrapper function to get running datastore"""
Expand Down

0 comments on commit 652f1e7

Please sign in to comment.