test_logic.py 1.51 KB
Newer Older
1 2 3 4
"""
Some additional unit tests for Microsite logic. The LMS covers some of the Microsite testing, this adds
some additional coverage
"""
5 6
import ddt
from mock import patch
7

8 9 10 11 12 13 14 15 16
from microsite_configuration.microsite import (
    get_value_for_org,
    get_backend,
)
from microsite_configuration.backends.base import BaseMicrositeBackend
from microsite_configuration.tests.tests import (
    DatabaseMicrositeTestCase,
    MICROSITE_BACKENDS,
)
17 18


19 20
@ddt.ddt
class TestMicrosites(DatabaseMicrositeTestCase):
21 22 23 24
    """
    Run through some Microsite logic
    """

25 26 27 28 29
    def setUp(self):
        super(TestMicrosites, self).setUp()

    @ddt.data(*MICROSITE_BACKENDS)
    def test_get_value_for_org_when_microsite_has_no_org(self, site_backend):
30
        """
31
        Make sure default value is returned if there's no Microsite ORG match
32
        """
33 34 35 36
        with patch('microsite_configuration.microsite.BACKEND',
                   get_backend(site_backend, BaseMicrositeBackend)):
            value = get_value_for_org("BogusX", "university", "default_value")
            self.assertEquals(value, "default_value")
37

38 39 40 41 42 43 44
    @ddt.data(*MICROSITE_BACKENDS)
    def test_get_value_for_org(self, site_backend):
        """
        Make sure get_value_for_org return value of org if it present.
        """
        with patch('microsite_configuration.microsite.BACKEND',
                   get_backend(site_backend, BaseMicrositeBackend)):
45 46
            value = get_value_for_org("TestSiteX", "university", "default_value")
            self.assertEquals(value, "test_site")