Commit 23c1ee32 by Ned Batchelder Committed by GitHub

Merge pull request #14679 from edx/nedbat/flexible-help-link-tests

HelpContextProcessorTest improvements from the Ficus branch.
parents 40621b6c 5e5f0c17
...@@ -21,9 +21,6 @@ class HelpContextProcessorTest(TestCase): ...@@ -21,9 +21,6 @@ class HelpContextProcessorTest(TestCase):
Tests for help_context_processor.py Tests for help_context_processor.py
""" """
def setUp(self):
super(HelpContextProcessorTest, self).setUp()
@staticmethod @staticmethod
def _get_doc_url(page_token=None): def _get_doc_url(page_token=None):
""" Helper method for getting the doc url. """ """ Helper method for getting the doc url. """
...@@ -36,34 +33,34 @@ class HelpContextProcessorTest(TestCase): ...@@ -36,34 +33,34 @@ class HelpContextProcessorTest(TestCase):
def test_get_doc_url(self): def test_get_doc_url(self):
# Test default values. # Test default values.
self.assertEqual( self.assertRegexpMatches(
"http://edx.readthedocs.io/projects/open-edx-learner-guide/en/latest/index.html", self._get_doc_url(),
HelpContextProcessorTest._get_doc_url() "http://edx.readthedocs.io/projects/open-edx-learner-guide/en/.*/index.html"
) )
# Provide a known page_token. # Provide a known page_token.
self.assertEqual( self.assertRegexpMatches(
"http://edx.readthedocs.io/projects/open-edx-learner-guide/en/latest/sfd_dashboard_profile/index.html", self._get_doc_url('profile'),
HelpContextProcessorTest._get_doc_url('profile') "http://edx.readthedocs.io/projects/open-edx-learner-guide/en/.*/sfd_dashboard_profile/index.html"
) )
# Use settings.DOC_LINK_BASE_URL to override default base_url. # Use settings.DOC_LINK_BASE_URL to override default base_url.
with patch('django.conf.settings.DOC_LINK_BASE_URL', 'settings_base_url'): with patch('django.conf.settings.DOC_LINK_BASE_URL', 'settings_base_url'):
self.assertEqual( self.assertRegexpMatches(
"settings_base_url/en/latest/SFD_instructor_dash_help.html", self._get_doc_url('instructor'),
HelpContextProcessorTest._get_doc_url('instructor') "settings_base_url/en/.*/SFD_instructor_dash_help.html"
) )
def test_get_pdf_url(self): def test_get_pdf_url(self):
# Test default values. # Test default values.
self.assertEqual( self.assertRegexpMatches(
"https://media.readthedocs.org/pdf/open-edx-learner-guide/latest/open-edx-learner-guide.pdf", self._get_pdf_url(),
HelpContextProcessorTest._get_pdf_url() "https://media.readthedocs.org/pdf/open-edx-learner-guide/.*/open-edx-learner-guide.pdf"
) )
# Use settings.DOC_LINK_BASE_URL to override default base_url. # Use settings.DOC_LINK_BASE_URL to override default base_url.
with patch('django.conf.settings.DOC_LINK_BASE_URL', 'settings_base_url'): with patch('django.conf.settings.DOC_LINK_BASE_URL', 'settings_base_url'):
self.assertEqual( self.assertRegexpMatches(
"settings_base_url/latest/open-edx-learner-guide.pdf", self._get_pdf_url(),
HelpContextProcessorTest._get_pdf_url() "settings_base_url/.*/open-edx-learner-guide.pdf"
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment