Commit fb5912f8 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Add test which imports a ZODB Document Component from another one.

parent 765722bb
...@@ -1252,7 +1252,7 @@ class _TestZodbComponent(ERP5TypeTestCase): ...@@ -1252,7 +1252,7 @@ class _TestZodbComponent(ERP5TypeTestCase):
except ImportError: except ImportError:
pass pass
else: else:
raise AssertionError("Component '%s' should have been generated" % \ raise AssertionError("Component '%s' should not have been generated" % \
full_module_name) full_module_name)
def assertModuleImportable(self, module_name): def assertModuleImportable(self, module_name):
...@@ -1262,7 +1262,7 @@ class _TestZodbComponent(ERP5TypeTestCase): ...@@ -1262,7 +1262,7 @@ class _TestZodbComponent(ERP5TypeTestCase):
__import__(full_module_name, fromlist=[self._getComponentModuleName()], __import__(full_module_name, fromlist=[self._getComponentModuleName()],
level=0) level=0)
except ImportError: except ImportError:
raise AssertionError("Component '%s' should not have been generated" % \ raise AssertionError("Component '%s' should have been generated" % \
full_module_name) full_module_name)
def testValidateInvalidate(self): def testValidateInvalidate(self):
...@@ -1477,6 +1477,51 @@ class TestPortalType(Person): ...@@ -1477,6 +1477,51 @@ class TestPortalType(Person):
person_type.setTypeClass('Person') person_type.setTypeClass('Person')
transaction.commit() transaction.commit()
def testDocumentWithImport(self):
self.failIfModuleImportable('TestDocumentWithImport')
self.failIfModuleImportable('TestDocumentImported')
# Create a new Document Component inheriting from Person Document which
# defines only one additional method (meaningful to make sure that the
# class (and not the module) has been added to the class when the
# TypeClass is changed)
test_imported_component = self._newComponent(
'TestDocumentImported',
"""
from Products.ERP5Type.Document.Person import Person
class TestDocumentImported(Person):
def test42(self):
return 42
""")
test_component = self._newComponent(
'TestDocumentWithImport',
"""
from Products.ERP5.Document.Person import Person
from erp5.component.document.TestDocumentImported import TestDocumentImported
class TestDocumentWithImport(TestDocumentImported):
def test42(self):
return 4242
""")
transaction.commit()
self.tic()
self.failIfModuleImportable('TestDocumentWithImport')
self.failIfModuleImportable('TestDocumentImported')
test_imported_component.validate()
test_component.validate()
transaction.commit()
self.tic()
# TestPortalWithImport must be imported first to check if
# TestPortalImported could be imported without being present before
self.assertModuleImportable('TestDocumentWithImport')
self.assertModuleImportable('TestDocumentImported')
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPortalTypeClass)) suite.addTest(unittest.makeSuite(TestPortalTypeClass))
......
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