Commit 47c2617d authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add a test for acquisition wrappers, and fix some style mess.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22292 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 87dbbd1a
...@@ -102,27 +102,24 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -102,27 +102,24 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
""" """
web_site_module = self.portal.getDefaultModule('Web Site') web_site_module = self.portal.getDefaultModule('Web Site')
website = web_site_module[self.website_id] website = web_site_module[self.website_id]
websection = website.newContent(portal_type = 'Web Section', **kw) websection = website.newContent(portal_type='Web Section', **kw)
self.websection = websection self.websection = websection
kw = dict(criterion_property_list = 'portal_type', kw = dict(criterion_property_list = 'portal_type',
membership_criterion_base_category_list = '', membership_criterion_base_category_list='',
membership_criterion_category_list = '',) membership_criterion_category_list='')
websection.edit(**kw) websection.edit(**kw)
websection.setCriterion(property = 'portal_type', websection.setCriterion(property='portal_type',
identity = ['Web Page'], identity=['Web Page'],
max = '', max='',
min = '') min='')
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
return websection return websection
def setupWebSitePages(self, def setupWebSitePages(self, prefix, suffix=None, version='0.1',
prefix, language_list=LANGUAGE_LIST, **kw):
suffix = None,
version = '0.1',
language_list = LANGUAGE_LIST):
""" """
Setup some Web Pages. Setup some Web Pages.
""" """
...@@ -135,23 +132,23 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -135,23 +132,23 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
# create sample web pages # create sample web pages
for language in language_list: for language in language_list:
if suffix is not None: if suffix is not None:
reference = '%s-%s' %(prefix, language) reference = '%s-%s' % (prefix, language)
else: else:
reference = prefix reference = prefix
webpage = self.web_page_module.newContent(portal_type = 'Web Page', webpage = self.web_page_module.newContent(portal_type='Web Page',
reference = reference, reference=reference,
version = version, version=version,
language = language) language=language,
**kw)
webpage.publish() webpage.publish()
webpage.reindexObject() get_transaction().commit()
self.tic()
self.assertEquals(language, webpage.getLanguage()) self.assertEquals(language, webpage.getLanguage())
self.assertEquals(reference, webpage.getReference()) self.assertEquals(reference, webpage.getReference())
self.assertEquals(version, webpage.getVersion()) self.assertEquals(version, webpage.getVersion())
self.assertEquals('published', webpage.getValidationState()) self.assertEquals('published', webpage.getValidationState())
webpage_list.append(webpage) webpage_list.append(webpage)
get_transaction().commit()
self.tic()
return webpage_list return webpage_list
...@@ -710,6 +707,64 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -710,6 +707,64 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
self.web_page_module.manage_delObjects(list(self.web_page_module.objectIds())) self.web_page_module.manage_delObjects(list(self.web_page_module.objectIds()))
def test_12_AcquisitionWrappers(self, quiet=quiet, run=run_all_test):
"""Test acquisition wrappers of documents.
Check if documents obtained by getDefaultDocumentValue, getDocumentValue
and getDocumentValueList are wrapped appropriately.
"""
if not run: return
if not quiet:
message = '\ntest_12_AcquisitionWrappers'
ZopeTestCase._print(message)
portal = self.getPortal()
# Make its own publication section category.
publication_section = portal.portal_categories['publication_section']
if publication_section._getOb('my_test_category', None) is None:
publication_section.newContent(portal_type='Category',
id='my_test_category',
title='Test')
get_transaction().commit()
self.tic()
website = self.setupWebSite()
websection = self.setupWebSection(
membership_criterion_base_category_list=('publication_section',),
membership_criterion_category=('publication_section/my_test_category',),
)
# Create at least two documents which belong to the publication section
# category.
web_page_list = self.setupWebSitePages('test1',
language_list=('en',),
publication_section_list=('my_test_category',))
web_page_list2 = self.setupWebSitePages('test2',
language_list=('en',),
publication_section_list=('my_test_category',))
# We need a default document.
websection.setAggregateValue(web_page_list[0])
get_transaction().commit()
self.tic()
# Obtain documens in various ways.
default_document = websection.getDefaultDocumentValue()
self.assertNotEquals(default_document, None)
document1 = websection.getDocumentValue('test1')
self.assertNotEquals(document1, None)
document2 = websection.getDocumentValue('test2')
self.assertNotEquals(document2, None)
document_list = websection.getDocumentValueList()
self.assertNotEquals(document_list, None)
self.assertNotEquals(len(document_list), 0)
# Check if they have good acquisition wrappers.
for doc in (default_document, document1, document2) + tuple(document_list):
self.assertEquals(doc.aq_parent, websection)
self.assertEquals(doc.aq_parent.aq_parent, website)
class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
""" """
......
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