Commit f004bd7b authored by Ivan Tyagov's avatar Ivan Tyagov

Add 'No ZODB' test search.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44022 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 134c9cb5
...@@ -31,6 +31,8 @@ import unittest ...@@ -31,6 +31,8 @@ import unittest
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5Type.Base import TempBase
def _getGadgetInstanceUrlFromKnowledgePad(knowledge_pad, gadget): def _getGadgetInstanceUrlFromKnowledgePad(knowledge_pad, gadget):
""" Get Knowledge Box's relative URL specialising a gadget in a Knowledge Pad.""" """ Get Knowledge Box's relative URL specialising a gadget in a Knowledge Pad."""
...@@ -904,22 +906,73 @@ class TestKM(TestKMMixIn): ...@@ -904,22 +906,73 @@ class TestKM(TestKMMixIn):
self.assertEquals(1,\ self.assertEquals(1,\
len( websection.WebSection_countAssignmentList(portal_type='Assignment'))) len( websection.WebSection_countAssignmentList(portal_type='Assignment')))
class TestKMNoZODBSearch(TestKMMixIn): class TestKMSearch(TestKMMixIn):
business_template_list = TestKMMixIn.business_template_list + \ business_template_list = TestKMMixIn.business_template_list + ["erp5_km_ui_test", "erp5_km_sphinxse_full_text_search"]
['erp5_full_text_sphinxse_catalog', \
'erp5_km_sphinxse_full_text_search']
def test_01_NoZODBSearch(self): #@expectedFailure
def test_01_NoZODBSphinxSeSearch(self):
""" """
Test that with 'No ZODB' search we do not access a ZODB object. Test that with 'No ZODB' search we do not access a ZODB object.
Use SphinSe backend at 127.0.0.1:9306
This test will fail if SphinxSe not properly installed therefore marked as expectedFailure
until test environment is properly setup.
See http://www.erp5.org/HowToUseSphinxSE
""" """
# XXX: implement portal = self.portal
pass portal_templates = portal.portal_templates
website = self.portal.web_site_module.km_test_web_site
base_url = "http://www.erp5.org/dists/snapshot/bt5"
# add connection sphinx_sql_connection
connection_id = "sphinx_sql_connection"
portal.manage_addProduct['ZMySQLDA'].manage_addZMySQLConnection(
id=connection_id ,
title="Sphinx",
connection_string="dummy@127.0.0.1:9306")
connection = getattr(portal, connection_id)
connection.manage_open_connection()
self.stepTic()
for bt5_id in ("erp5_full_text_sphinxse_catalog",):
bt5 = portal_templates.download("%s/%s.bt5" %(base_url, bt5_id))
bt5.install()
# make z_catalog_sphinxse_index_list and z0_uncatalog_sphinxse_index use Sphinx connection
z_catalog_sphinxse_index_list = portal.restrictedTraverse("portal_catalog/erp5_mysql_innodb/z_catalog_sphinxse_index_list")
z0_uncatalog_sphinxse_index = portal.restrictedTraverse("portal_catalog/erp5_mysql_innodb/z0_uncatalog_sphinxse_index")
z_catalog_sphinxse_index_list.connection_id=connection_id
z0_uncatalog_sphinxse_index.connection_id=connection_id
website.publish()
self.stepTic()
# reindex site
portal.ERP5Site_reindexSphinxSE()
self.stepTic()
# add some test data
portal.web_page_module.newContent(portal_type='Web Page',
text_content="Sphinx search tool page")
self.stepTic()
self.changeSkin('KM')
# in search mode we do NOT access a ZODB object
kw = {"list_style": "search",
"search_text": "Sphinx search tool page"}
search_result_list = website.WebSite_getFullTextSearchResultList(**kw)
self.assertEqual(1, len(search_result_list))
self.assertTrue(isinstance(search_result_list[0], TempBase))
# in any other mode we do access a ZODB object (i.e. a brain)
kw["list_style"] = "table"
search_result_list = website.WebSite_getFullTextSearchResultList(**kw)
self.assertEqual(1, len(search_result_list))
self.assertEqual(False, isinstance(search_result_list[0], TempBase))
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestKM)) suite.addTest(unittest.makeSuite(TestKM))
#suite.addTest(unittest.makeSuite(TestKMNoZODBSearch)) suite.addTest(unittest.makeSuite(TestKMSearch))
return suite return suite
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment