Files
edx-platform/common/djangoapps/util/tests/test_course.py
Calen Pennington 04115bfe43 Revert "Merge pull request #13235 from edx/jia/MA-2684"
This reverts commit bde0f7b2a7, reversing
changes made to 71693c3a12.
2016-12-21 13:21:47 -05:00

37 lines
1.7 KiB
Python

"""
Tests for course utils.
"""
from django.test import TestCase, override_settings
import mock
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from util.course import get_lms_link_for_about_page
class LmsLinksTestCase(TestCase):
""" Tests for LMS links. """
def test_about_page(self):
""" Get URL for about page, no marketing site """
with mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}):
self.assertEquals(self.get_about_page_link(), "http://localhost:8000/courses/mitX/101/test/about")
@override_settings(MKTG_URLS={'ROOT': 'https://dummy-root'})
def test_about_page_marketing_site(self):
""" Get URL for about page, marketing root present. """
with mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}):
self.assertEquals(self.get_about_page_link(), "https://dummy-root/courses/mitX/101/test/about")
with mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': False}):
self.assertEquals(self.get_about_page_link(), "http://localhost:8000/courses/mitX/101/test/about")
@override_settings(MKTG_URLS={'ROOT': 'https://www.dummyhttps://x'})
def test_about_page_marketing_site_https__edge(self):
""" Get URL for about page """
with mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_MKTG_SITE': True}):
self.assertEquals(self.get_about_page_link(), "https://www.dummyhttps://x/courses/mitX/101/test/about")
def get_about_page_link(self):
""" create mock course and return the about page link."""
course_key = SlashSeparatedCourseKey('mitX', '101', 'test')
return get_lms_link_for_about_page(course_key)