Commit d78a2b5b authored by Sebastien Robin's avatar Sebastien Robin

ERP5Type tests: make sure to enable developer role when "--save --load" is used

parent 0db06a63
...@@ -61,6 +61,7 @@ from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter ...@@ -61,6 +61,7 @@ from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
from zLOG import LOG, DEBUG from zLOG import LOG, DEBUG
from Products.ERP5Type.tests.backportUnittest import SetupSiteError from Products.ERP5Type.tests.backportUnittest import SetupSiteError
from Products.ERP5Type.tests.utils import addUserToDeveloperRole
from Products.ERP5Type.tests.utils import DummyMailHostMixin, parseListeningAddress from Products.ERP5Type.tests.utils import DummyMailHostMixin, parseListeningAddress
# Quiet messages when installing business templates # Quiet messages when installing business templates
...@@ -199,21 +200,6 @@ def _parse_args(self, *args, **kw): ...@@ -199,21 +200,6 @@ def _parse_args(self, *args, **kw):
_parse_args._original = DateTime._original_parse_args _parse_args._original = DateTime._original_parse_args
DateTime._parse_args = _parse_args DateTime._parse_args = _parse_args
def addUserToDeveloperRole(user_name):
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]
product_config['erp5'] = dummy_developer_config
elif user_name not in product_config['erp5'].developer_list:
product_config['erp5'].developer_list.append(user_name)
class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
"""Mixin class for ERP5 based tests. """Mixin class for ERP5 based tests.
""" """
......
...@@ -9,6 +9,7 @@ from ZODB.POSException import ConflictError ...@@ -9,6 +9,7 @@ from ZODB.POSException import ConflictError
from zLOG import LOG, ERROR from zLOG import LOG, ERROR
from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY
from Products.ERP5Type.tests import backportUnittest from Products.ERP5Type.tests import backportUnittest
from Products.ERP5Type.tests.utils import addUserToDeveloperRole
from Products.ERP5Type.tests.utils import createZServer from Products.ERP5Type.tests.utils import createZServer
...@@ -256,6 +257,8 @@ class ProcessingNodeTestCase(backportUnittest.TestCase, ZopeTestCase.TestCase): ...@@ -256,6 +257,8 @@ class ProcessingNodeTestCase(backportUnittest.TestCase, ZopeTestCase.TestCase):
def afterSetUp(self): def afterSetUp(self):
"""Initialize a node that will only process activities""" """Initialize a node that will only process activities"""
self.startZServer() self.startZServer()
# Make sure to still have possibilities to edit components
addUserToDeveloperRole('ERP5TypeTestCase')
from Zope2.custom_zodb import cluster from Zope2.custom_zodb import cluster
self._registerNode(distributing=not cluster, processing=1) self._registerNode(distributing=not cluster, processing=1)
self.commit() self.commit()
......
...@@ -182,6 +182,20 @@ class DummyLocalizer: ...@@ -182,6 +182,20 @@ class DummyLocalizer:
# the before traverse hook # the before traverse hook
pass pass
def addUserToDeveloperRole(user_name):
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]
product_config['erp5'] = dummy_developer_config
elif user_name not in product_config['erp5'].developer_list:
product_config['erp5'].developer_list.append(user_name)
# python scripts # python scripts
def createZODBPythonScript(container, script_id, script_params, def createZODBPythonScript(container, script_id, script_params,
......
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