def with_site_configuration(domain='test.localhost', configuration=None):
 def _decorator(func):
  @wraps(func)
  def _decorated(*args, **kwargs):
   (site, __) = Site.objects.get_or_create(domain=domain, name=domain)
   (site_configuration, created) = SiteConfiguration.objects.get_or_create(site=site, defaults={'enabled': True, 'values': configuration})
   if (not created):
    site_configuration.values = configuration
    site_configuration.save()
   with patch('openedx.core.djangoapps.site_configuration.helpers.get_current_site_configuration', return_value=site_configuration):
    with patch('openedx.core.djangoapps.theming.helpers.get_current_site', return_value=site):
     with patch('django.contrib.sites.models.SiteManager.get_current', return_value=site):
      return func(*args, **kwargs)
  return _decorated
 return _decorator

def with_site_configuration ( domain = 'test.localhost' , configuration = None ) : def _decorator ( func ) : @ wraps ( func ) def _decorated ( * args , ** kwargs ) : ( site , __ ) = Site . objects . get_or_create ( domain = domain , name = domain ) ( site_configuration , created ) = SiteConfiguration . objects . get_or_create ( site = site , defaults = { 'enabled' : True , 'values' : configuration } ) if ( not created ) : site_configuration . values = configuration site_configuration . save ( ) with patch ( 'openedx.core.djangoapps.site_configuration.helpers.get_current_site_configuration' , return_value = site_configuration ) : with patch ( 'openedx.core.djangoapps.theming.helpers.get_current_site' , return_value = site ) : with patch ( 'django.contrib.sites.models.SiteManager.get_current' , return_value = site ) : return func ( * args , ** kwargs ) return _decorated return _decorator
a decorator to run a test with a configuration enabled .