test_views.py 721 Bytes
Newer Older
Ola Hermann Opheim's avatar
Ola Hermann Opheim committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import unittest
from django.test import Client

from test_helpers import create_test_user, delete_test_data, create_multiple_test_data

class HomeViewRegressionTest(unittest.TestCase):
    def setUp(self):
        self.client = Client()
        create_test_user()

    def tearDown(self):
        delete_test_data()

    def test_authenticated_user(self):
        self.client.login(username= 'User', password= 'top_secret')
        response = self.client.get('/', follow=True)
        self.assertTrue(('/projects/', 302) not in response.redirect_chain)

    def test_unauthenticated_user(self):
        response = self.client.get('/', follow=True)
        self.assertTrue(('/projects/', 302) in response.redirect_chain)