Making/Creating a verified user for unit test (django-allauth)

505 views
Skip to first unread message

Desmond Lim

unread,
Aug 17, 2017, 6:20:48 AM8/17/17
to Django users
Hi there,

I'm wonder, how do we create a verified user for testing purpose

I have this line that creates a user

cls.user = get_user_model().objects.create_user(username='testuser', email='test...@testing.com', password='password')

When I do a test of this for my custom login interface

def test_login_page_login_without_verification(self):
response = self.client.post(
reverse('account_login'),
{
'login': 'test...@docdoc.com',
'password': 'password',
}
)

self.assertRedirects(response, '/accounts/testuser/')

I keep getting the error that it redirects to /accounts/confirm-email/ (which is the verification page). I'm wondering, how can I make the user verified or create a verified user, so that I can test that a verified user will be redirected to the correct page after login.

Thanks.

Desmond

Vijay Khemlani

unread,
Aug 17, 2017, 7:56:37 AM8/17/17
to django...@googlegroups.com
Check that the created user has the "is_active" field set to True

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/128591dc-b8c0-4f78-af86-faf7a42f3f0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Desmond Lim

unread,
Aug 20, 2017, 9:59:05 PM8/20/17
to Django users
Thanks Vijay. It works.
Reply all
Reply to author
Forward
0 new messages