test_views.py 692 Bytes
Newer Older
Ola Hermann Opheim's avatar
Ola Hermann Opheim committed
1
2
3
import unittest
from django.test import Client

Ola Hermann Opheim's avatar
Ola Hermann Opheim committed
4
from test_helpers import create_test_user, delete_test_data
Ola Hermann Opheim's avatar
Ola Hermann Opheim committed
5

Ola Hermann Opheim's avatar
autopep    
Ola Hermann Opheim committed
6

Ola Hermann Opheim's avatar
Ola Hermann Opheim committed
7
8
9
10
11
12
13
14
15
class HomeViewRegressionTest(unittest.TestCase):
    def setUp(self):
        self.client = Client()
        create_test_user()

    def tearDown(self):
        delete_test_data()

    def test_authenticated_user(self):
Ola Hermann Opheim's avatar
autopep    
Ola Hermann Opheim committed
16
        self.client.login(username='User', password='top_secret')
Ola Hermann Opheim's avatar
Ola Hermann Opheim committed
17
18
19
20
21
        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)
Ola Hermann Opheim's avatar
autopep    
Ola Hermann Opheim committed
22
        self.assertTrue(('/projects/', 302) in response.redirect_chain)