Commit c3981772 authored by Ivan Tyagov's avatar Ivan Tyagov

Test calculation of documents' Web Section.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44237 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 23851702
...@@ -910,22 +910,16 @@ class TestKMSearch(TestKMMixIn): ...@@ -910,22 +910,16 @@ class TestKMSearch(TestKMMixIn):
business_template_list = TestKMMixIn.business_template_list + ["erp5_km_ui_test_data", "erp5_km_sphinxse_full_text_search"] business_template_list = TestKMMixIn.business_template_list + ["erp5_km_ui_test_data", "erp5_km_sphinxse_full_text_search"]
@expectedFailure def afterSetUp(self):
def test_01_NoZODBSphinxSeSearch(self): self.login()
""" portal = self.getPortal()
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
"""
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 # add connection sphinx_sql_connection
connection_id = "sphinx_sql_connection" connection_id = "sphinx_sql_connection"
if connection_id not in portal.objectIds():
portal_templates = portal.portal_templates
website = self.portal.web_site_module.km_test_web_site
base_url = "http://www.erp5.org/dists/snapshot/bt5"
portal.manage_addProduct['ZMySQLDA'].manage_addZMySQLConnection( portal.manage_addProduct['ZMySQLDA'].manage_addZMySQLConnection(
id=connection_id , id=connection_id ,
title="Sphinx", title="Sphinx",
...@@ -947,28 +941,80 @@ class TestKMSearch(TestKMMixIn): ...@@ -947,28 +941,80 @@ class TestKMSearch(TestKMMixIn):
website.publish() website.publish()
self.stepTic() self.stepTic()
# add some test data
self.web_page = portal.web_page_module.newContent(portal_type='Web Page',
text_content="Sphinx search tool page")
self.stepTic()
# reindex site # reindex site
portal.ERP5Site_reindexSphinxSE() portal.ERP5Site_reindexSphinxSE()
self.stepTic() self.stepTic()
# add some test data @expectedFailure
portal.web_page_module.newContent(portal_type='Web Page', def test_01_NoZODBSphinxSeSearch(self):
text_content="Sphinx search tool page") """
self.stepTic() Test that with 'No ZODB' search we do not access a ZODB object.
self.changeSkin('KM') 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
"""
portal = self.portal
website = self.portal.web_site_module.km_test_web_site
self.changeSkin('KM')
# in search mode we do NOT access a ZODB object # in search mode we do NOT access a ZODB object
kw = {"list_style": "search", kw = {"list_style": "search",
"search_text": "Sphinx search tool page"} "search_text": "Sphinx search tool page"}
search_result_list = website.WebSite_getFullTextSearchResultList(**kw) search_result_list = website.WebSite_getFullTextSearchResultList(**kw)
self.assertEqual(1, len(search_result_list)) self.assertEqual(1, len(search_result_list))
self.assertTrue(isinstance(search_result_list[0], TempBase)) self.assertTrue(isinstance(search_result_list[0], TempBase))
self.assertEqual(self.web_page.getRelativeUrl(), search_result_list[0].path)
# in any other mode we do access a ZODB object (i.e. a brain) # in any other mode we do access a ZODB object (i.e. a brain)
kw["list_style"] = "table" kw["list_style"] = "table"
search_result_list = website.WebSite_getFullTextSearchResultList(**kw) search_result_list = website.WebSite_getFullTextSearchResultList(**kw)
self.assertEqual(1, len(search_result_list)) self.assertEqual(1, len(search_result_list))
self.assertEqual(False, isinstance(search_result_list[0], TempBase)) self.assertEqual(False, isinstance(search_result_list[0], TempBase))
self.assertEqual(self.web_page, search_result_list[0].getObject())
@expectedFailure
def test_02_DocumentWebSectionList(self):
"""
Test determing list of documents web section.
"""
portal = self.portal
website = self.portal.web_site_module.km_test_web_site
web_page = self.web_page
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(0, len(search_result_list[0].section_list))
# set some groups to use Web Sections predicate
group_one = portal.portal_categories.restrictedTraverse("group/test_zuite/1")
web_page.setGroupValueList([group_one])
self.stepTic()
search_result_list = website.WebSite_getFullTextSearchResultList(**kw)
self.assertSameSet([website.restrictedTraverse("1")], \
[portal.restrictedTraverse(x) for x in search_result_list[0].section_list])
# multiple sections
group_two = portal.portal_categories.restrictedTraverse("group/test_zuite/2")
web_page.setGroupValue([group_one, group_two])
self.stepTic()
search_result_list = website.WebSite_getFullTextSearchResultList(**kw)
self.assertSameSet([website.restrictedTraverse("1"), website.restrictedTraverse("2")], \
[portal.restrictedTraverse(x) for x in search_result_list[0].section_list])
# unset
web_page.setGroupValue([])
self.stepTic()
search_result_list = website.WebSite_getFullTextSearchResultList(**kw)
self.assertSameSet([], \
[portal.restrictedTraverse(x) for x in search_result_list[0].section_list])
def test_suite(): def test_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