Commit 14f26ca0 authored by Nicolas Dumazet's avatar Nicolas Dumazet

Fix descendants of PropertySheetTestCase:

* use beforeTearDown instead of tearDown
* pay attention to abort() ordering so that no parent or
  subclass calls can invalidate necessary changes from tearDown logic
* use unique names for property sheets to get independant fixtures.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43099 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 59359459
...@@ -58,10 +58,10 @@ class TestPreferences(PropertySheetTestCase): ...@@ -58,10 +58,10 @@ class TestPreferences(PropertySheetTestCase):
self.createPreferences() self.createPreferences()
def beforeTearDown(self): def beforeTearDown(self):
transaction.abort()
portal_preferences = self.getPreferenceTool() portal_preferences = self.getPreferenceTool()
portal_preferences.manage_delObjects(list(portal_preferences.objectIds())) portal_preferences.manage_delObjects(list(portal_preferences.objectIds()))
transaction.commit() super(TestPreferences, self).beforeTearDown()
self.tic()
def createPreferences(self): def createPreferences(self):
""" create some preferences objects """ """ create some preferences objects """
...@@ -560,11 +560,12 @@ class TestPreferences(PropertySheetTestCase): ...@@ -560,11 +560,12 @@ class TestPreferences(PropertySheetTestCase):
self.assertEqual(system_pref, preference_tool.getActiveSystemPreference()) self.assertEqual(system_pref, preference_tool.getActiveSystemPreference())
def test_boolean_accessor(self): def test_boolean_accessor(self):
self._addProperty('Preference', 'DummyPreference', self._addProperty('Preference',
portal_type='Standard Property', 'test_boolean_accessor Preference',
property_id='dummy', portal_type='Standard Property',
preference=True, property_id='dummy',
elementary_type='boolean') preference=True,
elementary_type='boolean')
portal_preferences = self.portal.portal_preferences portal_preferences = self.portal.portal_preferences
self.assertFalse(portal_preferences.getDummy()) self.assertFalse(portal_preferences.getDummy())
self.assertFalse(portal_preferences.isDummy()) self.assertFalse(portal_preferences.isDummy())
...@@ -584,13 +585,14 @@ class TestPreferences(PropertySheetTestCase): ...@@ -584,13 +585,14 @@ class TestPreferences(PropertySheetTestCase):
write_permission = 'Modify portal content' write_permission = 'Modify portal content'
read_permission = 'Manage portal' read_permission = 'Manage portal'
self._addProperty('Preference', 'DummyPreference', self._addProperty('Preference',
property_id='preferred_toto', 'test_property_sheet_security_on_permission Preference',
portal_type='Standard Property', property_id='preferred_toto',
preference=1, portal_type='Standard Property',
write_permission='Modify portal content', preference=1,
read_permission='Manage portal', write_permission='Modify portal content',
elementary_type='string') read_permission='Manage portal',
elementary_type='string')
obj = self.portal.portal_preferences.newContent(portal_type='Preference') obj = self.portal.portal_preferences.newContent(portal_type='Preference')
obj.enable() obj.enable()
...@@ -633,12 +635,13 @@ class TestPreferences(PropertySheetTestCase): ...@@ -633,12 +635,13 @@ class TestPreferences(PropertySheetTestCase):
default_preference_string = 'Default Name' default_preference_string = 'Default Name'
normal_preference_string = 'Normal Preference' normal_preference_string = 'Normal Preference'
system_preference_string = 'System Preference' system_preference_string = 'System Preference'
self._addProperty('Preference', 'DummySystemPreference', self._addProperty('Preference',
portal_type='Standard Property', 'test_system_preference_value_prefererred Preference',
property_id='dummystring', portal_type='Standard Property',
property_default='python: "%s"' % default_preference_string, property_id='dummystring',
preference=True, property_default='python: "%s"' % default_preference_string,
elementary_type='string') preference=True,
elementary_type='string')
portal_preferences = self.portal.portal_preferences portal_preferences = self.portal.portal_preferences
self.assertEqual(default_preference_string, self.assertEqual(default_preference_string,
portal_preferences.getDummystring()) portal_preferences.getDummystring())
...@@ -667,12 +670,13 @@ class TestPreferences(PropertySheetTestCase): ...@@ -667,12 +670,13 @@ class TestPreferences(PropertySheetTestCase):
default_preference_string = 'Default Name' default_preference_string = 'Default Name'
normal_preference_string = 'Normal Preference' normal_preference_string = 'Normal Preference'
system_preference_string = 'System Preference' system_preference_string = 'System Preference'
self._addProperty('Preference', 'DummySystemPreference', self._addProperty('Preference',
portal_type='Standard Property', 'test_system_preference_value_prefererred_clear_cache_disabled Preference',
property_id='dummystring', portal_type='Standard Property',
property_default='python: "%s"' % default_preference_string, property_id='dummystring',
preference=True, property_default='python: "%s"' % default_preference_string,
elementary_type='string') preference=True,
elementary_type='string')
portal_preferences = self.portal.portal_preferences portal_preferences = self.portal.portal_preferences
self.assertEqual(default_preference_string, self.assertEqual(default_preference_string,
portal_preferences.getDummystring()) portal_preferences.getDummystring())
......
...@@ -72,8 +72,7 @@ class TestConstraint(PropertySheetTestCase): ...@@ -72,8 +72,7 @@ class TestConstraint(PropertySheetTestCase):
transaction.abort() transaction.abort()
module = self.portal.organisation_module module = self.portal.organisation_module
module.manage_delObjects(list(module.objectIds())) module.manage_delObjects(list(module.objectIds()))
transaction.commit() super(TestConstraint, self).beforeTearDown()
self.tic()
def createCategories(self): def createCategories(self):
""" """
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
############################################################################## ##############################################################################
import cPickle import cPickle
import md5
import unittest import unittest
import sys import sys
...@@ -42,7 +41,6 @@ from Products.ERP5Type.tests.utils import LogInterceptor ...@@ -42,7 +41,6 @@ from Products.ERP5Type.tests.utils import LogInterceptor
from Products.CMFCore.WorkflowCore import WorkflowException from Products.CMFCore.WorkflowCore import WorkflowException
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
from Products.ERP5Type.tests.utils import installRealClassTool from Products.ERP5Type.tests.utils import installRealClassTool
from Products.ERP5Type.Utils import removeLocalPropertySheet
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from AccessControl import Unauthorized from AccessControl import Unauthorized
...@@ -64,9 +62,8 @@ class PropertySheetTestCase(ERP5TypeTestCase): ...@@ -64,9 +62,8 @@ class PropertySheetTestCase(ERP5TypeTestCase):
super(PropertySheetTestCase,self).setUp() super(PropertySheetTestCase,self).setUp()
installRealClassTool(self.getPortal()) installRealClassTool(self.getPortal())
def tearDown(self): def beforeTearDown(self):
"""Clean up """ """Clean up """
transaction.abort()
ttool = self.getTypesTool() ttool = self.getTypesTool()
# remove all property sheet we added to type informations # remove all property sheet we added to type informations
for ti_name, psheet_list in self._added_property_sheets.items(): for ti_name, psheet_list in self._added_property_sheets.items():
...@@ -81,7 +78,8 @@ class PropertySheetTestCase(ERP5TypeTestCase): ...@@ -81,7 +78,8 @@ class PropertySheetTestCase(ERP5TypeTestCase):
# but in the other hand, if isolates the test "just in case" # but in the other hand, if isolates the test "just in case"
ttool.resetDynamicDocumentsOnceAtTransactionBoundary() ttool.resetDynamicDocumentsOnceAtTransactionBoundary()
transaction.commit() transaction.commit()
super(PropertySheetTestCase, self).tearDown() self.tic()
super(PropertySheetTestCase, self).beforeTearDown()
def _addProperty(self, portal_type_name, property_sheet_id, def _addProperty(self, portal_type_name, property_sheet_id,
property_id=None, property_id=None,
...@@ -145,8 +143,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -145,8 +143,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.getTypesTool().getTypeInfo('Person').acquire_local_roles = self.person_acquire_local_roles self.getTypesTool().getTypeInfo('Person').acquire_local_roles = self.person_acquire_local_roles
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
transaction.commit() super(TestERP5Type, self).beforeTearDown()
self.tic()
def loginWithNoRole(self): def loginWithNoRole(self):
uf = self.portal.acl_users uf = self.portal.acl_users
...@@ -828,10 +825,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -828,10 +825,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
"""Tests that the default value is returned correctly when a default """Tests that the default value is returned correctly when a default
value is defined using the property sheet. value is defined using the property sheet.
""" """
self._addProperty('Person', 'Person_dummy_ps_prop', 'dummy_ps_prop', self._addProperty('Person',
elementary_type='string', 'test_15b_DefaultValueDefinedOnPropertySheet',
portal_type='Standard Property', 'dummy_ps_prop',
property_default='python: "ps_default"') elementary_type='string',
portal_type='Standard Property',
property_default='python: "ps_default"')
module = self.getPersonModule() module = self.getPersonModule()
person = module.newContent(id='1', portal_type='Person') person = module.newContent(id='1', portal_type='Person')
...@@ -860,10 +859,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -860,10 +859,12 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
"""Tests that the default value is returned correctly when a default """Tests that the default value is returned correctly when a default
value is defined using the property sheet, on list accesors. value is defined using the property sheet, on list accesors.
""" """
self._addProperty('Person', 'Person_dummy_ps_prop', 'dummy_ps_prop', self._addProperty('Person',
elementary_type='lines', 'test_15b_ListAccessorsDefaultValueDefinedOnPropertySheet',
portal_type='Standard Property', 'dummy_ps_prop',
property_default='python: [1,2,3]') elementary_type='lines',
portal_type='Standard Property',
property_default='python: [1,2,3]')
module = self.getPersonModule() module = self.getPersonModule()
person = module.newContent(id='1', portal_type='Person') person = module.newContent(id='1', portal_type='Person')
...@@ -905,9 +906,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -905,9 +906,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def test_16_SimpleStringAccessor(self): def test_16_SimpleStringAccessor(self):
"""Tests a simple string accessor. """Tests a simple string accessor.
This is also a way to test _addProperty method """ This is also a way to test _addProperty method """
self._addProperty('Person', 'Person_dummy_ps_prop', 'dummy_ps_prop', self._addProperty('Person',
elementary_type='string', 'test_16_SimpleStringAccessor',
portal_type='Standard Property') 'dummy_ps_prop',
elementary_type='string',
portal_type='Standard Property')
person = self.getPersonModule().newContent(id='1', portal_type='Person') person = self.getPersonModule().newContent(id='1', portal_type='Person')
self.assertEquals('string', person.getPropertyType('dummy_ps_prop')) self.assertEquals('string', person.getPropertyType('dummy_ps_prop'))
self.assertTrue(hasattr(person, 'getDummyPsProp')) self.assertTrue(hasattr(person, 'getDummyPsProp'))
...@@ -1008,8 +1011,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1008,8 +1011,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
# For testing purposes, we add a default_organisation inside a person, # For testing purposes, we add a default_organisation inside a person,
# and we add code to generate a 'default_organisation_title' property on # and we add code to generate a 'default_organisation_title' property on
# this person that will returns the organisation title. # this person that will returns the organisation title.
self._addProperty('Person', 'Person_organisation', 'organisation', self._addProperty('Person',
**self.DEFAULT_ORGANISATION_TITLE_PROP) 'test_18_SimpleContentAccessor',
'organisation',
**self.DEFAULT_ORGANISATION_TITLE_PROP)
person = self.getPersonModule().newContent(id='1', portal_type='Person') person = self.getPersonModule().newContent(id='1', portal_type='Person')
self.assertTrue(hasattr(person, 'getDefaultOrganisationTitle')) self.assertTrue(hasattr(person, 'getDefaultOrganisationTitle'))
self.assertTrue(hasattr(person, 'setDefaultOrganisationTitle')) self.assertTrue(hasattr(person, 'setDefaultOrganisationTitle'))
...@@ -1070,8 +1075,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1070,8 +1075,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
# This is test is very similar to test_18_SimpleContentAccessor, but we # This is test is very similar to test_18_SimpleContentAccessor, but we
# use reference instead of title, because Reference accessors are # use reference instead of title, because Reference accessors are
# generated. # generated.
self._addProperty('Person', 'Person_organisation', 'organisation', self._addProperty('Person',
**self.DEFAULT_ORGANISATION_TITLE_PROP) 'test_18_SimpleContentAccessorWithGeneratedAccessor',
'organisation',
**self.DEFAULT_ORGANISATION_TITLE_PROP)
person = self.getPersonModule().newContent(id='1', portal_type='Person') person = self.getPersonModule().newContent(id='1', portal_type='Person')
self.assertTrue(hasattr(person, 'getDefaultOrganisationReference')) self.assertTrue(hasattr(person, 'getDefaultOrganisationReference'))
self.assertTrue(hasattr(person, 'setDefaultOrganisationReference')) self.assertTrue(hasattr(person, 'setDefaultOrganisationReference'))
...@@ -1128,8 +1135,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1128,8 +1135,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
that may have the same id, using same scenario as test_18 that may have the same id, using same scenario as test_18
Note that we only test Setter for now. Note that we only test Setter for now.
""" """
self._addProperty('Person', 'Person_organisation', 'organisation', self._addProperty('Person',
**self.DEFAULT_ORGANISATION_TITLE_PROP) 'test_18b_ContentAccessorWithIdClash',
'organisation',
**self.DEFAULT_ORGANISATION_TITLE_PROP)
person = self.getPersonModule().newContent(id='1', portal_type='Person') person = self.getPersonModule().newContent(id='1', portal_type='Person')
another_person = self.getPersonModule().newContent( another_person = self.getPersonModule().newContent(
id='default_organisation', id='default_organisation',
...@@ -1170,8 +1179,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1170,8 +1179,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
# defined, then we will acquire the default organisation title of the # defined, then we will acquire the default organisation title of the
# `destination` person. This is a stupid example, but it works with # `destination` person. This is a stupid example, but it works with
# objects we have in our testing environnement # objects we have in our testing environnement
self._addProperty('Person', 'Person_organisation', 'organisation', self._addProperty('Person',
**self.DEFAULT_ORGANISATION_TITLE_ACQUIRED_PROP) 'test_19_AcquiredContentAccessor',
'organisation',
**self.DEFAULT_ORGANISATION_TITLE_ACQUIRED_PROP)
# add destination base category to Person TI # add destination base category to Person TI
person_ti = self.getTypesTool().getTypeInfo('Person') person_ti = self.getTypesTool().getTypeInfo('Person')
base_category_list = person_ti.getTypeBaseCategoryList() base_category_list = person_ti.getTypeBaseCategoryList()
...@@ -1202,8 +1213,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1202,8 +1213,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
that may have the same id, using same scenario as test_19 that may have the same id, using same scenario as test_19
Note that we only test Setter for now. Note that we only test Setter for now.
""" """
self._addProperty('Person', 'Person_organisation', 'organisation', self._addProperty('Person',
**self.DEFAULT_ORGANISATION_TITLE_ACQUIRED_PROP) 'test_19b_AcquiredContentAccessorWithIdClash',
'organisation',
**self.DEFAULT_ORGANISATION_TITLE_ACQUIRED_PROP)
# add destination base category to Person TI # add destination base category to Person TI
person_ti = self.getTypesTool().getTypeInfo('Person') person_ti = self.getTypesTool().getTypeInfo('Person')
base_category_list = person_ti.getTypeBaseCategoryList() base_category_list = person_ti.getTypeBaseCategoryList()
...@@ -1245,11 +1258,15 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1245,11 +1258,15 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
We check in particular that getDefault[Property] and We check in particular that getDefault[Property] and
setDefault[Property] are working correctly setDefault[Property] are working correctly
""" """
self._addProperty('Person', 'Person_lang', 'available_language', self._addProperty('Person',
commit=False, 'test_19c_AcquiredTokensAccessor_Person',
**self.DEFAULT_LANGUAGE_PROP) 'available_language',
self._addProperty('Email', 'Email_lang', 'available_language', commit=False,
**self.DEFAULT_LANGUAGE_PROP) **self.DEFAULT_LANGUAGE_PROP)
self._addProperty('Email',
'test_19c_AcquiredTokensAccessor_Email',
'available_language',
**self.DEFAULT_LANGUAGE_PROP)
# Category setters (list, set, default) # Category setters (list, set, default)
person = self.getPersonModule().newContent(id='1', portal_type='Person') person = self.getPersonModule().newContent(id='1', portal_type='Person')
...@@ -1281,8 +1298,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1281,8 +1298,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
setDefault[Property] are working correctly setDefault[Property] are working correctly
This test focus on acquisition_mask_value parameter This test focus on acquisition_mask_value parameter
""" """
self._addProperty('Person', 'Person_19c2', 'subordination_organisation_reference', self._addProperty('Person',
**self.SUBORDINATION_ORGANISATION_REFERENCE) 'test_19c2_AcquiredStringAccessor',
'subordination_organisation_reference',
**self.SUBORDINATION_ORGANISATION_REFERENCE)
person = self.getPersonModule().newContent(portal_type='Person') person = self.getPersonModule().newContent(portal_type='Person')
organisation = self.getOrganisationModule()\ organisation = self.getOrganisationModule()\
...@@ -1327,8 +1346,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1327,8 +1346,10 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
setDefault[Property] are working correctly setDefault[Property] are working correctly
This test focus on acquisition_mask_value parameter This test focus on acquisition_mask_value parameter
""" """
self._addProperty('Person', 'Person_19c3', 'subordination_organisation_source_reference', self._addProperty('Person',
**self.SUBORDINATION_ORGANISATION_SOURCE_REFERENCE) 'test_19c3_AcquiredStringAccessor',
'subordination_organisation_source_reference',
**self.SUBORDINATION_ORGANISATION_SOURCE_REFERENCE)
person = self.getPersonModule().newContent(portal_type='Person') person = self.getPersonModule().newContent(portal_type='Person')
organisation = self.getOrganisationModule()\ organisation = self.getOrganisationModule()\
...@@ -1381,21 +1402,26 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1381,21 +1402,26 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
Boolean accessors generate both an getPropertyName and an isPropertyName Boolean accessors generate both an getPropertyName and an isPropertyName
Check in particular that both behave the same way regarding acquisition Check in particular that both behave the same way regarding acquisition
""" """
self._addProperty('Person', 'Person_19d', 'name_included_in_address', self._addProperty('Person',
commit=False, 'test_19d_AcquiredBooleanAccessor_Person',
portal_type='Standard Property', 'name_included_in_address',
property_default="python: True", commit=False,
elementary_type="boolean") portal_type='Standard Property',
self._addProperty('Email', 'Email_19d', 'name_included_in_address', property_default="python: True",
content_acquired_property_id=('name_included_in_address', ), elementary_type="boolean")
acquisition_base_category=( 'parent', ), self._addProperty('Email',
acquisition_portal_type="python: ( 'Person', )", 'test_19d_AcquiredBooleanAccessor_Email',
acquisition_copy_value=0, 'name_included_in_address',
acquisition_mask_value=1, 'name_included_in_address',
acquisition_accessor_id='getNameIncludedInAddress', content_acquired_property_id=('name_included_in_address', ),
portal_type='Acquired Property', acquisition_base_category=( 'parent', ),
property_default="python: True", acquisition_portal_type="python: ( 'Person', )",
elementary_type="boolean") acquisition_copy_value=0,
acquisition_mask_value=1,
acquisition_accessor_id='getNameIncludedInAddress',
portal_type='Acquired Property',
property_default="python: True",
elementary_type="boolean")
person = self.getPersonModule().newContent(portal_type='Person') person = self.getPersonModule().newContent(portal_type='Person')
email = person.newContent(portal_type='Email') email = person.newContent(portal_type='Email')
...@@ -1814,9 +1840,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -1814,9 +1840,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
"""Test 'has' Accessor. """Test 'has' Accessor.
This accessor returns true if the property is set on the document. This accessor returns true if the property is set on the document.
""" """
self._addProperty('Person', 'Person_foobar', 'foo_bar', self._addProperty('Person',
elementary_type='string', 'test_26_hasAccessors',
portal_type='Standard Property') 'foo_bar',
elementary_type='string',
portal_type='Standard Property')
obj = self.getPersonModule().newContent(portal_type='Person') obj = self.getPersonModule().newContent(portal_type='Person')
self.assertTrue(hasattr(obj, 'hasFooBar')) self.assertTrue(hasattr(obj, 'hasFooBar'))
self.failIf(obj.hasFooBar()) self.failIf(obj.hasFooBar())
...@@ -2193,16 +2221,18 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2193,16 +2221,18 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
region_category.restrictedTraverse, "beta") region_category.restrictedTraverse, "beta")
# Define the acquired property # Define the acquired property
self._addProperty('Person', 'Person_test_unaccessible', 'wrapped_region_title', self._addProperty('Person',
portal_type='Acquired Property', 'Person_test_unaccessible',
elementary_type='lines', 'wrapped_region_title',
description='The title of the region', portal_type='Acquired Property',
content_acquired_property_id=('description', ), elementary_type='lines',
acquisition_base_category=( 'region', ), description='The title of the region',
acquisition_portal_type="python: ( 'Category', )", content_acquired_property_id=('description', ),
alt_accessor_id=('_categoryGetRegionTitle', ), acquisition_base_category=( 'region', ),
acquisition_copy_value=0, acquisition_portal_type="python: ( 'Category', )",
acquisition_accessor_id='getTitle') alt_accessor_id=('_categoryGetRegionTitle', ),
acquisition_copy_value=0,
acquisition_accessor_id='getTitle')
# Create a new person, and associate it to beta and gamma. # Create a new person, and associate it to beta and gamma.
module = self.getPersonModule() module = self.getPersonModule()
...@@ -2282,9 +2312,9 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2282,9 +2312,9 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
logged_errors[0].getMessage()) logged_errors[0].getMessage())
def test_list_accessors(self): def test_list_accessors(self):
self._addProperty('Person', 'Person_dummy', 'dummy', self._addProperty('Person', 'test_list_accessors', 'dummy',
elementary_type='lines', elementary_type='lines',
portal_type='Standard Property') portal_type='Standard Property')
module = self.getPersonModule() module = self.getPersonModule()
# we set the property on the module, to check acquisition works as # we set the property on the module, to check acquisition works as
# expected. # expected.
...@@ -2310,11 +2340,13 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2310,11 +2340,13 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertEquals(person.getDummySet(), ['value']) self.assertEquals(person.getDummySet(), ['value'])
def test_translated_accessors(self): def test_translated_accessors(self):
self._addProperty('Person', 'Person_dummy', 'dummy', self._addProperty('Person',
elementary_type='string', 'test_translated_accessors',
translatable=1, 'dummy',
translation_domain='erp5_ui', elementary_type='string',
portal_type='Standard Property') translatable=1,
translation_domain='erp5_ui',
portal_type='Standard Property')
self.portal.Localizer = DummyLocalizer() self.portal.Localizer = DummyLocalizer()
doc = self.portal.person_module.newContent(portal_type='Person') doc = self.portal.person_module.newContent(portal_type='Person')
...@@ -2546,9 +2578,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2546,9 +2578,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def test_DefaultSecurityOnAccessors(self): def test_DefaultSecurityOnAccessors(self):
# Test accessors are protected correctly # Test accessors are protected correctly
self._addProperty('Person', 'Person_foobar', 'foo_bar', self._addProperty('Person',
elementary_type='string', 'test_DefaultSecurityOnAccessors',
portal_type='Standard Property') 'foo_bar',
elementary_type='string',
portal_type='Standard Property')
obj = self.getPersonModule().newContent(portal_type='Person') obj = self.getPersonModule().newContent(portal_type='Person')
self.assertTrue(guarded_hasattr(obj, 'setFooBar')) self.assertTrue(guarded_hasattr(obj, 'setFooBar'))
...@@ -2567,9 +2601,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2567,9 +2601,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def test_DefaultSecurityOnListAccessors(self): def test_DefaultSecurityOnListAccessors(self):
# Test list accessors are protected correctly # Test list accessors are protected correctly
self._addProperty('Person', 'Person_foobar', 'foo_bar', self._addProperty('Person',
elementary_type='lines', 'test_DefaultSecurityOnListAccessors',
portal_type='Standard Property') 'foo_bar',
elementary_type='lines',
portal_type='Standard Property')
obj = self.getPersonModule().newContent(portal_type='Person') obj = self.getPersonModule().newContent(portal_type='Person')
self.assertTrue(guarded_hasattr(obj, 'setFooBarList')) self.assertTrue(guarded_hasattr(obj, 'setFooBarList'))
self.assertTrue(guarded_hasattr(obj, 'getFooBarList')) self.assertTrue(guarded_hasattr(obj, 'getFooBarList'))
...@@ -2624,11 +2660,13 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2624,11 +2660,13 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def test_PropertySheetSecurityOnAccessors(self): def test_PropertySheetSecurityOnAccessors(self):
# Test accessors are protected correctly when you specify the permission # Test accessors are protected correctly when you specify the permission
# in the property sheet. # in the property sheet.
self._addProperty('Person', 'Person_foobar', 'foo_bar', self._addProperty('Person',
elementary_type='string', 'test_PropertySheetSecurityOnAccessors',
write_permission='Set own password', 'foo_bar',
read_permission='Manage users', elementary_type='string',
portal_type='Standard Property') write_permission='Set own password',
read_permission='Manage users',
portal_type='Standard Property')
obj = self.getPersonModule().newContent(portal_type='Person') obj = self.getPersonModule().newContent(portal_type='Person')
self.assertTrue(guarded_hasattr(obj, 'setFooBar')) self.assertTrue(guarded_hasattr(obj, 'setFooBar'))
self.assertTrue(guarded_hasattr(obj, 'getFooBar')) self.assertTrue(guarded_hasattr(obj, 'getFooBar'))
...@@ -2643,11 +2681,13 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2643,11 +2681,13 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
self.assertFalse(guarded_hasattr(obj, 'getFooBar')) self.assertFalse(guarded_hasattr(obj, 'getFooBar'))
def test_edit(self): def test_edit(self):
self._addProperty('Person', 'Person_foobar', 'foo_bar', self._addProperty('Person',
elementary_type='string', 'test_edit',
write_permission='Set own password', 'foo_bar',
read_permission='Manage users', elementary_type='string',
portal_type='Standard Property') write_permission='Set own password',
read_permission='Manage users',
portal_type='Standard Property')
obj = self.getPersonModule().newContent(portal_type='Person') obj = self.getPersonModule().newContent(portal_type='Person')
obj.edit(foo_bar="v1") obj.edit(foo_bar="v1")
self.assertEqual(obj.getFooBar(), "v1") self.assertEqual(obj.getFooBar(), "v1")
...@@ -2724,9 +2764,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2724,9 +2764,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
Check that we can use setPropertyList and getPropertyList Check that we can use setPropertyList and getPropertyList
on a mono valued property on a mono valued property
""" """
self._addProperty('Person', 'Person_foobar', 'foo_bar', self._addProperty('Person',
elementary_type='string', 'testPropertyListWithMonoValuedProperty',
portal_type='Standard Property') 'foo_bar',
elementary_type='string',
portal_type='Standard Property')
person = self.getPersonModule().newContent(portal_type='Person') person = self.getPersonModule().newContent(portal_type='Person')
email = person.newContent(portal_type='Email') email = person.newContent(portal_type='Email')
self.assertEquals(None, getattr(person, 'getFooBarList', None)) self.assertEquals(None, getattr(person, 'getFooBarList', None))
...@@ -2750,19 +2792,23 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2750,19 +2792,23 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
Check that we can use setPropertyList and getPropertyList Check that we can use setPropertyList and getPropertyList
on a mono valued acquired property on a mono valued acquired property
""" """
self._addProperty('Person', 'Person_foobar', 'foo_bar', self._addProperty('Person',
commit=False, 'testPropertyListOnMonoValuedAcquiredProperty_Person',
elementary_type='string', 'foo_bar',
portal_type='Standard Property') commit=False,
self._addProperty('Email', 'Email_foobar', 'foo_bar', elementary_type='string',
elementary_type='string', portal_type='Standard Property')
portal_type='Acquired Property', self._addProperty('Email',
content_acquired_property_id=('description', ), 'testPropertyListOnMonoValuedAcquiredProperty_Email',
acquisition_base_category=( 'parent', ), 'foo_bar',
acquisition_portal_type="python: ( 'Person', )", elementary_type='string',
acquisition_copy_value=0, portal_type='Acquired Property',
acquisition_mask_value=1, content_acquired_property_id=('description', ),
acquisition_accessor_id='getFooBar') acquisition_base_category=( 'parent', ),
acquisition_portal_type="python: ( 'Person', )",
acquisition_copy_value=0,
acquisition_mask_value=1,
acquisition_accessor_id='getFooBar')
person = self.getPersonModule().newContent(portal_type='Person') person = self.getPersonModule().newContent(portal_type='Person')
email = person.newContent(portal_type='Email') email = person.newContent(portal_type='Email')
self.assertEquals(email.getPropertyList('foo_bar'), [None]) self.assertEquals(email.getPropertyList('foo_bar'), [None])
...@@ -2780,9 +2826,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): ...@@ -2780,9 +2826,11 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
Check that we can use setPropertyList and getPropertyList Check that we can use setPropertyList and getPropertyList
on a multi valued property on a multi valued property
""" """
self._addProperty('Person', 'Person_foobar', 'foo_bar', self._addProperty('Person',
elementary_type='lines', 'testPropertyListWithMultiValuedProperty',
portal_type='Standard Property') 'foo_bar',
elementary_type='lines',
portal_type='Standard Property')
person = self.getPersonModule().newContent(portal_type='Person') person = self.getPersonModule().newContent(portal_type='Person')
# We have None, like test_list_accessors # We have None, like test_list_accessors
self.assertEquals(person.getFooBarList(), None) self.assertEquals(person.getFooBarList(), None)
......
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