Major refactoring. Got rid of exceptions/errors in favor of using simple return values. Update tests to ensure full coverage according to nose coverage plugin

This commit is contained in:
Matt Wright
2012-08-23 17:58:33 -04:00
parent 5a4fb94be3
commit 6e754ed356
12 changed files with 174 additions and 214 deletions
+2 -11
View File
@@ -9,9 +9,6 @@
:license: MIT, see LICENSE for more details.
"""
from . import exceptions
class UserDatastore(object):
"""Abstracted user datastore. Always extend this class and implement the
:attr:`_save_model`, :attr:`_delete_model`, :attr:`_do_find_user`, and
@@ -93,20 +90,14 @@ class UserDatastore(object):
:param user: User identifier, usually email address
"""
user = self._do_find_user(**kwargs)
if user:
return user
raise exceptions.UserNotFoundError('Parameters=%s' % kwargs)
return self._do_find_user(**kwargs)
def find_role(self, role):
"""Returns a role based on its name.
:param role: Role name
"""
role = self._do_find_role(role)
if role:
return role
raise exceptions.RoleNotFoundError()
return self._do_find_role(role)
def create_role(self, **kwargs):
"""Creates and returns a new role.