def __init__(self): self.host_patterns = get_host_patterns() try: self.default_host = get_host(settings.DEFAULT_HOST) except AttributeError: raise ImproperlyConfigured("Missing DEFAULT_HOST setting") except NoReverseMatch, e: raise ImproperlyConfigured("Invalid DEFAULT_HOST setting: %s" % e)
def test_get_host_patterns(self): self.assertRaisesWithMessage(ImproperlyConfigured, 'Missing ROOT_HOSTCONF setting', get_host_patterns) with self.settings(ROOT_HOSTCONF='django_hosts.tests.hosts'): self.assertRaisesWithMessage(ImproperlyConfigured, "Missing host_patterns in 'django_hosts.tests.hosts'", get_host_patterns) with self.settings(ROOT_HOSTCONF='django_hosts.tests.hosts.simple'): from django_hosts.tests.hosts import simple self.assertEqual(get_host_patterns(), simple.host_patterns)
def __init__(self): self.host_patterns = get_host_patterns() try: self.default_host = get_host(settings.DEFAULT_HOST) except AttributeError: raise ImproperlyConfigured("Missing DEFAULT_HOST setting") except NoReverseMatch as e: raise ImproperlyConfigured("Invalid DEFAULT_HOST setting: %s" % e) middlewares = list(settings.MIDDLEWARE_CLASSES) try: if middlewares.index(hosts_middleware) > middlewares.index(toolbar_middleware): raise ImproperlyConfigured( "The django_hosts and debug_toolbar middlewares " "are in the wrong order. Make sure %r comes before " "%r in the MIDDLEWARE_CLASSES setting." % (hosts_middleware, toolbar_middleware) ) except ValueError: # django-debug-toolbar middleware doesn't seem to be installed pass
def __init__(self): self.host_patterns = get_host_patterns() try: self.default_host = get_host(settings.DEFAULT_HOST) except AttributeError: raise ImproperlyConfigured("Missing DEFAULT_HOST setting") except NoReverseMatch as e: raise ImproperlyConfigured("Invalid DEFAULT_HOST setting: %s" % e) middlewares = list(settings.MIDDLEWARE_CLASSES) try: if (middlewares.index(hosts_middleware) > middlewares.index(toolbar_middleware)): raise ImproperlyConfigured( "The django_hosts and debug_toolbar middlewares " "are in the wrong order. Make sure %r comes before " "%r in the MIDDLEWARE_CLASSES setting." % (hosts_middleware, toolbar_middleware)) except ValueError: # django-debug-toolbar middleware doesn't seem to be installed pass
def test_get_working_host_patterns(self): from django_hosts.tests.hosts import simple self.assertEqual(get_host_patterns(), simple.host_patterns)