[Erp5-report] r44022 ivan - /erp5/trunk/products/ERP5/tests/testKM.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Mar 7 16:59:41 CET 2011


Author: ivan
Date: Mon Mar  7 16:59:41 2011
New Revision: 44022

URL: http://svn.erp5.org?rev=44022&view=rev
Log:
Add 'No ZODB' test search.

Modified:
    erp5/trunk/products/ERP5/tests/testKM.py

Modified: erp5/trunk/products/ERP5/tests/testKM.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testKM.py?rev=44022&r1=44021&r2=44022&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testKM.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testKM.py [utf8] Mon Mar  7 16:59:41 2011
@@ -31,6 +31,8 @@ import unittest
 from Testing import ZopeTestCase
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
 from AccessControl.SecurityManagement import newSecurityManager
+from Products.ERP5Type.tests.backportUnittest import expectedFailure
+from Products.ERP5Type.Base import TempBase
 
 def _getGadgetInstanceUrlFromKnowledgePad(knowledge_pad,  gadget):
   """ Get Knowledge Box's relative URL specialising a gadget in a Knowledge Pad."""
@@ -904,22 +906,73 @@ class TestKM(TestKMMixIn):
     self.assertEquals(1,\
       len( websection.WebSection_countAssignmentList(portal_type='Assignment')))                        
 
-class TestKMNoZODBSearch(TestKMMixIn):
+class TestKMSearch(TestKMMixIn):
   
-  business_template_list = TestKMMixIn.business_template_list + \
-                           ['erp5_full_text_sphinxse_catalog', \
-                            'erp5_km_sphinxse_full_text_search']  
-                             
-  def test_01_NoZODBSearch(self):
+  business_template_list = TestKMMixIn.business_template_list + ["erp5_km_ui_test", "erp5_km_sphinxse_full_text_search"]
+  
+  #@expectedFailure
+  def test_01_NoZODBSphinxSeSearch(self):
     """
       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
-    pass
-
+    portal = self.portal
+    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 at 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():
   suite = unittest.TestSuite()
   suite.addTest(unittest.makeSuite(TestKM))
-  #suite.addTest(unittest.makeSuite(TestKMNoZODBSearch))
+  suite.addTest(unittest.makeSuite(TestKMSearch))
   return suite



More information about the Erp5-report mailing list