Commit 01c261fb authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Module Component: Add Unit Tests.

parent ea30cba0
Pipeline #11804 passed with stage
in 0 seconds
...@@ -1429,18 +1429,18 @@ def assertResetCalled(*args, **kwargs): ...@@ -1429,18 +1429,18 @@ def assertResetCalled(*args, **kwargs):
return reset_performed return reset_performed
import abc
from Products.ERP5Type.mixin.component import ComponentMixin from Products.ERP5Type.mixin.component import ComponentMixin
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
from App.config import getConfiguration from App.config import getConfiguration
from Products.ERP5Type.Core.ModuleComponent import ModuleComponent
class _TestZodbComponent(SecurityTestCase): class TestZodbModuleComponent(SecurityTestCase):
""" """
Abstract class which defined convenient methods used by any Component Test Tests for ZODB Module Component (base class of all other Component
and tests ran for all Component Test classes classes)
""" """
__metaclass__ = abc.ABCMeta _portal_type = 'Module Component'
_document_class = ModuleComponent
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
return ('erp5_base',) return ('erp5_base',)
...@@ -1455,8 +1455,10 @@ class _TestZodbComponent(SecurityTestCase): ...@@ -1455,8 +1455,10 @@ class _TestZodbComponent(SecurityTestCase):
def _generateReference(self, base_name): def _generateReference(self, base_name):
return base_name return base_name
def _getValidSourceCode(self, class_name): def _getValidSourceCode(self, *_):
raise NotImplementedError return '''def foobar(*args, **kwargs):
return 'Anything'
'''
def _newComponent(self, reference, text_content=None, version='erp5', id_=None): def _newComponent(self, reference, text_content=None, version='erp5', id_=None):
""" """
...@@ -2553,7 +2555,7 @@ return 'OK' ...@@ -2553,7 +2555,7 @@ return 'OK'
from Products.ERP5Type.Core.ExtensionComponent import ExtensionComponent from Products.ERP5Type.Core.ExtensionComponent import ExtensionComponent
class TestZodbExtensionComponent(_TestZodbComponent): class TestZodbExtensionComponent(TestZodbModuleComponent):
""" """
Tests specific to ZODB Extension Component (previously defined in bt5 and Tests specific to ZODB Extension Component (previously defined in bt5 and
installed on the filesystem in $INSTANCE_HOME/Extensions) installed on the filesystem in $INSTANCE_HOME/Extensions)
...@@ -2561,11 +2563,6 @@ class TestZodbExtensionComponent(_TestZodbComponent): ...@@ -2561,11 +2563,6 @@ class TestZodbExtensionComponent(_TestZodbComponent):
_portal_type = 'Extension Component' _portal_type = 'Extension Component'
_document_class = ExtensionComponent _document_class = ExtensionComponent
def _getValidSourceCode(self, *_):
return '''def foobar(*args, **kwargs):
return 'Anything'
'''
def testExternalMethod(self): def testExternalMethod(self):
""" """
Check that ExternalMethod monkey-patch to use ZODB Components works well Check that ExternalMethod monkey-patch to use ZODB Components works well
...@@ -2655,7 +2652,7 @@ def foobar(self, a, b="portal_type"): ...@@ -2655,7 +2652,7 @@ def foobar(self, a, b="portal_type"):
from Products.ERP5Type.Core.DocumentComponent import DocumentComponent from Products.ERP5Type.Core.DocumentComponent import DocumentComponent
class _TestZodbDocumentComponentMixin(_TestZodbComponent): class _TestZodbDocumentComponentMixin(TestZodbModuleComponent):
""" """
Common to all Component class inheriting from Document Component (so Common to all Component class inheriting from Document Component (so
Interface, Tool and Mixin) Interface, Tool and Mixin)
...@@ -3070,7 +3067,7 @@ InitializeClass(%(class_name)s) ...@@ -3070,7 +3067,7 @@ InitializeClass(%(class_name)s)
from Products.ERP5Type.Core.TestComponent import TestComponent from Products.ERP5Type.Core.TestComponent import TestComponent
class TestZodbTestComponent(_TestZodbComponent): class TestZodbTestComponent(TestZodbModuleComponent):
""" """
Tests specific to ZODB Test Component (known as Live Tests, and previously Tests specific to ZODB Test Component (known as Live Tests, and previously
defined in bt5 and installed in $INSTANCE_HOME/test) defined in bt5 and installed in $INSTANCE_HOME/test)
...@@ -3473,6 +3470,7 @@ def test_suite(): ...@@ -3473,6 +3470,7 @@ def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPortalTypeClass)) suite.addTest(unittest.makeSuite(TestPortalTypeClass))
suite.addTest(unittest.makeSuite(TestZodbPropertySheet)) suite.addTest(unittest.makeSuite(TestZodbPropertySheet))
suite.addTest(unittest.makeSuite(TestZodbModuleComponent))
suite.addTest(unittest.makeSuite(TestZodbExtensionComponent)) suite.addTest(unittest.makeSuite(TestZodbExtensionComponent))
suite.addTest(unittest.makeSuite(TestZodbDocumentComponent)) suite.addTest(unittest.makeSuite(TestZodbDocumentComponent))
suite.addTest(unittest.makeSuite(TestZodbToolComponent)) suite.addTest(unittest.makeSuite(TestZodbToolComponent))
......
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