~ubuntuone-pqm-team/canonical-identity-provider/trunk

« back to all changes in this revision

Viewing changes to identityprovider/tests/test_static.py

  • Committer: Danny Tamez
  • Date: 2010-04-21 15:29:24 UTC
  • Revision ID: danny.tamez@canonical.com-20100421152924-lq1m92tstk2iz75a
Canonical SSO Provider (Open Source) - Initial Commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2010 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
from django.conf import settings
 
5
from django.shortcuts import render_to_response
 
6
from django.template import RequestContext
 
7
 
 
8
import identityprovider.branding
 
9
from identityprovider.tests.utils import SQLCachedTestCase
 
10
 
 
11
 
 
12
class DummyRequest(object):
 
13
    pass
 
14
 
 
15
 
 
16
class BrandingTestCase(SQLCachedTestCase):
 
17
    def setUp(self):
 
18
        self.BRAND = settings.BRAND
 
19
 
 
20
    def tearDown(self):
 
21
        self.set_branding(self.BRAND)
 
22
 
 
23
    def set_branding(self, branding):
 
24
        # reload settings
 
25
        settings.BRAND = branding
 
26
 
 
27
        reload(identityprovider.branding)
 
28
        reload(identityprovider.context_processors)
 
29
 
 
30
    def test_openid(self):
 
31
        self.set_branding('Ubuntu')
 
32
        r = self.client.get('/+openid')
 
33
        self.assertContains(r, "This is the Ubuntu SSO service")
 
34
        self.set_branding('Launchpad')
 
35
        r = self.client.get('/+openid')
 
36
        self.assertContains(r, "This is the Launchpad login service")
 
37
 
 
38
    def test_decide(self):
 
39
        self.set_branding('Ubuntu')
 
40
        req = DummyRequest()
 
41
        context = RequestContext(req, {'trust_root': 'foo', })
 
42
        response = render_to_response('decide.html', context)
 
43
        self.assertContains(response, 'recognised by\nUbuntu')
 
44
 
 
45
        self.set_branding('Launchpad')
 
46
        req = DummyRequest()
 
47
        context = RequestContext(req, {'trust_root': 'foo', })
 
48
        response = render_to_response('decide.html', context)
 
49
        self.assertContains(response, 'recognised by\nLaunchpad')
 
50
 
 
51
 
 
52
class StaticPageTestCase(SQLCachedTestCase):
 
53
    def test_faq_page(self):
 
54
        r = self.client.get('/+faq')
 
55
        self.assertContains(r, "Frequently asked questions")
 
56
        r = self.client.get('/+description')
 
57
        self.assertContains(r, "What's this?")