Commit 15f7d8f1 authored by Sebastien Robin's avatar Sebastien Robin

live tests: simplify the code reactivating subscription of portal_activities

Even though we can have different transactions between the beginning and the
end of a test, transaction.get().__hash__() might return the same value. So
always resubscribe portal_activities if it was subscribed at the beginning
parent 19493316
...@@ -126,13 +126,12 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin): ...@@ -126,13 +126,12 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin):
def _close(self): def _close(self):
'''Closes the ZODB connection.''' '''Closes the ZODB connection.'''
revert = transaction.get().__hash__() != self.initial_transaction_hash
self.abort() self.abort()
self._restoreMailHost() self._restoreMailHost()
if revert: if self.activity_tool_subscribed:
if self.activity_tool_subscribed: self.portal.portal_activities.subscribe()
self.portal.portal_activities.subscribe() self.commit()
self.commit()
def _setup(self): def _setup(self):
'''Change some site properties in order to be ready for live test '''Change some site properties in order to be ready for live test
...@@ -140,7 +139,6 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin): ...@@ -140,7 +139,6 @@ class ERP5TypeLiveTestCase(ERP5TypeTestCaseMixin):
# Disabling portal_activities is required in order to avoid # Disabling portal_activities is required in order to avoid
# conflict with other threads doing tic in the same time # conflict with other threads doing tic in the same time
self.login() self.login()
self.initial_transaction_hash = transaction.get().__hash__()
self.activity_tool_subscribed = self.getPortalObject()\ self.activity_tool_subscribed = self.getPortalObject()\
.portal_activities.isSubscribed() .portal_activities.isSubscribed()
self.portal.portal_activities.unsubscribe() self.portal.portal_activities.unsubscribe()
......
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