Skip to content

Commit

Permalink
Adds a couple of tests for the confirm information view
Browse files Browse the repository at this point in the history
  • Loading branch information
dirtycoder committed Nov 14, 2016
1 parent 7256d4e commit 6a261bf
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pets/users/tests/test_view_confirm_information.py
@@ -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()

0 comments on commit 6a261bf

Please sign in to comment.