Commits

Andriy Kornatskyy  committed 3795f71

Minor readability improvements in repository.

  • Participants
  • Parent commits 6424167

Comments (0)

Files changed (2)

File demos/template/src/membership/repository/caching.py

 """
 """
 
-from wheezy.core.introspection import looks
-
 from config import cache
 from membership.repository import keys
 from membership.repository.contract import IMembershipRepository
         return self.inner.create_account(registration)
 
 
+# region: internal details
+
+from wheezy.core.introspection import looks
+assert looks(MembershipRepository).like(IMembershipRepository)
 assert looks(IMembershipRepository).like(MembershipRepository)
+del looks

File demos/template/src/membership/repository/mock.py

+
 """
 """
 
 from wheezy.core.comp import u
-from wheezy.core.introspection import looks
 
 from membership.repository.contract import IMembershipRepository
 
         session.cursor()
 
     def authenticate(self, credential):
-        return credential.password == credentials.get(
+        return credential.password == db['credentials'].get(
             credential.username, None)
 
     def has_account(self, username):
-        return username in credentials
+        return username in db['credentials']
 
     def user_roles(self, username):
-        return tuple(roles.get(username, None))
+        return tuple(db['roles'].get(username, None))
 
     def create_account(self, registration):
         credential = registration.credential
-        credentials[credential.username] = credential.password
-        roles[credential.username] = tuple(
+        db['credentials'][credential.username] = credential.password
+        db['roles'][credential.username] = tuple(
             [registration.account.account_type])
         return True
 
 
 # region: internal details
 
-credentials = {
-    'demo': u('P@ssw0rd'),
-    'biz': u('P@ssw0rd')
-}
-roles = {
+db = {
+    'credentials': {
+        'demo': u('P@ssw0rd'),
+        'biz': u('P@ssw0rd')
+    },
+    'roles': {
     'demo': ['user'],
     'biz': ['business']
+    }
 }
 
+from wheezy.core.introspection import looks
+assert looks(MembershipRepository).like(IMembershipRepository)
 assert looks(IMembershipRepository).like(MembershipRepository)
+del looks