Created
January 15, 2018 06:53
-
-
Save dmukhg/7a2f1d776876de5e3f646dadfc10f1ee to your computer and use it in GitHub Desktop.
Writing services that are testable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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