Commit 279562e4 authored by Julien Muchembled's avatar Julien Muchembled

testBusinessTemplate: ignore errors from PortalTranforms

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41769 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a7a52d77
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
############################################################################## ##############################################################################
import unittest import unittest
import logging
import transaction import transaction
from Testing import ZopeTestCase from Testing import ZopeTestCase
...@@ -62,6 +62,10 @@ WORKFLOW_TYPE = 'erp5_workflow' ...@@ -62,6 +62,10 @@ WORKFLOW_TYPE = 'erp5_workflow'
class DummyTypeProvider(TypeProvider): class DummyTypeProvider(TypeProvider):
id = 'dummy_type_provider' id = 'dummy_type_provider'
from Products.MimetypesRegistry.common import MimeTypeException
from Products.PortalTransforms.Transform import Transform
Transform_tr_init = Transform._tr_init
Transform_manage_beforeDelete = Transform.manage_beforeDelete
class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
""" """
...@@ -93,6 +97,32 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -93,6 +97,32 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
""" """
return 1 return 1
## Ignore errors from PortalTransforms (e.g. missing binaries)
def _catch_log_errors(self):
LogInterceptor._catch_log_errors(self)
level = self.level
def _tr_init(*args, **kw):
self.level = logging.ERROR
try:
Transform_tr_init(*args, **kw)
finally:
self.level = level
Transform._tr_init = _tr_init
def manage_beforeDelete(self, *args, **kw):
try:
Transform_manage_beforeDelete(self, *args, **kw)
except MimeTypeException:
assert self.output == 'BROKEN'
Transform.manage_beforeDelete = manage_beforeDelete
def _ignore_log_errors(self):
Transform._tr_init = Transform_tr_init
Transform.manage_beforeDelete = Transform_manage_beforeDelete
LogInterceptor._ignore_log_errors(self)
###
def afterSetUp(self): def afterSetUp(self):
self.login() self.login()
portal = self.getPortal() portal = self.getPortal()
...@@ -222,11 +252,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -222,11 +252,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
""" """
bt = sequence.get('copy_bt') bt = sequence.get('copy_bt')
self.assertEquals(bt.getTitle(), 'erp5_core') self.assertEquals(bt.getTitle(), 'erp5_core')
# Ignore log, because PortalTransforms outputs an ERROR when it can't load
# a transform due to missing binary.
self._ignore_log_errors()
bt.build() bt.build()
self._catch_log_errors()
def stepInstallCopyCoreBusinessTemplate(self, sequence=None, def stepInstallCopyCoreBusinessTemplate(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
...@@ -236,11 +262,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -236,11 +262,7 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
bt = sequence.get('copy_bt') bt = sequence.get('copy_bt')
self.assertEquals(bt.getTitle(), 'erp5_core') self.assertEquals(bt.getTitle(), 'erp5_core')
self.assertEquals(bt.getInstallationState(), 'not_installed') self.assertEquals(bt.getInstallationState(), 'not_installed')
# Ignore log, because PortalTransforms outputs an ERROR when it can't load
# a transform due to missing binary.
self._ignore_log_errors()
bt.install() bt.install()
self._catch_log_errors()
def stepCheckOriginalAndCopyBusinessTemplate(self, sequence=None, def stepCheckOriginalAndCopyBusinessTemplate(self, sequence=None,
sequence_list=None, **kw): sequence_list=None, **kw):
......
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