Ticket #13914: tests.diff

File tests.diff, 2.1 KB (added by Juarez Bochi, 14 years ago)
  • django/contrib/auth/tests/__init__.py

     
    44from django.contrib.auth.tests.forms import UserCreationFormTest, AuthenticationFormTest, SetPasswordFormTest, PasswordChangeFormTest, UserChangeFormTest, PasswordResetFormTest
    55from django.contrib.auth.tests.remote_user \
    66        import RemoteUserTest, RemoteUserNoCreateTest, RemoteUserCustomTest
    7 from django.contrib.auth.tests.models import ProfileTestCase
     7from django.contrib.auth.tests.models import ProfileTestCase, NaturalKeysTestCase
    88from django.contrib.auth.tests.tokens import TokenGeneratorTest
    99from django.contrib.auth.tests.views \
    1010        import PasswordResetTest, ChangePasswordTest, LoginTest, LogoutTest
  • django/contrib/auth/tests/models.py

     
    11from django.conf import settings
    22from django.test import TestCase
    3 from django.contrib.auth.models import User, SiteProfileNotAvailable
     3from django.contrib.auth.models import Group, User, SiteProfileNotAvailable
    44
    55class ProfileTestCase(TestCase):
    66    fixtures = ['authtestdata.json']
     
    3333        # module that doesn't exist
    3434        settings.AUTH_PROFILE_MODULE = 'foo.bar'
    3535        self.assertRaises(SiteProfileNotAvailable, user.get_profile)
     36
     37
     38class NaturalKeysTestCase(TestCase):
     39    fixtures = ['authtestdata.json']
     40    def test_user_natural_key(self):
     41        staff_user = User.objects.get(username='staff')
     42        self.assertEquals(User.objects.get_by_natural_key('staff'), staff_user)
     43        self.assertEquals(staff_user.natural_key(), ('staff',))
     44
     45    def test_group_natural_key(self):
     46        users_group = Group.objects.create(name='users')
     47        self.assertEquals(Group.objects.get_by_natural_key('users'), users_group)
     48        self.assertEquals(users_group.natural_key(), ('users',))
Back to Top