Example #1
0
 def test_transaction_counter(self):
     tdata = td.get()
     createObject(self.portal, 'Event', 'event', title="Some Event")
     assert tdata.counter > 0
     prev = tdata.counter
     createObject(self.portal, 'Event', 'event2', title="Some Event")
     assert tdata.counter > prev
    def test_text_index_query(self):
        for idx in range(5):
            createObject(
                self.portal, 'Document',
                'page%i' % idx, title="Page %i" % idx)
            # should not show up in results
        events = []
        for idx in range(5):
            event = createObject(
                self.portal, 'Event',
                'event%i' % idx, title="Some Event %i" % idx)
            events.append(event)
        cat_results = self.searchResults(Title="Some Event")
        el_results = self.catalog(Title="Some Event")
        self.assertEquals(len(cat_results), len(el_results))
        self.assertEquals(len(cat_results), len(events))

        # only find one
        cat_results = self.searchResults(Title="Some Event 1",
                                         sort_on="getObjPositionInParent")
        el_results = self.catalog(Title="Some Event 1",
                                  sort_on="getObjPositionInParent")
        self.assertTrue("Some Event 1" in [
            b.Title for b in el_results])
        self.assertEquals(cat_results[0].Title, "Some Event 1")
 def test_keyword_index_query(self):
     createObject(self.portal, 'Event', 'event', title='Some Event')
     self.commit()
     self.es.connection.indices.flush()
     el_results = self.catalog(object_provides=[self.event_klass],
                               SearchableText='Event')
     self.assertEqual(len(el_results), 1)
 def test_combined_query(self):
     createObject(self.portal, 'Folder', 'folder1', title="Folder 1")
     self.assertEquals(
         len(self.catalog(path={'depth': 1, 'query': '/plone'},
                          portal_type='Folder',
                          is_default_page=False)),
         1)
Example #5
0
 def populate(parent, count=0, depth=0):
     if depth >= max_depth:
         return count
     for fidx in range(num_folders):
         count += 1
         folder = createObject(parent,
                               'Folder',
                               'folder%i' % fidx,
                               check_for_first=True,
                               delete_first=False,
                               title="Folder %i" % fidx)
         for didx in range(per_folder):
             count += 1
             print 'created ', count
             createObject(folder,
                          random.choice(portal_types),
                          'page%i' % didx,
                          check_for_first=True,
                          delete_first=False,
                          title="Page %i" % didx,
                          text=data.next())
         count = populate(folder, count, depth + 1)
     print 'commiting'
     transaction.commit()
     app._p_jar.cacheMinimize()
     return count
    def test_brains(self):
        event = createObject(self.portal, 'Event', 'event', title='Some Event')
        self.commit()
        self.es.connection.indices.flush()
        el_results = self.catalog(portal_type='Event', Title='Some Event')
        brain = el_results[0]
        self.assertEqual(brain.getObject(), event)
        self.assertEqual(brain.portal_type, 'Event')
        self.assertEqual(brain.getURL(), 'http://nohost/plone/event')
        self.assertEqual(brain.getPath(), '/plone/event')

        brain = el_results[-1]
        self.assertEqual(brain.getObject(), event)
        self.assertEqual(brain.portal_type, 'Event')
        self.assertEqual(brain.getURL(), 'http://nohost/plone/event')
        self.assertEqual(brain.getPath(), '/plone/event')

        createObject(self.portal, 'Event', 'event2', title='Some Event')
        self.commit()
        self.es.connection.indices.flush()

        el_results2 = self.catalog(portal_type='Event',
                                   Title='Some Event',
                                   sort_on='getId',
                                   sort_order='descending')
        brain = el_results2[0]
        self.assertEqual(brain.getId, 'event2')
        brain = el_results2[1]
        self.assertEqual(brain.getId, 'event')

        brain = el_results2[-1]
        self.assertEqual(brain.getId, 'event')
        brain = el_results2[-2]
        self.assertEqual(brain.getId, 'event2')
