Commits

Peter Sagerson committed 562655b

Flake8 cleanup.

Comments (0)

Files changed (1)

django_auth_ldap/tests.py

     ldap_methods_called() to get a record of all of the LDAP API calls that have
     been made, with or without arguments.
     """
-
-    class PresetReturnRequiredError(Exception): pass
+    class PresetReturnRequiredError(Exception):
+        pass
 
     SCOPE_BASE = 0
     SCOPE_ONELEVEL = 1
 
     RES_SEARCH_RESULT = 101
 
-    class LDAPError(Exception): pass
-    class INVALID_CREDENTIALS(LDAPError): pass
-    class NO_SUCH_OBJECT(LDAPError): pass
-    class NO_SUCH_ATTRIBUTE(LDAPError): pass
+    class LDAPError(Exception):
+        pass
+
+    class INVALID_CREDENTIALS(LDAPError):
+        pass
+
+    class NO_SUCH_OBJECT(LDAPError):
+        pass
+
+    class NO_SUCH_ATTRIBUTE(LDAPError):
+        pass
 
     #
     # Submodules
         class cidict(dict):
             pass
 
-
     def __init__(self, directory):
         """
         directory is a complex structure with the entire contents of the
         self._record_call('search', {
             'base': base,
             'scope': scope,
-            'filterstr':filterstr,
-            'attrlist':attrlist,
-            'attrsonly':attrsonly
+            'filterstr': filterstr,
+            'attrlist': attrlist,
+            'attrsonly': attrsonly
         })
 
         value = self._get_return_value('search_s',
         self._record_call('search_s', {
             'base': base,
             'scope': scope,
-            'filterstr':filterstr,
-            'attrlist':attrlist,
-            'attrsonly':attrsonly
+            'filterstr': filterstr,
+            'attrlist': attrlist,
+            'attrsonly': attrsonly
         })
 
         value = self._get_return_value('search_s',
         "member": ["cn=parent_gon,ou=groups,o=test"]
     })
 
-
     mock_ldap = MockLDAP({
         alice[0]: alice[1],
         bob[0]: bob[1],
         circular_gon[0]: circular_gon[1],
     })
 
+    logging_configured = False
 
-    logging_configured = False
     def configure_logger(cls):
         if not cls.logging_configured:
             logger = logging.getLogger('django_auth_ldap')
             cls.logging_configured = True
     configure_logger = classmethod(configure_logger)
 
-
     def setUp(self):
         self.configure_logger()
         self.mock_ldap.reset()
         self.ldap = _LDAPConfig.ldap = self.mock_ldap
         self.backend = backend.LDAPBackend()
 
-
     def tearDown(self):
         pass
 
-
     def test_options(self):
         self._init_settings(
             USER_DN_TEMPLATE='uid=%(user)s,ou=people,o=test',
         self.assertEqual(user.username, 'alice')
         self.assertEqual(User.objects.count(), user_count + 1)
 
-
     def test_simple_bind_bad_user(self):
         self._init_settings(
             USER_DN_TEMPLATE='uid=%(user)s,ou=people,o=test'
         self._init_settings(
             USER_SEARCH=LDAPSearch(
                 "ou=people,o=test", self.mock_ldap.SCOPE_SUBTREE, '(uid=%(user)s)'
-                )
             )
+        )
         self.mock_ldap.set_return_value('search_s',
             ("ou=people,o=test", 2, "(uid=Alice)", None, 0), [self.alice])
         User.objects.create(username='alice')
         class MyBackend(backend.LDAPBackend):
             def ldap_to_django_username(self, username):
                 return 'ldap_%s' % username
+
             def django_to_ldap_username(self, username):
                 return username[5:]
 
         self._init_settings(
             USER_SEARCH=LDAPSearch(
                 "ou=people,o=test", self.mock_ldap.SCOPE_SUBTREE, '(uid=%(user)s)'
-                )
             )
+        )
         self.mock_ldap.set_return_value('search_s',
             ("ou=people,o=test", 2, "(uid=alice)", None, 0), [self.alice])
         user_count = User.objects.count()
         self._init_settings(
             USER_SEARCH=LDAPSearch(
                 "ou=people,o=test", self.mock_ldap.SCOPE_SUBTREE, '(cn=%(user)s)'
-                )
             )
+        )
         self.mock_ldap.set_return_value('search_s',
             ("ou=people,o=test", 2, "(cn=alice)", None, 0), [])
 
         self._init_settings(
             USER_SEARCH=LDAPSearch(
                 "ou=people,o=test", self.mock_ldap.SCOPE_SUBTREE, '(uid=*)'
-                )
             )
+        )
         self.mock_ldap.set_return_value('search_s',
             ("ou=people,o=test", 2, "(uid=*)", None, 0), [self.alice, self.bob])
 
         self._init_settings(
             USER_SEARCH=LDAPSearch(
                 "ou=people,o=test", self.mock_ldap.SCOPE_SUBTREE, '(uid=%(user)s)'
-                )
             )
+        )
         self.mock_ldap.set_return_value('search_s',
             ("ou=people,o=test", 2, "(uid=alice)", None, 0), [self.alice])
 
             BIND_PASSWORD='password',
             USER_SEARCH=LDAPSearch(
                 "ou=people,o=test", self.mock_ldap.SCOPE_SUBTREE, '(uid=%(user)s)'
-                )
             )
+        )
         self.mock_ldap.set_return_value('search_s',
             ("ou=people,o=test", 2, "(uid=alice)", None, 0), [self.alice])
 
             BIND_PASSWORD='bogus',
             USER_SEARCH=LDAPSearch(
                 "ou=people,o=test", self.mock_ldap.SCOPE_SUBTREE, '(uid=%(user)s)'
-                )
             )
+        )
 
         user = self.backend.authenticate(username='alice', password='password')
 
         self._init_settings(
             USER_DN_TEMPLATE='uid=%(user)s,ou=people,o=test'
         )
+
         def handle_populate_user(sender, **kwargs):
             self.assert_('user' in kwargs and 'ldap_user' in kwargs)
             kwargs['user'].populate_user_handled = True
         self.assert_(alice.get_profile().is_special)
         self.assert_(not bob.get_profile().is_special)
 
-
     def test_dn_group_permissions(self):
         self._init_settings(
             USER_DN_TEMPLATE='uid=%(user)s,ou=people,o=test',
         self._init_settings(
             USER_SEARCH=LDAPSearch(
                 "ou=people,o=test", self.mock_ldap.SCOPE_SUBTREE, '(uid=%(user)s)'
-                )
             )
+        )
         self.mock_ldap.set_return_value('search_s',
             ("ou=people,o=test", 2, "(uid=alice)", None, 0), [self.alice, (None, '')])
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.