Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a couple of tests for the confirm information view
- Loading branch information
1 parent
7256d4e
commit 6a261bf
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.shortcuts import resolve_url | ||
from django.test import TestCase | ||
|
||
from users.models import OwnerProfile | ||
|
||
|
||
class ConfirmInformationTest(TestCase): | ||
def test_redirect_to_confirmation(self): | ||
"""User not confirmed should be redirected to the edit page""" | ||
self.create_user(False) | ||
self.client.login(username='admin', password='test123') | ||
|
||
resp = self.client.get(resolve_url('users:confirm_information')) | ||
|
||
self.assertRedirects(resp, resolve_url('users:edit')) | ||
|
||
def test_redirect_to_index(self): | ||
"""Confirmed user should be redirected to the index page""" | ||
self.create_user(True) | ||
self.client.login(username='admin', password='test123') | ||
|
||
resp = self.client.get(resolve_url('users:confirm_information')) | ||
|
||
self.assertRedirects(resp, resolve_url('meupet:index')) | ||
|
||
@staticmethod | ||
def create_user(is_confirmed): | ||
user = OwnerProfile(first_name='Admin', last_name='Adminson', email='admin@example.com', | ||
username='admin', is_information_confirmed=is_confirmed) | ||
user.set_password('test123') | ||
user.save() |