Commit 39cfacb8 authored by Rob Carleski's avatar Rob Carleski 🇮🇸
Browse files

Multiple fixes

- Add custom exception for entity not being found
- Raise new exception when DN cannot be found from search
- Fix fetch method to return empty group object when search brings back
  no results, but preserve exception raise for multiple failed searches
parent 825235ce
...@@ -58,7 +58,9 @@ def get_entity_dn(client, name): ...@@ -58,7 +58,9 @@ def get_entity_dn(client, name):
else: else:
raise MCommError('Searching MCommunity failed.') raise MCommError('Searching MCommunity failed.')
else: else:
raise MCommError('Unable to find "{}" in MCommunity'.format(name)) raise MCommEntityNotFound(
'Unable to find "{}" in MCommunity'.format(name)
if data: if data:
for item in data: for item in data:
...@@ -82,3 +84,7 @@ def get_entity_dn(client, name): ...@@ -82,3 +84,7 @@ def get_entity_dn(client, name):
class MCommError(Exception): class MCommError(Exception):
pass pass
class MCommEntityNotFound(Exception):
...@@ -168,7 +168,10 @@ class MCommGroup: ...@@ -168,7 +168,10 @@ class MCommGroup:
None None
""" """
self.dn = core.get_entity_dn(self.client, self.dn = core.get_entity_dn(self.client,
except core.MCommEntityNotFound:
self.dn = None
if not self.dn: if not self.dn:
return return
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment