test_footer.py 2.29 KB
Newer Older
1 2 3 4 5
"""
Tests related to the basic footer-switching based off SITE_NAME to ensure
edx.org uses an edx footer but other instances use an Open edX footer.
"""

6
import unittest
7

8
from django.conf import settings
9
from django.test import TestCase
10
from django.test.utils import override_settings
11
from nose.plugins.attrib import attr
12

13
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme
David Baumgold committed
14

15

16
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
17
@attr(shard=1)
18
class TestFooter(TestCase):
19 20 21
    """
    Tests for edx and OpenEdX footer
    """
22

23 24 25 26 27 28 29 30 31 32 33
    SOCIAL_MEDIA_NAMES = [
        "facebook",
        "google_plus",
        "twitter",
        "linkedin",
        "tumblr",
        "meetup",
        "reddit",
        "youtube",
    ]

34 35 36 37 38 39 40 41 42 43 44
    SOCIAL_MEDIA_URLS = {
        "facebook": "http://www.facebook.com/",
        "google_plus": "https://plus.google.com/",
        "twitter": "https://twitter.com/",
        "linkedin": "http://www.linkedin.com/",
        "tumblr": "http://www.tumblr.com/",
        "meetup": "http://www.meetup.com/",
        "reddit": "http://www.reddit.com/",
        "youtube": "https://www.youtube.com/"
    }

45
    @with_comprehensive_theme("edx.org")
46 47 48 49
    def test_edx_footer(self):
        """
        Verify that the homepage, when accessed at edx.org, has the edX footer
        """
David Baumgold committed
50 51 52
        resp = self.client.get('/')
        self.assertEqual(resp.status_code, 200)
        self.assertContains(resp, 'footer-edx-v3')
53 54 55 56 57 58

    def test_openedx_footer(self):
        """
        Verify that the homepage, when accessed at something other than
        edx.org, has the Open edX footer
        """
David Baumgold committed
59 60 61
        resp = self.client.get('/')
        self.assertEqual(resp.status_code, 200)
        self.assertContains(resp, 'footer-openedx')
62

63
    @with_comprehensive_theme("edx.org")
64 65 66 67
    @override_settings(
        SOCIAL_MEDIA_FOOTER_NAMES=SOCIAL_MEDIA_NAMES,
        SOCIAL_MEDIA_FOOTER_URLS=SOCIAL_MEDIA_URLS
    )
68 69 70 71 72 73
    def test_edx_footer_social_links(self):
        resp = self.client.get('/')
        for name, url in self.SOCIAL_MEDIA_URLS.iteritems():
            self.assertContains(resp, url)
            self.assertContains(resp, settings.SOCIAL_MEDIA_FOOTER_DISPLAY[name]['title'])
            self.assertContains(resp, settings.SOCIAL_MEDIA_FOOTER_DISPLAY[name]['icon'])