コード例 #1
0
    def test_url(self):
        content = self.root.section.folder.link.get_editable()
        request = TestRequest(application=self.root)
        url = component.getMultiAdapter(
            (content, request),
            IContentURL)
        self.assertTrue(verifyObject(IContentURL, url))
        self.assertTrue(IContentURL.extends(IAbsoluteURL))

        self.assertEqual(
            str(url),
            'http://localhost/root/section/folder/link/0')
        self.assertEqual(
            url(),
            'http://localhost/root/section/folder/link/0')
        self.assertEqual(
            url.url(relative=True),
            '/root/section/folder/link/0')
        self.assertEqual(
            url.url(relative=True, preview=True),
            '/root/++preview++/section/folder/link/0')
        self.assertEqual(
            url.preview(),
            'http://localhost/root/++preview++/section/folder/link/0')

        alsoProvides(request, IPreviewLayer)
        self.assertEqual(
            str(url),
            'http://localhost/root/++preview++/section/folder/link/0')
        self.assertEqual(
            url(),
            'http://localhost/root/++preview++/section/folder/link/0')
コード例 #2
0
    def test_url(self):
        """Test IContentURL url computation. Preview is not available
        on Zope object.
        """
        request = TestRequest(application=self.root)
        url = component.getMultiAdapter(
            (self.root.service_extensions, request), IContentURL)
        self.assertTrue(verifyObject(IContentURL, url))
        self.assertTrue(IContentURL.extends(IAbsoluteURL))

        self.assertEqual(
            str(url),
            'http://localhost/root/service_extensions')
        self.assertEqual(
            url(),
            'http://localhost/root/service_extensions')
        self.assertEqual(
            url.url(relative=True),
            '/root/service_extensions')
        self.assertEqual(
            url.url(relative=True, preview=True),
            '/root/service_extensions')
        self.assertEqual(
            url.preview(),
            'http://localhost/root/service_extensions')

        alsoProvides(request, IPreviewLayer)
        self.assertEqual(
            str(url),
            'http://localhost/root/service_extensions')
        self.assertEqual(
            url(),
            'http://localhost/root/service_extensions')
コード例 #3
0
    def test_vhm(self):
        """Test IContentURL url computation while a VHM is used. Zope
        object doesn't support the preview mode.
        """
        request = TestRequest(
            application=self.root,
            url='http://localhost/service_extension',
            headers=[('X-VHM-Url', 'http://infrae.com'),
                     ('X-VHM-Path', '/root')])
        plugin = request.query_plugin(request.application, IVirtualHosting)
        root, method, path = plugin(request.method, request.path)
        self.assertEqual(root, self.root)
        self.assertEqual(method, 'index_html')
        self.assertEqual(path, ['service_extension'])

        url = component.getMultiAdapter(
            (self.root.service_extensions, request), IContentURL)
        self.assertTrue(verifyObject(IContentURL, url))
        self.assertTrue(IContentURL.extends(IAbsoluteURL))

        self.assertEqual(
            str(url),
            'http://infrae.com/service_extensions')
        self.assertEqual(
            url(),
            'http://infrae.com/service_extensions')
        self.assertEqual(
            url.url(relative=True),
            '/service_extensions')
        self.assertEqual(
            url.url(relative=True, preview=True),
            '/service_extensions')
        self.assertEqual(
            url.preview(),
            'http://infrae.com/service_extensions')
        self.assertEqual(
            url.url(host='http://silvacms.org'),
            'http://silvacms.org/service_extensions')
        self.assertEqual(
            url.url(host='http://silvacms.org', preview=True),
            'http://silvacms.org/service_extensions')

        alsoProvides(request, IPreviewLayer)
        self.assertEqual(
            str(url),
            'http://infrae.com/service_extensions')
        self.assertEqual(
            url(),
            'http://infrae.com/service_extensions')
コード例 #4
0
    def test_url(self):
        """Test the IContentURL on Catalog brains object. Like for
        Zope object, they don't support the preview mode.
        """
        brains = self.root.service_catalog(
            meta_type="Silva Publication",
            path="/root/section")
        self.assertEqual(len(brains), 1)
        brain = brains[0]

        request = TestRequest(application=self.root)
        url = component.getMultiAdapter(
            (brain, request), IContentURL)
        self.assertTrue(verifyObject(IContentURL, url))
        self.assertTrue(IContentURL.extends(IAbsoluteURL))

        self.assertEqual(
            brain.getURL(),
            'http://localhost/root/section')
        self.assertEqual(
            str(url),
            'http://localhost/root/section')
        self.assertEqual(
            url(),
            'http://localhost/root/section')
        self.assertEqual(
            url.url(relative=True),
            '/root/section')
        self.assertEqual(
            url.url(relative=True, preview=True),
            '/root/section')
        self.assertEqual(
            url.preview(),
            'http://localhost/root/section')
        self.assertEqual(
            url.url(host='http://silvacms.org'),
            'http://silvacms.org/root/section')
        self.assertEqual(
            url.url(host='http://silvacms.org', preview=True),
            'http://silvacms.org/root/section')

        alsoProvides(request, IPreviewLayer)
        self.assertEqual(
            str(url),
            'http://localhost/root/section')
        self.assertEqual(
            url(),
            'http://localhost/root/section')
コード例 #5
0
    def test_url(self):
        """Verify the IContentURL on a Silva Publication.
        """
        request = TestRequest(application=self.root)
        url = component.getMultiAdapter(
            (self.root.section, request), IContentURL)
        self.assertTrue(verifyObject(IContentURL, url))
        self.assertTrue(IContentURL.extends(IAbsoluteURL))

        self.assertEqual(
            str(url),
            'http://localhost/root/section')
        self.assertEqual(
            url(),
            'http://localhost/root/section')
        self.assertEqual(
            url.url(relative=True),
            '/root/section')
        self.assertEqual(
            url.url(relative=True, preview=True),
            '/root/++preview++/section')
        self.assertEqual(
            url.preview(),
            'http://localhost/root/++preview++/section')
        self.assertEqual(
            url.url(host='http://silvacms.org'),
            'http://silvacms.org/root/section')
        self.assertEqual(
            url.url(host='http://silvacms.org', preview=True),
            'http://silvacms.org/root/++preview++/section')

        alsoProvides(request, IPreviewLayer)
        self.assertEqual(
            str(url),
            'http://localhost/root/++preview++/section')
        self.assertEqual(
            url(),
            'http://localhost/root/++preview++/section')