Commit a392266e authored by Rafael Monnerat's avatar Rafael Monnerat

Added a test for WebSection_getDocumentValueList behaviour.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22196 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c3bc331b
...@@ -544,8 +544,8 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -544,8 +544,8 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
#set predicate on web section using 'publication_section' #set predicate on web section using 'publication_section'
websection.edit(membership_criterion_base_category = ['publication_section'], websection.edit(membership_criterion_base_category = ['publication_section'],
membership_criterion_category=['publication_section/%s' membership_criterion_category=['publication_section/%s' \
%publication_section_category_id_list[0]]) % publication_section_category_id_list[0]])
# clean up # clean up
self.web_page_module.manage_delObjects(list(self.web_page_module.objectIds())) self.web_page_module.manage_delObjects(list(self.web_page_module.objectIds()))
portal.portal_categories.publication_section.manage_delObjects( portal.portal_categories.publication_section.manage_delObjects(
...@@ -563,6 +563,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -563,6 +563,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
reference = web_page_reference %index, reference = web_page_reference %index,
publication_section_list=publication_section_category_id_list[:1]) publication_section_list=publication_section_category_id_list[:1])
web_page_list.append(web_page) web_page_list.append(web_page)
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
# in draft state no documents should belong to this Web Section # in draft state no documents should belong to this Web Section
...@@ -718,6 +719,147 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -718,6 +719,147 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self.assertSameSet((), self.assertSameSet((),
section.get_local_roles_for_userid(person_reference)) section.get_local_roles_for_userid(person_reference))
def test_03_WebSection_getDocumentValueListSecurity(self, quiet=quiet, run=run_all_test):
""" Test WebSection_getDocumentValueList behaviour and security"""
if not run:
return
self.changeUser('admin')
web_site_module = self.portal.web_site_module
site = web_site_module.newContent(portal_type='Web Site',
id='site')
section = site.newContent(portal_type='Web Section',
id='section')
get_transaction().commit()
self.tic()
section.setCriterionProperty('portal_type')
section.setCriterion('portal_type', max='',
identity=['Web Page'], min='')
get_transaction().commit()
self.tic()
self.changeUser('erp5user')
page_en_0 = self.portal.web_page_module.newContent(portal_type='Web Page')
page_en_0.edit(reference='my-first-web-page',
language='en',
version='1',
text_format='text/plain',
text_content='Hello, World!')
page_en_1 = self.portal.web_page_module.newContent(portal_type='Web Page')
page_en_1.edit(reference='my-first-web-page',
language='en',
version='2',
text_format='text/plain',
text_content='Hello, World!')
page_en_2 = self.portal.web_page_module.newContent(portal_type='Web Page')
page_en_2.edit(reference='my-second-web-page',
language='en',
version='2',
text_format='text/plain',
text_content='Hello, World!')
page_jp_0 = self.portal.web_page_module.newContent(portal_type='Web Page')
page_jp_0.edit(reference='my-first-japonese-page',
language='jp',
version='1',
text_format='text/plain',
text_content='Hello, World!')
get_transaction().commit()
self.changeUser('erp5user')
self.tic()
self.portal.Localizer.changeLanguage('en')
self.assertEquals(0, len(section.WebSection_getDocumentValueList()))
self.changeUser('erp5user')
page_en_0.publish()
get_transaction().commit()
self.tic()
self.portal.Localizer.changeLanguage('en')
self.assertEquals(1, len(section.WebSection_getDocumentValueList()))
self.assertEquals(page_en_0.getUid(),
section.WebSection_getDocumentValueList()[0].getUid())
self.portal.Localizer.changeLanguage('jp')
self.assertEquals(0, len(section.WebSection_getDocumentValueList()))
# By Anonymous
self.logout()
self.portal.Localizer.changeLanguage('en')
self.assertEquals(1, len(section.WebSection_getDocumentValueList()))
self.assertEquals(page_en_0.getUid(),
section.WebSection_getDocumentValueList()[0].getUid())
self.portal.Localizer.changeLanguage('jp')
self.assertEquals(0, len(section.WebSection_getDocumentValueList()))
# Second Object
self.changeUser('erp5user')
page_en_1.publish()
get_transaction().commit()
self.tic()
self.portal.Localizer.changeLanguage('en')
self.assertEquals(1, len(section.WebSection_getDocumentValueList()))
self.assertEquals(page_en_1.getUid(),
section.WebSection_getDocumentValueList()[0].getUid())
self.portal.Localizer.changeLanguage('jp')
self.assertEquals(0, len(section.WebSection_getDocumentValueList()))
# By Anonymous
self.logout()
self.portal.Localizer.changeLanguage('en')
self.assertEquals(1, len(section.WebSection_getDocumentValueList()))
self.assertEquals(page_en_1.getUid(),
section.WebSection_getDocumentValueList()[0].getUid())
# Trird Object
self.changeUser('erp5user')
page_en_2.publish()
get_transaction().commit()
self.tic()
self.portal.Localizer.changeLanguage('en')
self.assertEquals(2, len(section.WebSection_getDocumentValueList()))
self.portal.Localizer.changeLanguage('jp')
self.assertEquals(0, len(section.WebSection_getDocumentValueList()))
# By Anonymous
self.logout()
self.portal.Localizer.changeLanguage('en')
self.assertEquals(2, len(section.WebSection_getDocumentValueList()))
self.portal.Localizer.changeLanguage('jp')
self.assertEquals(0, len(section.WebSection_getDocumentValueList()))
# First Japonese Object
self.changeUser('erp5user')
page_jp_0.publish()
get_transaction().commit()
self.tic()
self.portal.Localizer.changeLanguage('en')
self.assertEquals(2, len(section.WebSection_getDocumentValueList()))
self.portal.Localizer.changeLanguage('jp')
self.assertEquals(1, len(section.WebSection_getDocumentValueList()))
# By Anonymous
self.logout()
self.portal.Localizer.changeLanguage('en')
self.assertEquals(2, len(section.WebSection_getDocumentValueList()))
self.portal.Localizer.changeLanguage('jp')
self.assertEquals(1, len(section.WebSection_getDocumentValueList()))
self.assertEquals(page_jp_0.getUid(),
section.WebSection_getDocumentValueList()[0].getUid())
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Web)) suite.addTest(unittest.makeSuite(TestERP5Web))
......
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