Beispiel #1
0
    def test_json_search_icon(self):
        self.portal.invokeFactory('File', id='somefile.bin')
        linkable_portal_types = self.utility.linkable.split('\n')
        linkable_portal_types.extend(self.utility.containsobjects.split('\n'))

        obj = IJSONSearch(self.portal)
        results = obj.getSearchResults(filter_portal_types=linkable_portal_types,
                                         searchtext='somefile')
        self.assertRegexpMatches(results,
            r'"id": "somefile.bin", "icon": "<img width=\\"16\\" height=\\"16\\" src=\\"http://nohost/plone/application.png\\" alt=\\"File\\" />"')
Beispiel #2
0
    def test_json_search_icon(self):
        self.portal.invokeFactory('File', id='somefile.bin')
        linkable_portal_types = self.utility.linkable.split('\n')
        linkable_portal_types.extend(self.utility.containsobjects.split('\n'))

        obj = IJSONSearch(self.portal)
        results = obj.getSearchResults(filter_portal_types=linkable_portal_types,
                                         searchtext='somefile')
        self.assertRegexpMatches(results,
            r'"id": "somefile.bin", "icon": "<img width=\\"16\\" height=\\"16\\" src=\\"http://nohost/plone/application.png\\" alt=\\"File.*?\\" />"')
    def jsonLinkableSearch(self, searchtext):
        """Returns the search results of linkable objects in JSON"""

        utility = getToolByName(aq_inner(self.context), 'portal_tinymce')
        linkable_portal_types = utility.linkable.split('\n')
        linkable_portal_types.extend(utility.containsobjects.split('\n'))

        object = IJSONSearch(self.context, None)
        if object is None:
            return ''
        results = object.getSearchResults(linkable_portal_types, searchtext)
        return results
Beispiel #4
0
    def jsonImageSearch(self, searchtext):
        """Returns the search results of image objects in JSON"""

        utility = getToolByName(aq_inner(self.context), 'portal_tinymce')
        image_portal_types = utility.imageobjects.split('\n')
        image_portal_types.extend(utility.containsobjects.split('\n'))

        object = IJSONSearch(self.context, None)
        if object is None:
            return ''
        results = object.getSearchResults(image_portal_types, searchtext)
        return results
Beispiel #5
0
    def jsonSCEmbedderSearch(self, searchtext):
        """Returns the search results of sc.embedder objects in JSON"""

        utility = getUtility(ITinyMCE)
        portal_types = ['sc.embedder']
        portal_types.extend(utility.containsobjects.split('\n'))

        object = IJSONSearch(self.context, None)
        if object is None:
            return ''
        results = object.getSearchResults(portal_types, searchtext)
        return results
    def jsonSCEmbedderSearch(self, searchtext):
        """Returns the search results of sc.embedder objects in JSON"""

        utility = getUtility(ITinyMCE)
        portal_types = ["sc.embedder"]
        portal_types.extend(utility.containsobjects.split("\n"))

        object = IJSONSearch(self.context, None)
        if object is None:
            return ""
        results = object.getSearchResults(portal_types, searchtext)
        return results
Beispiel #7
0
    def jsonImageSearch(self, searchtext):
        """Returns the search results of image objects in JSON"""

        utility = getUtility(ITinyMCE)
        image_portal_types = utility.imageobjects.split('\n')
        image_portal_types.extend(utility.containsobjects.split('\n'))

        object = IJSONSearch(self.context, None)
        if object is None:
            return ''
        results = object.getSearchResults(image_portal_types, searchtext)
        return results
Beispiel #8
0
    def jsonLinkableSearch(self, searchtext):
        """Returns the search results of linkable objects in JSON"""

        utility = getUtility(ITinyMCE)
        linkable_portal_types = utility.linkable.split('\n')
        linkable_portal_types.extend(utility.containsobjects.split('\n'))

        object = IJSONSearch(self.context, None)
        if object is None:
            return ''
        results = object.getSearchResults(linkable_portal_types, searchtext)
        return results
Beispiel #9
0
    def jsonImageSearch(self, searchtext):
        """Returns the search results of image objects in JSON"""

        utility = getToolByName(aq_inner(self.context), "portal_tinymce")
        image_portal_types = utility.imageobjects.split("\n")
        image_portal_types.extend(utility.containsobjects.split("\n"))

        object = IJSONSearch(self.context, None)
        if object is None:
            return ""
        results = object.getSearchResults(image_portal_types, searchtext)
        return results
    def test_json_search(self):
        # Create an Event
        self.portal.invokeFactory('Event', id='events', title='Events')

        # The json search is used the look for content types within the self.portal. Let's see
        # if we can find some items containing the searchterm 'Events'
        linkable_portal_types = self.utility.linkable.split('\n')
        linkable_portal_types.extend(self.utility.containsobjects.split('\n'))

        obj = IJSONSearch(self.portal)
        self.assertRegexpMatches(
            obj.getSearchResults(filter_portal_types=linkable_portal_types,
            searchtext='Events',
        ), '\{.*"title": "Events", "url": "http://nohost/plone/events".*}')