Skip to content

Instantly share code, notes, and snippets.

@dmukhg
Created January 15, 2018 06:53
Show Gist options
  • Save dmukhg/7a2f1d776876de5e3f646dadfc10f1ee to your computer and use it in GitHub Desktop.
Save dmukhg/7a2f1d776876de5e3f646dadfc10f1ee to your computer and use it in GitHub Desktop.
Writing services that are testable
from .auth import AccessControlList
class GoodBookService(object):
def __init__(self, acl_service=AccessControlList()):
self.acl = acl_service
def create_book(self, user, book):
if self.acl.can_create_book(user):
# ... code to create book
else:
# ... raise an exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment