mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-11 08:43:10 +00:00
Add userprofile creation method tests
This commit is contained in:
parent
4ce37c2653
commit
64058c989a
1 changed files with 17 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from django.test import TestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth.models import User
|
||||
from wagtail.wagtailusers.models import User, UserProfile
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
|
||||
|
||||
|
|
@ -114,3 +114,19 @@ class TestUserEditView(TestCase, WagtailTestUtils):
|
|||
|
||||
# Should not redirect to index
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class TestUserProfileCreation(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
# Create a user
|
||||
self.test_user = User.objects.create_user(username='testuser', email='testuser@email.com', password='password')
|
||||
|
||||
def test_user_created_without_profile(self):
|
||||
self.assertEqual(UserProfile.objects.filter(user=self.test_user).count(), 0)
|
||||
with self.assertRaises(UserProfile.DoesNotExist):
|
||||
self.test_user.userprofile
|
||||
|
||||
def test_user_profile_created_when_method_called(self):
|
||||
self.assertIsInstance(self.test_user.get_profile(), UserProfile)
|
||||
# and get it from the db too
|
||||
self.assertEqual(UserProfile.objects.filter(user=self.test_user).count(), 1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue