Commit 1cb0c529 authored by Jérome Perrin's avatar Jérome Perrin

create installRealClassTool and installDummyClassTool utility functions


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10145 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a98c89de
# we need a class tool for this test.
def allowClassTool():
return 1
import Products.ERP5Type
Products.ERP5Type.allowClassTool = allowClassTool
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
......@@ -20,6 +14,7 @@ from zLOG import LOG, INFO
from Products.CMFCore.tests.base.testcase import LogInterceptor
from Products.ERP5Type.Cache import CachingMethod, clearCache
from Products.ERP5Type.Base import _aq_reset
from Products.ERP5Type.tests.utils import installRealClassTool
class TestERP5Type(ERP5TypeTestCase, LogInterceptor):
......@@ -406,6 +401,7 @@ class TestERP5Type(ERP5TypeTestCase, LogInterceptor):
This is a test to make sure this will not happens any more
"""
if not run: return
installRealClassTool(self.getPortal())
# We will first define a new propertysheet
class_tool = self.getClassTool()
......
......@@ -29,6 +29,7 @@
"""Utility functions and classes for unit testing
"""
import Products.ERP5Type
from Products.MailHost.MailHost import MailHost
class DummyMailHost(MailHost):
......@@ -68,3 +69,24 @@ def removeZODBPythonScript(container, script_id):
Removes a Python script `script_id` in the given `container`.
"""
container.manage_delObjects([script_id])
def installRealClassTool(portal):
"""Replaces portal_classes by a real class tool object.
"""
Products.ERP5Type.allowClassTool = lambda: 1
_recreateClassTool(portal)
def installDummyClassTool(portal):
"""Replaces portal_classes by a dummy class tool object.
"""
Products.ERP5Type.allowClassTool = lambda: 0
_recreateClassTool(portal)
def _recreateClassTool(portal):
"""Recreate the class tool for this portal.
"""
from Products.ERP5Type.Tool import ClassTool
reload(ClassTool)
portal.manage_delObjects(['portal_classes'])
portal._setObject('portal_classes', ClassTool.ClassTool())
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