Commit 9aca69d4 authored by Vincent Pelletier's avatar Vincent Pelletier

Cleanup globally modified properties.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18505 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 460c86ab
...@@ -1968,9 +1968,10 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -1968,9 +1968,10 @@ class TestCMFActivity(ERP5TypeTestCase):
# Remove one entry from object list: this is understood by caller as a # Remove one entry from object list: this is understood by caller as a
# success for this entry. # success for this entry.
object_list.pop() object_list.pop()
Organisation.modifySQLAndFail = modifySQLAndFail
def dummy(self): def dummy(self):
pass pass
try:
Organisation.modifySQLAndFail = modifySQLAndFail
Organisation.dummy = dummy Organisation.dummy = dummy
obj = self.getPortal().organisation_module.newContent(portal_type='Organisation') obj = self.getPortal().organisation_module.newContent(portal_type='Organisation')
group_method_id = '%s/modifySQLAndFail' % (obj.getPath(), ) group_method_id = '%s/modifySQLAndFail' % (obj.getPath(), )
...@@ -1980,6 +1981,9 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -1980,6 +1981,9 @@ class TestCMFActivity(ERP5TypeTestCase):
get_transaction().commit() get_transaction().commit()
self.flushAllActivities(silent=1, loop_size=100) self.flushAllActivities(silent=1, loop_size=100)
self.assertEquals(activity_tool.countMessage(method_id='dummy_activity'), 0) self.assertEquals(activity_tool.countMessage(method_id='dummy_activity'), 0)
finally:
delattr(Organisation, 'modifySQLAndFail')
delattr(Organisation, 'dummy')
def test_84_ActivityModificationsViaCMFActivityConnectionRolledBackOnErrorSQLQueue(self, quiet=0, run=run_all_test): def test_84_ActivityModificationsViaCMFActivityConnectionRolledBackOnErrorSQLQueue(self, quiet=0, run=run_all_test):
""" """
...@@ -2018,12 +2022,15 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2018,12 +2022,15 @@ class TestCMFActivity(ERP5TypeTestCase):
) )
# Fail # Fail
raise ValueError, 'This method always fail' raise ValueError, 'This method always fail'
try:
Organisation.modifySQLAndFail = modifySQLAndFail Organisation.modifySQLAndFail = modifySQLAndFail
obj = self.getPortal().organisation_module.newContent(portal_type='Organisation') obj = self.getPortal().organisation_module.newContent(portal_type='Organisation')
obj.activate(activity='SQLQueue').modifySQLAndFail() obj.activate(activity='SQLQueue').modifySQLAndFail()
get_transaction().commit() get_transaction().commit()
self.flushAllActivities(silent=1, loop_size=100) self.flushAllActivities(silent=1, loop_size=100)
self.assertEquals(activity_tool.countMessage(method_id='dummy_activity'), 0) self.assertEquals(activity_tool.countMessage(method_id='dummy_activity'), 0)
finally:
dellatr(Organisation, 'modifySQLAndFail')
def test_85_MessagePathMustBeATuple(self, quiet=0, run=run_all_test): def test_85_MessagePathMustBeATuple(self, quiet=0, run=run_all_test):
""" """
...@@ -2081,10 +2088,13 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2081,10 +2088,13 @@ class TestCMFActivity(ERP5TypeTestCase):
) )
# Fail # Fail
raise ValueError, 'This method always fail' raise ValueError, 'This method always fail'
activity_tool.__class__.invoke = modifySQLAndFail
activity_tool.__class__.invokeGroup = modifySQLAndFail
def dummy(self): def dummy(self):
pass pass
invoke = activity_tool.__class__.invoke
invokeGroup = activity_tool.__class__.invokeGroup
try:
activity_tool.__class__.invoke = modifySQLAndFail
activity_tool.__class__.invokeGroup = modifySQLAndFail
Organisation.dummy = dummy Organisation.dummy = dummy
obj = self.getPortal().organisation_module.newContent(portal_type='Organisation') obj = self.getPortal().organisation_module.newContent(portal_type='Organisation')
group_method_id = '%s/dummy' % (obj.getPath(), ) group_method_id = '%s/dummy' % (obj.getPath(), )
...@@ -2094,6 +2104,10 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2094,6 +2104,10 @@ class TestCMFActivity(ERP5TypeTestCase):
get_transaction().commit() get_transaction().commit()
self.flushAllActivities(silent=1, loop_size=100) self.flushAllActivities(silent=1, loop_size=100)
self.assertEquals(activity_tool.countMessage(method_id='dummy_activity'), 0) self.assertEquals(activity_tool.countMessage(method_id='dummy_activity'), 0)
finally:
delattr(Organisation, 'dummy')
activity_tool.__class__.invoke = invoke
activity_tool.__class__.invokeGroup = invokeGroup
def test_87_ActivityToolInvokeFailureDoesNotCommitCMFActivitySQLConnectionSQLQueue(self, quiet=0, run=run_all_test): def test_87_ActivityToolInvokeFailureDoesNotCommitCMFActivitySQLConnectionSQLQueue(self, quiet=0, run=run_all_test):
""" """
...@@ -2131,16 +2145,23 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2131,16 +2145,23 @@ class TestCMFActivity(ERP5TypeTestCase):
) )
# Fail # Fail
raise ValueError, 'This method always fail' raise ValueError, 'This method always fail'
activity_tool.__class__.invoke = modifySQLAndFail
activity_tool.__class__.invokeGroup = modifySQLAndFail
def dummy(self): def dummy(self):
pass pass
invoke = activity_tool.__class__.invoke
invokeGroup = activity_tool.__class__.invokeGroup
try:
activity_tool.__class__.invoke = modifySQLAndFail
activity_tool.__class__.invokeGroup = modifySQLAndFail
Organisation.dummy = dummy Organisation.dummy = dummy
obj = self.getPortal().organisation_module.newContent(portal_type='Organisation') obj = self.getPortal().organisation_module.newContent(portal_type='Organisation')
obj.activate(activity='SQLQueue').dummy() obj.activate(activity='SQLQueue').dummy()
get_transaction().commit() get_transaction().commit()
self.flushAllActivities(silent=1, loop_size=100) self.flushAllActivities(silent=1, loop_size=100)
self.assertEquals(activity_tool.countMessage(method_id='dummy_activity'), 0) self.assertEquals(activity_tool.countMessage(method_id='dummy_activity'), 0)
finally:
delattr(Organisation, 'dummy')
activity_tool.__class__.invoke = invoke
activity_tool.__class__.invokeGroup = invokeGroup
def test_88_ProcessingMultipleMessagesMustRevertIndividualMessagesOnError(self, quiet=0, run=run_all_test): def test_88_ProcessingMultipleMessagesMustRevertIndividualMessagesOnError(self, quiet=0, run=run_all_test):
""" """
...@@ -2165,6 +2186,7 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2165,6 +2186,7 @@ class TestCMFActivity(ERP5TypeTestCase):
self.setTitle(self.getTitle() + to_append) self.setTitle(self.getTitle() + to_append)
if fail: if fail:
raise ValueError, 'This method always fail' raise ValueError, 'This method always fail'
try:
Organisation.appendToTitle = appendToTitle Organisation.appendToTitle = appendToTitle
obj.setTitle('a') obj.setTitle('a')
active_obj.appendToTitle('b') active_obj.appendToTitle('b')
...@@ -2177,6 +2199,8 @@ class TestCMFActivity(ERP5TypeTestCase): ...@@ -2177,6 +2199,8 @@ class TestCMFActivity(ERP5TypeTestCase):
self.flushAllActivities(silent=1, loop_size=100) self.flushAllActivities(silent=1, loop_size=100)
self.assertEqual(activity_tool.countMessage(method_id='appendToTitle'), 1) self.assertEqual(activity_tool.countMessage(method_id='appendToTitle'), 1)
self.assertEqual(obj.getTitle(), 'abd') self.assertEqual(obj.getTitle(), 'abd')
finally:
delattr(Organisation, 'appendToTitle')
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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