def test_host_nonexistent_callback(self):
        api_host = host(r'api',
                        'api.urls',
                        name='api',
                        callback='whatever.non_existent')
        self.assertRaisesMessageIn(
            ImproperlyConfigured,
            "Could not import 'whatever'. Error was: No module named",
            lambda: api_host.callback)

        api_host = host(r'api',
                        'api.urls',
                        name='api',
                        callback='django_hosts.non_existent')
        try:
            self.assertRaisesMessageIn(
                ImproperlyConfigured,
                "Could not import 'django_hosts.non_existent'. "
                "Callable does not exist in module", lambda: api_host.callback)
        except Exception:  # Django < 1.8
            self.assertRaisesMessageIn(
                ImproperlyConfigured,
                "Could not import django_hosts.non_existent. "
                "Callable does not exist in module", lambda: api_host.callback)

        api_host = host(r'api',
                        'api.urls',
                        name='api',
                        callback='tests.broken_module.yeah_yeah')
        self.assertRaises(ImproperlyConfigured, lambda: api_host.callback)
Пример #2
0
    def test_host_nonexistent_callback(self):
        api_host = host(r'api', 'api.urls', name='api',
                        callback='whatever.non_existent')
        self.assertRaisesWithMessageIn(ImproperlyConfigured,
            "Could not import 'whatever'. Error was: No module named",
            lambda: api_host.callback)

        api_host = host(r'api', 'api.urls', name='api',
                        callback='django_hosts.non_existent')
        self.assertRaisesWithMessageIn(ImproperlyConfigured,
            "Could not import django_hosts.non_existent. "
            "Callable does not exist in module",
            lambda: api_host.callback)
Пример #3
0
    def test_host_nonexistent_callback(self):
        api_host = host(r'api', 'api.urls', name='api', callback='whatever.non_existent')
        self.assertRaisesWithMessage(
            ImproperlyConfigured,
            "Could not import 'whatever'. Error was: No module named whatever",
            lambda: api_host.callback)

        api_host = host(r'api', 'api.urls', name='api', callback='django_hosts.non_existent')
        self.assertRaisesWithMessage(
            ImproperlyConfigured,
            "Tried 'non_existent' in module 'django_hosts'. "
            "Error was: 'module' object has no attribute 'non_existent'",
            lambda: api_host.callback)
 def test_pattern_with_prefix(self):
     host_patterns = patterns('mysite',
         host(r'api', 'api.urls', name='api'),
     )
     self.assertEqual(len(host_patterns), 1)
     self.assertTrue(isinstance(host_patterns[0], host))
     self.assertEqual(host_patterns[0].urlconf, 'mysite.api.urls')
Пример #5
0
 def test_pattern_with_prefix(self):
     host_patterns = patterns('mysite',
         host(r'api', 'api.urls', name='api'),
     )
     self.assertEqual(len(host_patterns), 1)
     self.assertTrue(isinstance(host_patterns[0], host))
     self.assertEqual(host_patterns[0].urlconf, 'mysite.api.urls')
Пример #6
0
 def test_pattern(self):
     host_patterns = patterns('',
         host(r'api', 'api.urls', name='api'),
     )
     self.assertEqual(len(host_patterns), 1)
     self.assertTrue(isinstance(host_patterns[0], host))
     self.assertEqual(repr(host_patterns[0]),
                      "<host api: api.urls ('api')>")
Пример #7
0
 def test_pattern(self):
     host_patterns = patterns('',
         host(r'api', 'api.urls', name='api'),
     )
     self.assertEqual(len(host_patterns), 1)
     self.assertTrue(isinstance(host_patterns[0], host))
     self.assertEqual(repr(host_patterns[0]),
                      "<host api: regex='api' urlconf='api.urls' "
                      "scheme='//' port=''>")
Пример #8
0
    def test_host_nonexistent_callback(self):
        api_host = host(r'api',
                        'api.urls',
                        name='api',
                        callback='whatever.non_existent')
        self.assertRaisesWithMessageIn(
            ImproperlyConfigured,
            "Could not import 'whatever'. Error was: No module named",
            lambda: api_host.callback)

        api_host = host(r'api',
                        'api.urls',
                        name='api',
                        callback='django_hosts.non_existent')
        self.assertRaisesWithMessageIn(
            ImproperlyConfigured,
            "Could not import django_hosts.non_existent. "
            "Callable does not exist in module", lambda: api_host.callback)
Пример #9
0
 def test_pattern(self):
     host_patterns = patterns(
         '',
         host(r'api', 'api.urls', name='api'),
     )
     self.assertEqual(len(host_patterns), 1)
     self.assertTrue(isinstance(host_patterns[0], host))
     self.assertEqual(repr(host_patterns[0]),
                      "<host api: api.urls ('api')>")
 def test_pattern(self):
     host_patterns = patterns('',
         host(r'api', 'api.urls', name='api'),
     )
     self.assertEqual(len(host_patterns), 1)
     self.assertTrue(isinstance(host_patterns[0], host))
     self.assertEqual(repr(host_patterns[0]),
                      "<host api: regex='api' urlconf='api.urls' "
                      "scheme='//' port=''>")
