Permalink
Browse files

add test for search-indexes

  • Loading branch information...
1 parent 651dbe2 commit af53f71c8ee590ff9930bee49efa555252f3d70b @pbauer pbauer committed Feb 26, 2012
Showing with 48 additions and 0 deletions.
  1. +48 −0 plone/app/contenttypes/tests/test_indexes.py
View
48 plone/app/contenttypes/tests/test_indexes.py
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+import unittest2 as unittest
+
+from Products.CMFCore.utils import getToolByName
+
+from plone.app.contenttypes.testing import \
+ PLONE_APP_CONTENTTYPES_INTEGRATION_TESTING
+
+from plone.app.testing import TEST_USER_ID, setRoles
+
+
+class CatalogIntegrationTest(unittest.TestCase):
+
+ layer = PLONE_APP_CONTENTTYPES_INTEGRATION_TESTING
+
+ def setUp(self):
+ self.portal = self.layer['portal']
+ setRoles(self.portal, TEST_USER_ID, ['Manager'])
+ self.portal.invokeFactory('Folder', 'folder')
+ self.folder = self.portal.folder
+ self.folder.invokeFactory('Document',
+ 'document')
+ self.document = self.folder.document
+ self.catalog = getToolByName(self.portal, 'portal_catalog')
+
+ def test_title_in_searchable_text_index(self):
+ self.document.title = "My title"
+ self.document.reindexObject()
+ brains = self.catalog.searchResults(dict(
+ SearchableText="My title",
+ portal_type="Document"
+ ))
+ self.assertEqual(len(brains), 1)
+ self.assertEquals(brains[0].getPath(),
+ '/plone/folder/document')
+
+ def test_description_in_searchable_text_index(self):
+ self.document.description = "My description"
+ self.document.reindexObject()
+ brains = self.catalog.searchResults(dict(
+ SearchableText="My description",
+ portal_type="Document"
+ ))
+ self.assertEqual(len(brains), 1)
+ self.assertEquals(brains[0].getPath(),
+ '/plone/folder/document')
+
+

0 comments on commit af53f71

Please sign in to comment.