Example #7
0
 def test_keyword_index_query(self):
     createObject(self.portal, 'Event', 'event', title="Some Event")
     cat_results = self.searchResults(
         object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
     el_results = self.catalog(
         object_provides=["Products.ATContentTypes.interfaces.event.IATEvent"])
     self.assertEquals(len(cat_results), len(el_results))
     self.assertEquals(len(cat_results), 1)
Example #8
0
 def test_multi_keyword_index_query(self):
     createObject(self.portal, 'Event', 'event', title='New Content')
     createObject(self.portal, 'Document', 'page', title='New Content')
     self.commit()
     self.es.connection.indices.flush()
     el_results = self.catalog(
         object_provides=[EVENT_KLASS, DOCUMENT_KLASS],
         SearchableText='new content')
     self.assertEqual(len(el_results), 2)
 def test_multi_keyword_index_query(self):
     createObject(self.portal, 'Event', 'event', title="Some Event")
     createObject(self.portal, 'Document', 'page', title="Some page")
     cat_results = self.searchResults(
         object_provides=[EVENT_KLASS, DOCUMENT_KLASS])
     el_results = self.catalog(
         object_provides=[EVENT_KLASS, DOCUMENT_KLASS])
     self.assertEquals(len(cat_results), len(el_results))
     self.assertEquals(len(cat_results), 2)
 def test_multi_keyword_index_query(self):
     createObject(self.portal, 'Event', 'event', title='New Content')
     createObject(self.portal, 'Document', 'page', title='New Content')
     self.commit()
     self.es.connection.indices.flush()
     el_results = self.catalog(
         object_provides=[self.event_klass, self.document_klass],
         SearchableText='new content')
     self.assertEqual(len(el_results), 2)
Example #11
0
 def test_combined_query(self):
     createObject(self.portal, 'Folder', 'folder1', title='Folder 1')
     self.commit()
     self.es.connection.indices.flush()
     self.assertEqual(
         len(self.catalog(path={'depth': 1, 'query': '/plone'},
                          portal_type='Folder',
                          is_default_page=False,
                          SearchableText='folder')),
         1)
    def test_abort_td(self):
        tdata = td.get()
        createObject(self.portal, 'Event', 'event', title="Some Event")
        # query for it...
        cat_results = self.catalog(object_provides=EVENT_KLASS)
        self.assertEquals(len(cat_results), 1)

        transaction.abort()
        cat_results = self.catalog(object_provides=EVENT_KLASS)
        self.assertEquals(len(cat_results), 0)
        self.assertEquals(len(tdata.docs), 0)
Example #13
0
    def test_abort_td(self):
        tdata = td.get()
        createObject(self.portal, 'Event', 'event', title="Some Event")
        # query for it...
        cat_results = self.catalog(object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(len(cat_results), 1)

        transaction.abort()
        cat_results = self.catalog(
            object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(len(cat_results), 0)
        self.assertEquals(tdata.counter, 0)
 def test_combined_query(self):
     createObject(self.portal, 'Folder', 'folder1', title='Folder 1')
     self.commit()
     self.es.connection.indices.flush()
     self.assertEqual(
         len(
             self.catalog(path={
                 'depth': 1,
                 'query': '/plone'
             },
                          portal_type='Folder',
                          is_default_page=False,
                          SearchableText='folder')), 1)
    def test_deleting_multiple_items_works_with_result_set(self):
        createObject(self.portal, 'Event', 'event1', title="Some Event")
        createObject(self.portal, 'Event', 'event2', title="Some Event")
        transaction.commit()
        # query for it...
        cat_results = self.catalog(object_provides=EVENT_KLASS)
        self.assertEquals(len(cat_results), 2)

        # now delete
        self.portal.manage_delObjects(['event1'])
        # should still be able to access second of query result
        self.assertTrue(cat_results[1] is not None)
        self.portal.manage_delObjects(['event2'])
        transaction.commit()
Example #16
0
    def test_date_index_query(self):
        start = DateTime()
        time.sleep(1)
        events = []
        for idx in range(5):
            event = createObject(
                self.portal, 'Event',
                'event%i' % idx, title='Some Event %i' % idx,
                effective=DateTime('2015/09/25 20:00'))
            events.append(event)

        self.commit()
        self.es.connection.indices.flush()

        end = DateTime()
        query = {'query': (start, end), 'range': 'min:max', 'SearchableText': 'Event'}
        cat_results = self.catalog._old_searchResults(created=query)
        el_results = self.catalog(created=query)
        self.assertEqual(len(cat_results), len(el_results))
        self.assertEqual(len(cat_results), len(events))

        query = {'query': DateTime().latestTime(), 'range': 'min'}
        cat_results = self.catalog._old_searchResults(effective=query)
        el_results = self.catalog(effective=query)
        self.assertEqual(len(cat_results), len(el_results))
        self.assertEqual(len(cat_results), 0)

        query = {'query': DateTime().latestTime(), 'range': 'max'}
        cat_results = self.catalog._old_searchResults(effective=query)
        el_results = self.catalog(effective=query)
        self.assertEqual(len(cat_results), len(el_results))
        self.assertEqual(len(cat_results), 5)
 def test_brains_indexing(self):
     for idx in range(120):
         createObject(self.portal,
                      'Document',
                      '{0:04d}page'.format(idx),
                      title='Page {}'.format(idx))
     self.commit()
     el_results = self.catalog(portal_type='Document',
                               sort_on='getId',
                               sort_order='asc')
     self.assertEqual(len(el_results), 120)
     self.assertEqual(el_results[0].getId, '0000page')
     self.assertEqual(el_results[-1].getId, '0119page')
     self.assertEqual(el_results[-50].getId, '0070page')
     self.assertEqual(el_results[-55].getId, '0065page')
     self.assertEqual(el_results[-100].getId, '0020page')
Example #18
0
 def test_rename_object(self):
     current_length = len(self.catalog._catalog.uids)
     obj = createObject(self.portal, 'Event', 'event1', title='Some Event')
     obj_uid = getUID(obj)
     self.assertEqual(current_length + 1, len(self.catalog._catalog.uids))
     api.content.rename(self.portal.event1, new_id='event2')
     self.assertEqual(self.get_hook().remove, set())
     self.assertEqual(self.get_hook().index, {obj_uid: obj})
Example #19
0
 def test_brains(self):
     event = createObject(self.portal, 'Event', 'event', title="Some Event")
     el_results = self.catalog(portal_type="Event")
     brain = el_results[0]
     self.assertEquals(brain.getObject(), event)
     self.assertEquals(brain.portal_type, 'Event')
     self.assertEquals(brain.getURL(), 'http://nohost/plone/event')
     self.assertEquals(brain.getPath(), '/plone/event')
 def test_delete_object(self):
     obj = createObject(self.portal,
                        'Event',
                        'event_to_delete',
                        title='Some Event')
     obj_uid = getUID(obj)
     self.portal.manage_delObjects(['event_to_delete'])
     self.assertEqual(self.get_hook().index, {})
     self.assertEqual(self.get_hook().remove, {obj_uid})
 def test_has_right_brain_data(self):
     current_length = len(self.catalog._catalog.uids)
     obj = createObject(self.portal, 'Event', 'event', title='Some Event')
     self.assertEqual(current_length + 1, len(self.catalog._catalog.uids))
     self.assertEqual(self.get_hook().index, {getUID(obj): obj})
     self.portal.manage_delObjects(['event'])
     self.assertEqual(current_length, len(self.catalog._catalog.uids))
     self.assertEqual(self.get_hook().remove, {getUID(obj)})
     self.assertEqual(self.get_hook().index, {})
 def test_brains(self):
     event = createObject(self.portal, 'Event', 'event', title='Some Event')
     self.commit()
     self.es.connection.indices.flush()
     el_results = self.catalog(portal_type='Event', Title='Some Event')
     brain = el_results[0]
     self.assertEqual(brain.getObject(), event)
     self.assertEqual(brain.portal_type, 'Event')
     self.assertEqual(brain.getURL(), 'http://nohost/plone/event')
     self.assertEqual(brain.getPath(), '/plone/event')
Example #23
0
 def test_brains(self):
     event = createObject(self.portal, 'Event', 'event', title='Some Event')
     self.commit()
     self.es.connection.indices.flush()
     el_results = self.catalog(portal_type='Event', Title='Some Event')
     brain = el_results[0]
     self.assertEqual(brain.getObject(), event)
     self.assertEqual(brain.portal_type, 'Event')
     self.assertEqual(brain.getURL(), 'http://nohost/plone/event')
     self.assertEqual(brain.getPath(), '/plone/event')
Example #24
0
 def populate(parent, count=0, depth=0):
     if depth >= max_depth:
         return count
     for fidx in range(num_folders):
         count += 1
         folder = createObject(parent, 'Folder', 'folder%i' % fidx,
                               check_for_first=True, delete_first=False,
                               title="Folder %i" % fidx)
         for didx in range(per_folder):
             count += 1
             print 'created ', count
             createObject(folder, random.choice(portal_types), 'page%i' % didx,
                          check_for_first=True, delete_first=False,
                          title="Page %i" % didx, text=data.next())
         count = populate(folder, count, depth + 1)
     print 'commiting'
     transaction.commit()
     app._p_jar.cacheMinimize()
     return count
Example #25
0
 def test_has_right_brain_data(self):
     current_length = len(self.catalog._catalog.uids)
     obj = createObject(self.portal, 'Event', 'event', title='Some Event')
     self.assertEqual(current_length + 1, len(self.catalog._catalog.uids))
     self.assertEqual(self.get_hook().index, {getUID(obj): obj})
     self.portal.manage_delObjects(['event'])
     # uid not actually removed until this if catalog optimized
     processQueue()
     self.assertEqual(current_length, len(self.catalog._catalog.uids))
     self.assertEqual(self.get_hook().remove, {getUID(obj)})
     self.assertEqual(self.get_hook().index, {})
    def test_abort_deleting_item(self):
        tdata = td.get()
        createObject(self.portal, 'Event', 'event', title="Some Event")
        transaction.commit()
        # query for it...
        cat_results = self.catalog(object_provides=EVENT_KLASS)
        self.assertEquals(len(cat_results), 1)

        # now delete
        self.portal.manage_delObjects(['event'])
        cat_results = self.catalog(object_provides=EVENT_KLASS)
        self.assertEquals(len(cat_results), 0)

        # abort should now restore it to the index
        transaction.abort()
        cat_results = self.catalog(object_provides=EVENT_KLASS)
        self.assertEquals(len(cat_results), 1)
        self.assertEquals(len(tdata.docs), 0)
        self.portal.manage_delObjects(['event'])
        transaction.commit()
Example #27
0
    def test_text_index_query(self):
        for idx in range(5):
            createObject(self.portal, 'Document',
                'page%i' % idx, title="Page %i" % idx)
            # should not show up in results
        events = []
        for idx in range(5):
            event = createObject(self.portal, 'Event',
                'event%i' % idx, title="Some Event %i" % idx)
            events.append(event)
        cat_results = self.searchResults(Title="Some Event")
        el_results = self.catalog(Title="Some Event")
        self.assertEquals(len(cat_results), len(el_results))
        self.assertEquals(len(cat_results), len(events))

        # only find one
        cat_results = self.searchResults(Title="Some Event 1",
                                             sort_on="getObjPositionInParent")
        el_results = self.catalog(Title="Some Event 1",
                                  sort_on="getObjPositionInParent")
        self.assertEquals(el_results[0].Title, "Some Event 1")
        self.assertEquals(cat_results[0].Title, "Some Event 1")
Example #28
0
 def test_date_index_query(self):
     start = DateTime()
     time.sleep(1)
     events = []
     for idx in range(5):
         event = createObject(self.portal, 'Event',
             'event%i' % idx, title="Some Event %i" % idx)
         events.append(event)
     end = DateTime()
     query = {'query':(start, end), 'range': 'min:max'}
     cat_results = self.searchResults(created=query)
     el_results = self.catalog(created=query)
     self.assertEquals(len(cat_results), len(el_results))
     self.assertEquals(len(cat_results), len(events))
Example #29
0
    def test_abort_deleting_item(self):
        tdata = td.get()
        createObject(self.portal, 'Event', 'event', title="Some Event")
        transaction.commit()
        # query for it...
        cat_results = self.catalog(
            object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(len(cat_results), 1)

        # now delete
        self.portal.manage_delObjects(['event'])
        cat_results = self.catalog(
            object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(len(cat_results), 0)

        # abort should now restore it to the index
        transaction.abort()
        cat_results = self.catalog(
            object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(len(cat_results), 1)
        self.assertEquals(tdata.counter, 0)
        self.portal.manage_delObjects(['event'])
        transaction.commit()
    def test_adding_modifying_item_then_abort(self):
        event = createObject(self.portal, 'Event', 'event', title="Some Event")
        # query for it...
        cat_results = self.catalog(object_provides=EVENT_KLASS)
        self.assertEquals(len(cat_results), 1)

        event.setTitle('Modified Event')
        event.reindexObject()

        cat_results = self.catalog(object_provides=EVENT_KLASS)
        self.assertEquals(cat_results[0].Title, 'Modified Event')

        transaction.abort()
        cat_results = self.catalog(object_provides=EVENT_KLASS)
        self.assertEquals(len(cat_results), 0)
Example #31
0
    def test_text_index_query(self):
        for idx in range(5):
            createObject(
                self.portal, 'Document',
                'page%i' % idx, title='Page %i' % idx)
            # should not show up in results
        events = []
        for idx in range(5):
            event = createObject(
                self.portal, 'Event',
                'event%i' % idx, title='Some Event %i' % idx)
            events.append(event)

        self.commit()
        self.es.connection.indices.flush()

        el_results = self.catalog(Title='Some Event')
        self.assertEqual(len(el_results), len(events))

        el_results = self.catalog(Title='Some Event 1',
                                  sort_on='getObjPositionInParent')
        self.assertTrue('Some Event 1' in [
            b.Title for b in el_results])
        self.assertEqual(el_results[0].Title, 'Some Event 1')
Example #32
0
    def test_adding_modifying_item_then_abort(self):
        event = createObject(self.portal, 'Event', 'event', title="Some Event")
        # query for it...
        cat_results = self.catalog(
            object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(len(cat_results), 1)

        event.setTitle('Modified Event')
        event.reindexObject()

        cat_results = self.catalog(
            object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(cat_results[0].Title, 'Modified Event')

        transaction.abort()
        cat_results = self.catalog(
            object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(len(cat_results), 0)
Example #33
0
    def test_modifying_item_then_abort(self):
        event = createObject(self.portal, 'Event', 'event', title="Some Event")
        transaction.commit()
        # query for it...
        cat_results = self.catalog(
            object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(len(cat_results), 1)

        event.setTitle('Modified Event')
        event.reindexObject()

        cat_results = self.catalog(
            object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(cat_results[0].Title, 'Modified Event')

        transaction.abort()
        cat_results = self.catalog(
            object_provides="Products.ATContentTypes.interfaces.event.IATEvent")
        self.assertEquals(cat_results[0].Title, 'Some Event')
        self.portal.manage_delObjects(['event'])
        transaction.commit()
    def test_date_index_query(self):
        start = DateTime()
        time.sleep(1)
        events = []
        for idx in range(5):
            event = createObject(self.portal,
                                 'Event',
                                 'event%i' % idx,
                                 title='Some Event %i' % idx,
                                 effective=DateTime('2015/09/25 20:00'))
            events.append(event)

        self.commit()
        self.es.connection.indices.flush()

        end = DateTime()
        query = {
            'query': (start, end),
            'range': 'minmax',
            'SearchableText': 'Event'
        }
        cat_results = self.catalog._old_searchResults(created=query)
        el_results = self.catalog(created=query)
        self.assertEqual(len(cat_results), len(el_results))
        self.assertEqual(len(cat_results), len(events))

        query = {'query': DateTime().latestTime(), 'range': 'min'}
        cat_results = self.catalog._old_searchResults(effective=query)
        el_results = self.catalog(effective=query)
        self.assertEqual(len(cat_results), len(el_results))
        self.assertEqual(len(cat_results), 0)

        query = {'query': DateTime().latestTime(), 'range': 'max'}
        cat_results = self.catalog._old_searchResults(effective=query)
        el_results = self.catalog(effective=query)
        self.assertEqual(len(cat_results), len(el_results))
        self.assertEqual(len(cat_results), 5)
Example #35
0
    def test_path_index_query(self):
        folder1 = createObject(self.portal, 'Folder', 'folder0',
                               title='New Content 0')
        createObject(folder1, 'Document', 'page1', title='New Content 1')
        createObject(folder1, 'Document', 'page2', title='New Content 2')
        createObject(folder1, 'Document', 'page3', title='New Content 3')
        folder2 = createObject(folder1, 'Folder', 'folder4',
                               title='New Content 4')
        folder3 = createObject(folder2, 'Folder', 'folder5',
                               title='New Content 5')
        createObject(folder3, 'Document', 'page6', title='New Content 6')
        createObject(folder3, 'Document', 'page7', title='New Content 7')
        createObject(folder3, 'Document', 'page8', title='New Content 8')

        self.commit()
        self.es.connection.indices.flush()

        self.assertEqual(
            len(self.catalog(path={'depth': 0, 'query': '/plone/folder0'},
                             SearchableText='new content')), 1)
        self.assertEqual(
            len(self.catalog(path={'depth': 1, 'query': '/plone/folder0'},
                             SearchableText='new content')), 4)
        self.assertEqual(
            len(self.catalog(path={'depth': -1,
                                   'query': '/plone/folder0'},
                             SearchableText='new content')), 9)
        self.assertEqual(
            len(self.catalog(path={'depth': 1, 'query': '/plone'},
                             SearchableText='new content')), 1)
        # this proofs its wrong
        self.assertEqual(
            len(self.catalog(path={'query': '/plone/folder0',
                                   'navtree_start': 0, 'navtree': 1},
                             is_default_page=False,
                             SearchableText='new content')), 9)
Example #36
0
 def test_keyword_index_query(self):
     createObject(self.portal, 'Event', 'event', title='Some Event')
     self.commit()
     self.es.connection.indices.flush()
     el_results = self.catalog(object_provides=[EVENT_KLASS], SearchableText='Event')
     self.assertEqual(len(el_results), 1)
Example #37
0
 def test_has_right_brain_data(self):
     current_length = len(self.catalog._catalog.uids)
     createObject(self.portal, 'Event', 'event', title='Some Event')
     self.assertEqual(current_length + 1, len(self.catalog._catalog.uids))
     self.portal.manage_delObjects(['event'])
     self.assertEqual(current_length, len(self.catalog._catalog.uids))
Example #38
0
 def test_brain_type(self):
     createObject(self.portal, 'Event', 'event', title="Some Event")
     results = self.catalog(portal_type="Event")
     self.assertEquals(type(results[0].aq_base), Brain)
 def test_field_index_query(self):
     createObject(self.portal, 'Event', 'event', title='Some Event')
     self.commit()
     self.es.connection.indices.flush()
     el_results = self.catalog(portal_type='Event', Title='some event')
     self.assertEqual(len(el_results), 1)
    def test_path_index_query(self):
        folder1 = createObject(self.portal,
                               'Folder',
                               'folder0',
                               title='New Content 0')
        createObject(folder1, 'Document', 'page1', title='New Content 1')
        createObject(folder1, 'Document', 'page2', title='New Content 2')
        createObject(folder1, 'Document', 'page3', title='New Content 3')
        folder2 = createObject(folder1,
                               'Folder',
                               'folder4',
                               title='New Content 4')
        folder3 = createObject(folder2,
                               'Folder',
                               'folder5',
                               title='New Content 5')
        createObject(folder3, 'Document', 'page6', title='New Content 6')
        createObject(folder3, 'Document', 'page7', title='New Content 7')
        createObject(folder3, 'Document', 'page8', title='New Content 8')

        self.commit()
        self.es.connection.indices.flush()

        self.assertEqual(
            len(
                self.catalog(path={
                    'depth': 0,
                    'query': '/plone/folder0'
                },
                             SearchableText='new content')), 1)
        self.assertEqual(
            len(
                self.catalog(path={
                    'depth': 1,
                    'query': '/plone/folder0'
                },
                             SearchableText='new content')), 4)
        self.assertEqual(
            len(
                self.catalog(path={
                    'depth': -1,
                    'query': '/plone/folder0'
                },
                             SearchableText='new content')), 9)
        self.assertEqual(
            len(
                self.catalog(path={
                    'depth': 1,
                    'query': '/plone'
                },
                             SearchableText='new content')), 1)
        # this proofs its wrong
        self.assertEqual(
            len(
                self.catalog(path={
                    'query': '/plone/folder0',
                    'navtree_start': 0,
                    'navtree': 1
                },
                             is_default_page=False,
                             SearchableText='new content')), 9)
 def test_has_right_brain_data(self):
     current_length = len(self.catalog._catalog.uids)
     createObject(self.portal, 'Event', 'event', title='Some Event')
     self.assertEqual(current_length + 1, len(self.catalog._catalog.uids))
     self.portal.manage_delObjects(['event'])
     self.assertEqual(current_length, len(self.catalog._catalog.uids))
Example #42
0
 def test_field_index_query(self):
     createObject(self.portal, 'Event', 'event', title="Some Event")
     cat_results = self.searchResults(portal_type="Event")
     el_results = self.catalog(portal_type="Event")
     self.assertEquals(len(cat_results), len(el_results))
     self.assertEquals(len(cat_results), 1)
Example #43
0
 def test_field_index_query(self):
     createObject(self.portal, 'Event', 'event', title='Some Event')
     self.commit()
     self.es.connection.indices.flush()
     el_results = self.catalog(portal_type='Event', Title='some event')
     self.assertEqual(len(el_results), 1)
Example #44
0
 def test_path_index_query(self):
     folder1 = createObject(self.portal, 'Folder', 'folder1',
         title="Folder 1")
     createObject(folder1, 'Document', 'page1', title="Page 1")
     createObject(folder1, 'Document', 'page2', title="Page 2")
     createObject(folder1, 'Document', 'page3', title="Page 3")
     folder2 = createObject(folder1, 'Folder', 'folder2',
         title="Folder 2")
     folder3 = createObject(folder2, 'Folder', 'folder3',
         title="Folder 3")
     createObject(folder3, 'Document', 'page4', title="Page 4")
     createObject(folder3, 'Document', 'page5', title="Page 5")
     createObject(folder3, 'Document', 'page6', title="Page 6")
     self.assertEquals(
         len(self.catalog(path={'depth': 0, 'query': '/plone/folder1'})),
         len(self.searchResults(
             path={'depth': 0, 'query': '/plone/folder1'})))
     self.assertEquals(
         len(self.catalog(path={'depth': 1, 'query': '/plone/folder1'})),
         len(self.searchResults(
                 path={'depth': 1, 'query': '/plone/folder1'})))
     self.assertEquals(
         len(self.catalog(path={'depth': -1, 'query': '/plone/folder1'})),
         len(self.searchResults(
             path={'depth': -1, 'query': '/plone/folder1'})))
     self.assertEquals(
         len(self.catalog(path={'depth': 1, 'query': '/plone'})),
         len(self.searchResults(
                 path={'depth': 1, 'query': '/plone'})))
     self.assertEquals(
         len(self.catalog(path={'query': '/plone/folder1', 'navtree_start': 2, 'navtree': 1},
                          is_default_page=False)),
         len(self.searchResults(
                 path={'query': '/plone/folder1', 'navtree_start': 2, 'navtree': 1},
                 is_default_page=False)))