@@ -262,9 +262,10 @@ def testImportFunc(self):
262
262
with self .settings (LDAP_AUTH_SYNC_USER_RELATIONS = 'django.contrib.auth.get_user_model' ):
263
263
self .assertTrue (callable (import_func (settings .LDAP_AUTH_SYNC_USER_RELATIONS )))
264
264
265
- # User cleaning.
266
-
267
265
def testCleanUsersDeactivate (self ):
266
+ """
267
+ ldap_clean_users management command test
268
+ """
268
269
from django .contrib .auth import get_user_model
269
270
User = get_user_model ()
270
271
_username = "nonldap{user}" .format (user = settings .LDAP_AUTH_TEST_USER_USERNAME )
@@ -280,7 +281,9 @@ def testCleanUsersDeactivate(self):
280
281
self .assertEqual (user_count_1 , user_count_2 )
281
282
self .assertEqual (User .objects .get (username = _username ).is_active , False )
282
283
283
- ### Test with lookup
284
+ """
285
+ Test with lookup
286
+ """
284
287
# Reactivate user
285
288
user = User .objects .get (username = _username )
286
289
user .is_active = True
@@ -309,12 +312,12 @@ def testCleanUsersDeactivate(self):
309
312
self .assertEqual (User .objects .get (username = _username ).is_active , False )
310
313
self .assertEqual (User .objects .get (username = _usernameLookup ).is_active , True )
311
314
# Lookup a non existing user (raise a CommandError)
312
- try :
315
+ with self . assertRaises ( CommandError ) :
313
316
call_command ("ldap_clean_users" , 'doesnonexist' , verbosity = 0 )
314
- except Exception as e :
315
- print (e )
316
317
317
- ### Test with superuser
318
+ """
319
+ Test with superuser
320
+ """
318
321
# Reactivate first user and promote to superuser
319
322
user = User .objects .get (username = _username )
320
323
user .is_active = True
@@ -330,7 +333,9 @@ def testCleanUsersDeactivate(self):
330
333
call_command ("ldap_clean_users" , superuser = True , verbosity = 0 )
331
334
self .assertEqual (User .objects .get (username = _username ).is_active , False )
332
335
333
- ### Test with staff user
336
+ """
337
+ Test with staff user
338
+ """
334
339
# Reactivate first user and promote to staff
335
340
user = User .objects .get (username = _username )
336
341
user .is_active = True
@@ -348,6 +353,9 @@ def testCleanUsersDeactivate(self):
348
353
self .assertEqual (User .objects .get (username = _username ).is_active , False )
349
354
350
355
def testCleanUsersPurge (self ):
356
+ """
357
+ ldap_clean_users management command test with purge argument
358
+ """
351
359
from django .contrib .auth import get_user_model
352
360
User = get_user_model ()
353
361
user = User .objects .create_user (
0 commit comments