aboutsummaryrefslogtreecommitdiff
blob: 12931ef70735f9e19219ed3df18108be4e3a6060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# vim:fileencoding=utf8:et:ts=4:sts=4:sw=4:ft=python

from django.conf import settings
from django.test import TestCase
from django.test.client import Client
from mockldap import MockLdap

from okupy.tests import vars


class SettingsIntegrationTests(TestCase):
    @classmethod
    def setUpClass(cls):
        cls.mockldap = MockLdap(vars.DIRECTORY)

    def setUp(self):
        self.client = Client()
        self.mockldap.start()
        self.ldapobj = self.mockldap[settings.AUTH_LDAP_SERVER_URI]

    def tearDown(self):
        self.mockldap.stop()

    def test_profile_settings_page_uses_correct_template(self):
        response = self.client.post('/login/', vars.LOGIN_ALICE)
        response = self.client.get('/')
        response = self.client.get('/profile-settings/')
        self.assertTemplateUsed(response, 'base.html')
        self.assertTemplateUsed(response, 'settings-profile.html')

    def test_password_settings_page_uses_correct_template(self):
        response = self.client.post('/login/', vars.LOGIN_ALICE)
        response = self.client.get('/')
        response = self.client.get('/password-settings/')
        self.assertTemplateUsed(response, 'base.html')
        self.assertTemplateUsed(response, 'settings-password.html')

    def test_email_settings_page_uses_correct_template(self):
        response = self.client.post('/login/', vars.LOGIN_ALICE)
        response = self.client.get('/')
        response = self.client.get('/email-settings/')
        self.assertTemplateUsed(response, 'base.html')
        self.assertTemplateUsed(response, 'settings-email.html')

    def test_contact_settings_page_uses_correct_template(self):
        response = self.client.post('/login/', vars.LOGIN_ALICE)
        response = self.client.get('/')
        response = self.client.get('/contact-settings/')
        self.assertTemplateUsed(response, 'base.html')
        self.assertTemplateUsed(response, 'settings-contact.html')

    def test_gentoo_account_settings_page_uses_correct_template(self):
        response = self.client.post('/login/', vars.LOGIN_ALICE)
        response = self.client.get('/')
        response = self.client.get('/gentoo-dev-settings/')
        self.assertTemplateUsed(response, 'base.html')
        self.assertTemplateUsed(response, 'settings-gentoo.html')

    def test_profile_settings_page_returns_404_for_non_auth_users(self):
        response = self.client.get('/profile-settings/')
        self.assertTrue(response.status_code, 404)

    def test_password_settings_page_returns_404_for_non_auth_users(self):
        response = self.client.get('/password-settings/')
        self.assertTrue(response.status_code, 404)

    def test_email_settings_page_returns_404_for_non_auth_users(self):
        response = self.client.get('/email-settings/')
        self.assertTrue(response.status_code, 404)

    def test_contact_setttings_page_returns_404_for_non_auth_users(self):
        response = self.client.get('/contact-settings/')
        self.assertTrue(response.status_code, 404)

    def test_gentoo_account_settings_page_returns_404_for_non_auth_users(self):
        response = self.client.get('/gentoo-dev-settings/')
        self.assertTrue(response.status_code, 404)