Ejemplo n.º 1
0
class URLHookTest(TestCase):
    def setUp(self):
        manager = ExtensionManager('')
        self.test_extension = \
            TestExtensionWithRegistration(extension_manager=manager)
        self.patterns = patterns('',
            (r'^url_hook_test/', include('djblets.extensions.test.urls')))
        self.url_hook = URLHook(self.test_extension, self.patterns)

    def test_url_registration(self):
        """Testing URLHook URL registration"""
        self.assertTrue(set(self.patterns)
            .issubset(set(self.url_hook.dynamic_urls.url_patterns)))
        # And the URLHook should be added to the extension's list of hooks
        self.assertTrue(self.url_hook in self.test_extension.hooks)

    def test_shutdown_removes_urls(self):
        """Testing URLHook.shutdown"""
        # On shutdown, a URLHook's patterns should no longer be in its
        # parent URL resolver's pattern collection.
        self.url_hook.shutdown()
        self.assertFalse(
            set(self.patterns).issubset(
                set(self.url_hook.dynamic_urls.url_patterns)))

        # But the URLHook should still be in the extension's list of hooks
        self.assertTrue(self.url_hook in self.test_extension.hooks)
Ejemplo n.º 2
0
class URLHookTest(TestCase):
    def setUp(self):
        self.test_extension = TestExtensionWithRegistration()
        self.patterns = patterns(
            '', (r'^url_hook_test/', include('djblets.extensions.test.urls')))
        self.url_hook = URLHook(self.test_extension, self.patterns)

    def test_urls_appended(self):
        """On initialization, a URLHook should extend its parent URL resolver's
           patterns with the patterns passed into the URLHook."""
        self.assertTrue(
            set(self.patterns).issubset(
                set(self.url_hook.parent_resolver.url_patterns)))
        # And the URLHook should be added to the extension's list of hooks
        self.assertTrue(self.url_hook in self.test_extension.hooks)

    def test_shutdown_removes_urls(self):
        """On shutdown, a URLHook's patterns should no longer be in its
           parent URL resolver's pattern collection."""
        self.url_hook.shutdown()
        self.assertFalse(
            set(self.patterns).issubset(
                set(self.url_hook.parent_resolver.url_patterns)))
        # But the URLHook should still be in the extension's list of hooks
        self.assertTrue(self.url_hook in self.test_extension.hooks)
Ejemplo n.º 3
0
class URLHookTest(TestCase):
    def setUp(self):
        manager = ExtensionManager('')
        self.test_extension = \
            TestExtensionWithRegistration(extension_manager=manager)
        self.patterns = patterns(
            '', (r'^url_hook_test/', include('djblets.extensions.test.urls')))
        self.url_hook = URLHook(self.test_extension, self.patterns)

    def test_url_registration(self):
        """Testing URLHook URL registration"""
        self.assertTrue(
            set(self.patterns).issubset(
                set(self.url_hook.dynamic_urls.url_patterns)))
        # And the URLHook should be added to the extension's list of hooks
        self.assertTrue(self.url_hook in self.test_extension.hooks)

    def test_shutdown_removes_urls(self):
        """Testing URLHook.shutdown"""
        # On shutdown, a URLHook's patterns should no longer be in its
        # parent URL resolver's pattern collection.
        self.url_hook.shutdown()
        self.assertFalse(
            set(self.patterns).issubset(
                set(self.url_hook.dynamic_urls.url_patterns)))

        # But the URLHook should still be in the extension's list of hooks
        self.assertTrue(self.url_hook in self.test_extension.hooks)
Ejemplo n.º 4
0
class URLHookTest(TestCase):
    def setUp(self):
        self.test_extension = TestExtensionWithRegistration()
        self.patterns = patterns("", (r"^url_hook_test/", include("djblets.extensions.test.urls")))
        self.url_hook = URLHook(self.test_extension, self.patterns)

    def test_urls_appended(self):
        """On initialization, a URLHook should extend its parent URL resolver's
           patterns with the patterns passed into the URLHook."""
        self.assertTrue(set(self.patterns).issubset(set(self.url_hook.parent_resolver.url_patterns)))
        # And the URLHook should be added to the extension's list of hooks
        self.assertTrue(self.url_hook in self.test_extension.hooks)

    def test_shutdown_removes_urls(self):
        """On shutdown, a URLHook's patterns should no longer be in its
           parent URL resolver's pattern collection."""
        self.url_hook.shutdown()
        self.assertFalse(set(self.patterns).issubset(set(self.url_hook.parent_resolver.url_patterns)))
        # But the URLHook should still be in the extension's list of hooks
        self.assertTrue(self.url_hook in self.test_extension.hooks)