Commits

Anonymous committed 9fbac5f

adjust tests use groups and user_permissions again

Comments (0)

Files changed (1)

djangotoolbox/contrib/auth/tests/auth_backends.py

         content_type=ContentType.objects.get_for_model(Group)
         perm = Permission.objects.create(name='test', content_type=content_type, codename='test')
         # default django way (ManyToManyField)
-        #user.user_permissions.add(perm)
-
-        # curent djangotoolbox.contrib.auth api
-        user.user_permissions.permissions.append(perm.id)
+        user.user_permissions.add(perm)
         
         user.save()
         # reloading user to purge the _perm_cache
         self.assertEqual(user.has_module_perms('auth'), True)
         
         perm = Permission.objects.create(name='test2', content_type=content_type, codename='test2')
+
         # default django way (ManyToManyField)
-        #user.user_permissions.add(perm)
-
-        # curent djangotoolbox.contrib.auth api
-        user.user_permissions.permissions.append(perm.id)
+        user.user_permissions.add(perm)
 
         user.save()
         perm = Permission.objects.create(name='test3', content_type=content_type, codename='test3')
+
         # default django  way (ManyToManyField)
-        #user.user_permissions.add(perm)
+        user.user_permissions.add(perm)
 
-        # curent djangotoolbox.contrib.auth api
-        user.user_permissions.permissions.append(perm.id)
-        
         user.save()
         user = User.objects.get(username='test')
         self.assertEqual(user.get_all_permissions(), set([u'auth.test2', u'auth.test', u'auth.test3']))
         group.save()
 
         # default django way (ManyToManyField)
-        #user.groups.add(group)
+        user.groups.add(group)
 
-        # current djangotoolbox way
+        # djangotoolbox.contrib.auth needs save()
+        user.save()
+
+        """# current djangotoolbox way
         user.group_list.groups.append(group.id)
         user.save()
+        """
         
         user = User.objects.get(username='test')
         exp = set([u'auth.test2', u'auth.test', u'auth.test3', u'auth.test_group'])
         perm = Permission.objects.create(name='test', content_type=content_type, codename='test')
         
         # default django way (ManyToManyField)
-        #user.user_permissions.add(perm)
-
-        # curent djangotoolbox.contrib.auth api
-        user.user_permissions.permissions.append(perm.id)
+        user.user_permissions.add(perm)
 
         user.save()
 
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.