diff --git a/src/phi/async_ldap/mixins.py b/src/phi/async_ldap/mixins.py index 0ae52aa..1aff860 100644 --- a/src/phi/async_ldap/mixins.py +++ b/src/phi/async_ldap/mixins.py @@ -4,10 +4,8 @@ from bonsai.ldapvaluelist import LDAPValueList import bonsai.errors from phi.exceptions import ( - PhiAttributeMissing, PhiEntryDoesNotExist, PhiEntryExists, - PhiUnauthorized, PhiUnexpectedRuntimeValue, PhiCannotExecute, ) @@ -48,6 +46,8 @@ class Singleton(object): name = f"{cls.__name__}-{args[0]}-{id(client)}" else: name = f"{cls.__name__}-{id(client)}" + if not hasattr(cls, "_instances"): + cls._instances = dict() if name not in cls._instances: cls._instances[name] = object.__new__(cls) return cls._instances[name] diff --git a/src/phi/async_ldap/model.py b/src/phi/async_ldap/model.py index 5e08e68..dec8656 100644 --- a/src/phi/async_ldap/model.py +++ b/src/phi/async_ldap/model.py @@ -4,6 +4,9 @@ from bonsai import LDAPEntry from multidict import MultiDict from phi.async_ldap import mixins +from phi.exceptions import ( + PhiUnexpectedRuntimeValue, +) def parse_dn(dn): @@ -60,7 +63,7 @@ class Service(mixins.Member, mixins.Entry, mixins.Singleton): ldap_attributes = ["uid", "ou", "userPassword"] async def iter_groups(self): # To be monkeypatched later - pass # pragma: no cover + raise NotImplemented async def groups(self): return [g async for g in self.iter_groups()]