def test_bc_navigationroot(self):
        makeContent(self.portal.folder1, portal_type="Document", id="page1")

        page = self.portal.folder1.page1

        browser = Browser()
        data = {"fieldName": "relatedItems", "fieldRealName": "relatedItems", "at_url": page.absolute_url(1)}

        basic = "%s:%s" % (portal_owner, default_password)

        browser.addHeader("Authorization", "Basic %s" % basic)
        browser.open("%s/refbrowser_popup?%s" % (page.absolute_url(), urlencode(data)))
        self.assertTrue(
            (
                '<a class="browsesite" href="http://nohost/plone/refbrowser_popup?'
                "fieldName=relatedItems&amp;fieldRealName=relatedItems"
                '&amp;at_url=plone/folder1/page1" rel="Home"> '
                "<span>Home</span> </a>"
            )
            in normalize(browser.contents)
        )

        # now let's change the navigation root
        zope.interface.alsoProvides(self.portal.folder1, INavigationRoot)
        browser.open("%s/refbrowser_popup?%s" % (page.absolute_url(), urlencode(data)))
        self.assertTrue(
            (
                '<a class="browsesite" href="http://nohost/plone/folder1/refbrowser_popup?'
                "fieldName=relatedItems&amp;fieldRealName=relatedItems"
                '&amp;at_url=plone/folder1/page1" rel="Home"> '
                "<span>Home</span> </a>"
            )
            in normalize(browser.contents)
        )
예제 #2
0
    def test_bc_navigationroot(self):
        makeContent(self.portal.folder1, portal_type='Document', id='page1')

        page = self.portal.folder1.page1

        browser = Browser()
        data = {
          'fieldName': 'relatedItems',
          'fieldRealName': 'relatedItems',
          'at_url': page.absolute_url(1)}

        basic = '%s:%s' % (portal_owner, default_password)

        browser.addHeader('Authorization', 'Basic %s' % basic)
        browser.open('%s/refbrowser_popup?%s' % (page.absolute_url(),
                                                 urlencode(data)))
        self.assertTrue(('<a class="browsesite" href="http://nohost/plone/refbrowser_popup?'
                         'fieldName=relatedItems&amp;fieldRealName=relatedItems'
                         '&amp;at_url=plone/folder1/page1" rel="Home"> '
                         '<span>Home</span> </a>')
                         in normalize(browser.contents))

        # now let's change the navigation root
        zope.interface.alsoProvides(self.portal.folder1, INavigationRoot)
        browser.open('%s/refbrowser_popup?%s' % (page.absolute_url(),
                                                 urlencode(data)))
        self.assertTrue(('<a class="browsesite" href="http://nohost/plone/folder1/refbrowser_popup?'
                         'fieldName=relatedItems&amp;fieldRealName=relatedItems'
                         '&amp;at_url=plone/folder1/page1" rel="Home"> '
                         '<span>Home</span> </a>')
                         in normalize(browser.contents))
    def getNormalizedPopup(self, url=None, field=None, startup_path=None):
        if url is None:
            url = self.demo1_url
        if field is None:
            field = "singleRef"
        if startup_path is None:
            startup_path = self.popup_url
        response = self.publish(
            "%s?fieldName=%s&fieldRealName=%s&at_url=%s" % (startup_path, field, field, url), self.basic_auth
        )

        return normalize(response.getBody())
예제 #4
0
    def test_basewidget(self):
        response = self.publish('%s/base_edit' % self.demo1_url,
                                                 self.basic_auth)
        body = normalize(response.getBody())
        assert ('<script type="text/javascript" charset="iso-8859-1" '
                'src="http://nohost/plone/referencebrowser.js"> '
                '</script>') in body

        widgetdiv = re.compile((
            r'<div class="field ArchetypesReferenceBrowserWidget .*?" '
             'id="archetypes-fieldname-singleRef">'))
        assert widgetdiv.search(body)
        assert (
            '<input id="ref_browser_singleRef_label" size="50" type="text" readonly="readonly" '
            'value="No reference set. Click the add button to select." /> '
            ) in body
        assert ('<input type="hidden" name="singleRef" id="ref_browser_singleRef" /> ') \
                in body
        assert ('<input type="button" class="searchButton addreference" '
                'value="Add..." src="') in body
        assert '''<input type="button" class="destructive" value="Clear reference" onclick="javascript:refbrowser_removeReference('ref_browser_singleRef', 0)" />''' in body
예제 #5
0
    def test_basewidget(self):
        response = self.publish('%s/base_edit' % self.demo1_url,
                                self.basic_auth)
        body = normalize(response.getBody())
        assert ('<script type="text/javascript" charset="iso-8859-1" '
                'src="http://nohost/plone/referencebrowser.js"> '
                '</script>') in body

        # Check the div.  Allow for the existence of extra classes and
        # extra data attributes.
        widgetdiv = re.compile((
            r'<div class="field ArchetypesReferenceBrowserWidget [^"]*"[^>]*'
            'id="archetypes-fieldname-singleRef"'))
        assert widgetdiv.search(body)
        assert (
            '<input id="ref_browser_singleRef_label" size="50" type="text" readonly="readonly" '
            'value="No reference set. Click the add button to select." /> '
            ) in body
        assert ('<input type="hidden" name="singleRef" id="ref_browser_singleRef" /> ') in body
        assert ('<input type="button" class="searchButton addreference" '
                'value="Add..." src="') in body
        assert '''<input type="button" class="destructive removereference" value="Clear reference" data-fieldname="singleRef" data-multivalued="0" />''' in body