Пример #11
0
    def test_host_nonexistent_callback(self):
        api_host = host(r"api", "api.urls", name="api", callback="whatever.non_existent")
        self.assertRaisesMessageIn(
            ImproperlyConfigured, "Could not import 'whatever'. Error was: No module named", lambda: api_host.callback
        )

        api_host = host(r"api", "api.urls", name="api", callback="django_hosts.non_existent")
        try:
            self.assertRaisesMessageIn(
                ImproperlyConfigured,
                "Could not import 'django_hosts.non_existent'. " "Callable does not exist in module",
                lambda: api_host.callback,
            )
        except AssertionError:
            self.assertRaisesMessageIn(
                ImproperlyConfigured,
                "Could not import django_hosts.non_existent. " "Callable does not exist in module",
                lambda: api_host.callback,
            )

        api_host = host(r"api", "api.urls", name="api", callback="tests.broken_module.yeah_yeah")
        self.assertRaises(ImproperlyConfigured, lambda: api_host.callback)
    def test_host_nonexistent_callback(self):
        api_host = host(r'api', 'api.urls', name='api',
                        callback='whatever.non_existent')
        self.assertRaisesMessageIn(ImproperlyConfigured,
            "Could not import 'whatever'. Error was: No module named",
            lambda: api_host.callback)

        api_host = host(r'api', 'api.urls', name='api',
                        callback='django_hosts.non_existent')
        try:
            self.assertRaisesMessageIn(ImproperlyConfigured,
                "Could not import 'django_hosts.non_existent'. "
                "Callable does not exist in module",
                lambda: api_host.callback)
        except Exception:  # Django < 1.8
            self.assertRaisesMessageIn(ImproperlyConfigured,
                "Could not import django_hosts.non_existent. "
                "Callable does not exist in module",
                lambda: api_host.callback)

        api_host = host(r'api', 'api.urls', name='api',
                        callback='tests.broken_module.yeah_yeah')
        self.assertRaises(ImproperlyConfigured, lambda: api_host.callback)
 def test_host_callable_callback(self):
     api_host = host(r'api', 'api.urls', name='api',
                     callback=get_host_patterns)
     self.assertEqual(api_host.callback, get_host_patterns)
 def test_host_string_callback(self):
     api_host = host(r'api', 'api.urls', name='api',
                     callback='django_hosts.resolvers.get_host_patterns')
     self.assertEqual(api_host.callback, get_host_patterns)
 def test_host_prefix(self):
     api_host = host(r'api', 'api.urls', name='api', prefix='spam.eggs')
     self.assertEqual(api_host.urlconf, 'spam.eggs.api.urls')
 def test_host(self):
     api_host = host(r'api', 'api.urls', name='api')
     self.assertTrue(isinstance(api_host, host))
Пример #17
0
 def test_pattern_with_duplicate(self):
     api_host = host(r"api", "api.urls", name="api")
     self.assertRaises(ImproperlyConfigured, patterns, "", api_host, api_host)
Пример #18
0
 def test_host_callable_callback(self):
     api_host = host(r"api", "api.urls", name="api", callback=get_host_patterns)
     self.assertEqual(api_host.callback, get_host_patterns)
Пример #19
0
 def test_host(self):
     api_host = host(r'api', 'api.urls', name='api')
     self.assertTrue(isinstance(api_host, host))
Пример #20
0
 def test_pattern_with_prefix(self):
     host_patterns = patterns("mysite", host(r"api", "api.urls", name="api"))
     self.assertEqual(len(host_patterns), 1)
     self.assertTrue(isinstance(host_patterns[0], host))
     self.assertEqual(host_patterns[0].urlconf, "mysite.api.urls")
Пример #21
0
 def test_host_string_callback(self):
     api_host = host(r'api',
                     'api.urls',
                     name='api',
                     callback='django_hosts.resolvers.get_host_patterns')
     self.assertEqual(api_host.callback, get_host_patterns)
Пример #22
0
 def test_host(self):
     api_host = host(r"api", "api.urls", name="api")
     self.assertTrue(isinstance(api_host, host))
Пример #23
0
 def test_host_prefix(self):
     api_host = host(r"api", "api.urls", name="api", prefix="spam.eggs")
     self.assertEqual(api_host.urlconf, "spam.eggs.api.urls")
Пример #24
0
 def test_pattern_with_duplicate(self):
     api_host = host(r'api', 'api.urls', name='api')
     self.assertRaises(ImproperlyConfigured, patterns, '', api_host,
                       api_host)
 def test_pattern_with_duplicate(self):
     api_host = host(r'api', 'api.urls', name='api')
     self.assertRaises(ImproperlyConfigured,
                       patterns, '', api_host, api_host)
Пример #26
0
 def test_host_prefix(self):
     api_host = host(r'api', 'api.urls', name='api', prefix='spam.eggs')
     self.assertEqual(api_host.urlconf, 'spam.eggs.api.urls')
Пример #27
0
 def test_host_string_callback(self):
     api_host = host(r"api", "api.urls", name="api", callback="django_hosts.resolvers.get_host_patterns")
     self.assertEqual(api_host.callback, get_host_patterns)
Пример #28
0
 def test_host_callable_callback(self):
     api_host = host(r'api',
                     'api.urls',
                     name='api',
                     callback=get_host_patterns)
     self.assertEqual(api_host.callback, get_host_patterns)
Пример #29
0
 def test_pattern_with_default(self):
     default_host = host(r'www', 'mysite.urls', name='default')
     self.assertRaises(ImproperlyConfigured, patterns, '', default_host)