from django.test import TestCase
from django.test.utils import override_settings
from django.core.urlresolvers import reverse
from django.conf import settings
from mitxmako.shortcuts import marketing_link
from mock import patch


class ShortcutsTests(TestCase):
    """
    Test the mitxmako shortcuts file
    """

    @override_settings(MKTG_URLS={'ROOT': 'dummy-root', 'ABOUT': '/about-us'})
    @override_settings(MKTG_URL_LINK_MAP={'ABOUT': 'about_edx'})
    def test_marketing_link(self):
        # test marketing site on
        with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': True}):
            expected_link = 'dummy-root/about-us'
            link = marketing_link('ABOUT')
            self.assertEquals(link, expected_link)
        # test marketing site off
        with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': False}):
            expected_link = reverse('about_edx')
            link = marketing_link('ABOUT')
            self.assertEquals(link, expected_link)

from django.test import TestCase
from django.test.utils import override_settings
from django.core.urlresolvers import reverse
from django.conf import settings
from mitxmako.shortcuts import marketing_link
from mock import patch


class ShortcutsTests(TestCase):
    """
    Test the mitxmako shortcuts file
    """

    @override_settings(MKTG_URLS={'ROOT': 'dummy-root', 'ABOUT': '/about-us'})
    @override_settings(MKTG_URL_LINK_MAP={'ABOUT': 'login'})
    def test_marketing_link(self):
        # test marketing site on
        with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': True}):
            expected_link = 'dummy-root/about-us'
            link = marketing_link('ABOUT')
            self.assertEquals(link, expected_link)
        # test marketing site off
        with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': False}):
            # we are using login because it is common across both cms and lms
            expected_link = reverse('login')
            link = marketing_link('ABOUT')
            self.assertEquals(link, expected_link)

Fix test so that it works with both CMS and LMS settings
Fix test so that it works with both CMS and LMS settings

  from django.test import TestCase
  from django.test.utils import override_settings
  from django.core.urlresolvers import reverse
  from django.conf import settings
  from mitxmako.shortcuts import marketing_link
  from mock import patch
  
  
  class ShortcutsTests(TestCase):
      """
      Test the mitxmako shortcuts file
      """
  
      @override_settings(MKTG_URLS={'ROOT': 'dummy-root', 'ABOUT': '/about-us'})
-     @override_settings(MKTG_URL_LINK_MAP={'ABOUT': 'about_edx'})
+     @override_settings(MKTG_URL_LINK_MAP={'ABOUT': 'login'})
      def test_marketing_link(self):
          # test marketing site on
          with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': True}):
              expected_link = 'dummy-root/about-us'
              link = marketing_link('ABOUT')
              self.assertEquals(link, expected_link)
          # test marketing site off
          with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': False}):
+             # we are using login because it is common across both cms and lms
-             expected_link = reverse('about_edx')
+             expected_link = reverse('login')
              link = marketing_link('ABOUT')
              self.assertEquals(link, expected_link)
  
Fix test so that it works with both CMS and LMS settings
## Code Before:
from django.test import TestCase
from django.test.utils import override_settings
from django.core.urlresolvers import reverse
from django.conf import settings
from mitxmako.shortcuts import marketing_link
from mock import patch


class ShortcutsTests(TestCase):
    """
    Test the mitxmako shortcuts file
    """

    @override_settings(MKTG_URLS={'ROOT': 'dummy-root', 'ABOUT': '/about-us'})
    @override_settings(MKTG_URL_LINK_MAP={'ABOUT': 'about_edx'})
    def test_marketing_link(self):
        # test marketing site on
        with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': True}):
            expected_link = 'dummy-root/about-us'
            link = marketing_link('ABOUT')
            self.assertEquals(link, expected_link)
        # test marketing site off
        with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': False}):
            expected_link = reverse('about_edx')
            link = marketing_link('ABOUT')
            self.assertEquals(link, expected_link)

## Instruction:
Fix test so that it works with both CMS and LMS settings
## Code After:
from django.test import TestCase
from django.test.utils import override_settings
from django.core.urlresolvers import reverse
from django.conf import settings
from mitxmako.shortcuts import marketing_link
from mock import patch


class ShortcutsTests(TestCase):
    """
    Test the mitxmako shortcuts file
    """

    @override_settings(MKTG_URLS={'ROOT': 'dummy-root', 'ABOUT': '/about-us'})
    @override_settings(MKTG_URL_LINK_MAP={'ABOUT': 'login'})
    def test_marketing_link(self):
        # test marketing site on
        with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': True}):
            expected_link = 'dummy-root/about-us'
            link = marketing_link('ABOUT')
            self.assertEquals(link, expected_link)
        # test marketing site off
        with patch.dict('django.conf.settings.MITX_FEATURES', {'ENABLE_MKTG_SITE': False}):
            # we are using login because it is common across both cms and lms
            expected_link = reverse('login')
            link = marketing_link('ABOUT')
            self.assertEquals(link, expected_link)
