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):
""" """
......
This diff is collapsed.
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