1. Waldemar Kornewald
  2. djangotoolbox

Commits

d3f3nd3r  committed d0bd900

some code style fixes

  • Participants
  • Parent commits 0a47fec
  • Branches default

Comments (0)

Files changed (1)

File djangotoolbox/auth/tests.py

View file
  • Ignore whitespace
-from django.conf import settings
-from django.db import models
 from django.contrib.auth import authenticate
 from django.contrib.auth.models import User, Group, Permission, AnonymousUser
 from django.contrib.contenttypes.models import ContentType
 from django.test import TestCase
 
-from djangotoolbox.auth.models import UserPermissionList, GroupPermissionList, GroupList
-from djangotoolbox.auth.utils import add_permission_to_user, add_user_to_group, add_permission_to_group
+from djangotoolbox.auth.models import UserPermissionList, \
+     GroupPermissionList, GroupList
+from djangotoolbox.auth.utils import add_permission_to_user, \
+     add_user_to_group, add_permission_to_group
 
 
 class BackendTest(TestCase):
         User.objects.create_user('test', 'test@example.com', 'test')
 
     def test_add_permission_to_user(self):
-        content_type=ContentType.objects.get_for_model(User)
-        perm = Permission.objects.create(name='test', content_type=content_type, codename='test')
+        content_type = ContentType.objects.get_for_model(User)
+        perm = Permission.objects.create(name='test',
+                                         content_type=content_type,
+                                         codename='test')
         user = User.objects.get(username='test')
         self.assertEqual(user.has_perm('auth.test'), False)
         user = User.objects.get(username='test')
         self.assertNotEqual(GroupList.objects.all()[0] , None)
 
     def test_add_permission_to_group(self):
-        content_type=ContentType.objects.get_for_model(Group)
-        perm = Permission.objects.create(name='test', content_type=content_type, codename='test')
+        content_type = ContentType.objects.get_for_model(Group)
+        perm = Permission.objects.create(name='test',
+                                         content_type=content_type,
+                                         codename='test')
         user = User.objects.get(username='test')
         self.assertEqual(user.has_perm('auth.test'), False)
         user = User.objects.get(username='test')
         user.is_active = False
         user.save()
         self.assertEqual(user.has_perm('auth.test'), False)
-        
-        
+
     def test_custom_perms(self):
         user = User.objects.get(username='test')
-        content_type=ContentType.objects.get_for_model(Permission)
-        perm = Permission.objects.create(name='test', content_type=content_type, codename='test')
+        content_type = ContentType.objects.get_for_model(Permission)
+        perm = Permission.objects.create(name='test',
+                                         content_type=content_type,
+                                         codename='test')
         # default django way (ManyToManyField)
         #user.user_permissions.add(perm)      
 
         self.assertEqual(user.has_module_perms('Group'), False)
         self.assertEqual(user.has_module_perms('auth'), True)
         
-        perm = Permission.objects.create(name='test2', content_type=content_type, codename='test2')
+        perm = Permission.objects.create(name='test2',
+                                         content_type=content_type,
+                                         codename='test2')
         
         # default django way (ManyToManyField)
         #user.user_permissions.add(perm)
 
         add_permission_to_user(perm, user)
         
-        perm = Permission.objects.create(name='test3', content_type=content_type, codename='test3')
+        perm = Permission.objects.create(name='test3',
+                                         content_type=content_type,
+                                         codename='test3')
 
         # default django  way (ManyToManyField)
         #user.user_permissions.add(perm)
         add_permission_to_user(perm, user)
 
         user = User.objects.get(username='test')
-        self.assertEqual(user.get_all_permissions(), set([u'auth.test2', u'auth.test', u'auth.test3']))
+        self.assertEqual(user.get_all_permissions(),
+                         set([u'auth.test2', u'auth.test', u'auth.test3']))
         self.assertEqual(user.has_perm('test'), False)
         self.assertEqual(user.has_perm('auth.test'), True)
         self.assertEqual(user.has_perms(['auth.test2', 'auth.test3']), True)
         
-        perm = Permission.objects.create(name='test_group', content_type=content_type, codename='test_group')
+        perm = Permission.objects.create(name='test_group',
+                                         content_type=content_type,
+                                         codename='test_group')
         group = Group.objects.create(name='test_group')
 
         # default django way (ManyToManyField)
         add_user_to_group(user, group)
         
         user = User.objects.get(username='test')
-        exp = set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group'])
+        exp = set([u'auth.test2', u'auth.test',
+                   u'auth.test3', u'auth.test_group'])
         self.assertEqual(user.get_all_permissions(), exp)
-        self.assertEqual(user.get_group_permissions(), set([u'auth.test_group']))
-        self.assertEqual(user.has_perms(['auth.test3', 'auth.test_group']), True)
+        self.assertEqual(user.get_group_permissions(),
+                         set([u'auth.test_group']))
+        self.assertEqual(user.has_perms(['auth.test3', 'auth.test_group']),
+                         True)
 
         user = AnonymousUser()
         self.assertEqual(user.has_perm('test'), False)
         self.assertEqual(user.has_perms(['auth.test2', 'auth.test3']), False)
         
-        
     def test_has_no_object_perm(self):
         """Regressiontest for #12462"""
         
         user = User.objects.get(username='test')
-        content_type=ContentType.objects.get_for_model(Group)
+        content_type = ContentType.objects.get_for_model(Group)
         content_type.save()
-        perm = Permission.objects.create(name='test', content_type=content_type, codename='test')
+        perm = Permission.objects.create(name='test',
+                                         content_type=content_type,
+                                         codename='test')
         
         # default django way (ManyToManyField)
         #user.user_permissions.add(perm)
         self.assertEqual(user.has_perm('auth.test'), True)
         self.assertEqual(user.get_all_permissions(), set(['auth.test']))
         
-
     def test_authenticate(self):
-       user = User.objects.get(username='test')
-       self.assertEquals(authenticate(username='test', password='test'), user)
-       self.assertEquals(authenticate(username='test', password='testNones'), None)
+        user = User.objects.get(username='test')
+        self.assertEquals(authenticate(username='test', password='test'), user)
+        self.assertEquals(authenticate(username='test', password='testNones'),
+                          None)