Files
edx-platform/common/djangoapps/microsite_configuration/tests/tests.py
Saleem Latif 8ae92901ef 1. Merge microsites into Comprehensive Theming
2. Add site configuration overrides to theming/helpers.py
3. Move microsite.get_value from theming/helpers to site_configuration/helpers
4. Move microsite_configuration.microsite.get_value usages to site_configuration.helpers.values
2016-07-27 13:55:14 +05:00

42 lines
1.2 KiB
Python

"""
Holds base classes for microsite tests
"""
from mock import DEFAULT
from django.test import TestCase
from microsite_configuration.tests.factories import (
MicrositeFactory,
MicrositeOrganizationMappingFactory,
)
MICROSITE_BACKENDS = (
'microsite_configuration.backends.filebased.FilebasedMicrositeBackend',
'microsite_configuration.backends.database.DatabaseMicrositeBackend',
)
class DatabaseMicrositeTestCase(TestCase):
"""
Base class for microsite related tests.
"""
def setUp(self):
super(DatabaseMicrositeTestCase, self).setUp()
self.microsite = MicrositeFactory.create()
MicrositeOrganizationMappingFactory.create(microsite=self.microsite, organization='TestSiteX')
def side_effect_for_get_value(value, return_value):
"""
returns a side_effect with given return value for a given value
"""
def side_effect(*args, **kwargs): # pylint: disable=unused-argument
"""
A side effect for tests which returns a value based
on a given argument otherwise return actual function.
"""
if args[0] == value:
return return_value
else:
return DEFAULT
return side_effect