Commit ea406275 authored by Sebastien Robin's avatar Sebastien Robin

product_config might exist even if it does not contains "erp5" key

To enable DeadlockDebugger in test, we setup a default product_config,
and this was breaking testBusinessTemplate and testDynamicClassGeneration.
Also, stop duplicating code and use a mixin class for the "login" mehtod
used by both tests.
parent d67b584d
......@@ -42,6 +42,7 @@ from Products.CMFCore.Expression import Expression
from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.Workflow import addWorkflowByType
from Products.ERP5Type.tests.backportUnittest import expectedFailure, skip
from Products.ERP5Type.tests.testDynamicClassGeneration import TestDeveloperMixin
from Products.ERP5VCS.WorkingCopy import getVcsTool
import shutil
import os
......@@ -58,7 +59,7 @@ from Products.PortalTransforms.Transform import Transform
Transform_tr_init = Transform._tr_init
Transform_manage_beforeDelete = Transform.manage_beforeDelete
class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
class BusinessTemplateMixin(TestDeveloperMixin, ERP5TypeTestCase, LogInterceptor):
def getBusinessTemplateList(self):
return ('erp5_base',
'erp5_csv_style',
......@@ -6963,25 +6964,6 @@ class TestDocumentTemplateItem(BusinessTemplateMixin):
component_module = DocumentComponent._getDynamicModuleNamespace()
component_portal_type = DocumentComponent.portal_type
def login(self, user_name='ERP5TypeTestCase', quiet=0):
"""
XXX-arnau: Copy/paste from testDynamicClassGeneration
"""
from App.config import getConfiguration
product_config = getattr(getConfiguration(), 'product_config', None)
if product_config is None:
class DummyDeveloperConfig(object):
pass
dummy_developer_config = DummyDeveloperConfig()
dummy_developer_config.developer_list = [user_name]
getConfiguration().product_config = {'erp5': dummy_developer_config}
elif user_name not in product_config['erp5'].developer_list:
product_config['erp5'].developer_list.append(user_name)
return super(TestDocumentTemplateItem, self).login(user_name, quiet)
def stepCreateZodbDocument(self, sequence=None, **kw):
document_id = self.component_module + '.erp5.' + self.document_title
self.getPortalObject().portal_components.newContent(
......
......@@ -1246,34 +1246,39 @@ from Products.ERP5Type.mixin.component import ComponentMixin
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
from App.config import getConfiguration
class _TestZodbComponent(SecurityTestCase):
"""
Abstract class which defined convenient methods used by any Component Test
and tests ran for all Component Test classes
"""
__metaclass__ = abc.ABCMeta
def getBusinessTemplateList(self):
return ('erp5_base',)
class TestDeveloperMixin:
def login(self, user_name='ERP5TypeTestCase', quiet=0):
"""
Make sure that the test user has Developer Role, otherwise the user cannot
do anything on Components...
"""
product_config = getattr(getConfiguration(), 'product_config', None)
config = getConfiguration()
product_config = getattr(config, 'product_config', None)
if product_config is None:
product_config = config.product_config = {}
if product_config.get('erp5') is None:
class DummyDeveloperConfig(object):
pass
dummy_developer_config = DummyDeveloperConfig()
dummy_developer_config.developer_list = [user_name]
getConfiguration().product_config = {'erp5': dummy_developer_config}
product_config['erp5'] = dummy_developer_config
elif user_name not in product_config['erp5'].developer_list:
product_config['erp5'].developer_list.append(user_name)
return super(_TestZodbComponent, self).login(user_name, quiet)
return ERP5TypeTestCase.login(self, user_name, quiet)
class _TestZodbComponent(TestDeveloperMixin, SecurityTestCase):
"""
Abstract class which defined convenient methods used by any Component Test
and tests ran for all Component Test classes
"""
__metaclass__ = abc.ABCMeta
def getBusinessTemplateList(self):
return ('erp5_base',)
def afterSetUp(self):
self._component_tool = self.getPortal().portal_components
......
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