Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amer
erp5
Commits
7faa0c7d
Commit
7faa0c7d
authored
Feb 04, 2019
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP
parent
dd2505f5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
5 deletions
+79
-5
product/ERP5Type/Core/DocumentComponent.py
product/ERP5Type/Core/DocumentComponent.py
+13
-2
product/ERP5Type/Core/MixinComponent.py
product/ERP5Type/Core/MixinComponent.py
+1
-0
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+65
-3
No files found.
product/ERP5Type/Core/DocumentComponent.py
View file @
7faa0c7d
...
@@ -75,8 +75,19 @@ class DocumentComponent(ComponentMixin, TextContentHistoryMixin):
...
@@ -75,8 +75,19 @@ class DocumentComponent(ComponentMixin, TextContentHistoryMixin):
error_list
=
super
(
DocumentComponent
,
self
).
checkConsistency
(
*
args
,
**
kw
)
error_list
=
super
(
DocumentComponent
,
self
).
checkConsistency
(
*
args
,
**
kw
)
reference
=
self
.
getReference
()
reference
=
self
.
getReference
()
text_content
=
self
.
getTextContent
()
text_content
=
self
.
getTextContent
()
if
(
reference
and
text_content
and
# Already checked in the parent class
# Already checked in the parent class
'class %s('
%
reference
not
in
text_content
):
if
reference
and
text_content
:
class_definition_str
=
'class %s'
%
reference
try
:
sep
=
text_content
[
text_content
.
index
(
class_definition_str
)
+
len
(
class_definition_str
)]
except
(
ValueError
,
IndexError
):
pass
else
:
if
(
sep
==
':'
or
# old-style class
sep
==
'('
):
# new-style class
return
error_list
error_list
.
append
(
ConsistencyMessage
(
error_list
.
append
(
ConsistencyMessage
(
self
,
self
,
self
.
getRelativeUrl
(),
self
.
getRelativeUrl
(),
...
...
product/ERP5Type/Core/MixinComponent.py
View file @
7faa0c7d
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
##############################################################################
##############################################################################
from
Products.ERP5Type.Core.DocumentComponent
import
DocumentComponent
from
Products.ERP5Type.Core.DocumentComponent
import
DocumentComponent
from
Products.ERP5Type.ConsistencyMessage
import
ConsistencyMessage
class
MixinComponent
(
DocumentComponent
):
class
MixinComponent
(
DocumentComponent
):
"""
"""
...
...
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
7faa0c7d
...
@@ -2417,7 +2417,6 @@ class Test(ERP5TypeTestCase):
...
@@ -2417,7 +2417,6 @@ class Test(ERP5TypeTestCase):
self.commit()
self.commit()
from Products.ERP5Type.Core.InterfaceComponent import InterfaceComponent
from Products.ERP5Type.Core.InterfaceComponent import InterfaceComponent
class TestZodbInterfaceComponent(TestZodbDocumentComponent):
class TestZodbInterfaceComponent(TestZodbDocumentComponent):
"""
"""
Tests specific to ZODB Interface Component.
Tests specific to ZODB Interface Component.
...
@@ -2439,7 +2438,7 @@ class %s(Interface):
...
@@ -2439,7 +2438,7 @@ class %s(Interface):
''' % class_name
''' % class_name
def testNamingConsistency(self):
def testNamingConsistency(self):
valid_reference =
'
ITestNaming
'
valid_reference =
self._generateReference('
TestNaming
')
component = self._newComponent(valid_reference)
component = self._newComponent(valid_reference)
component.validate()
component.validate()
self.tic()
self.tic()
...
@@ -2468,7 +2467,7 @@ class %s(Interface):
...
@@ -2468,7 +2467,7 @@ class %s(Interface):
self.assertEqual(component.getValidationState(), '
modified
')
self.assertEqual(component.getValidationState(), '
modified
')
self.assertEqual([m.getMessage().translate()
self.assertEqual([m.getMessage().translate()
for m in component.checkConsistency()],
for m in component.checkConsistency()],
[
"Interface Reference must start with '
I
'"
])
[
self._document_class._message_reference_wrong_naming
])
self.assertEqual(component.getTextContentErrorMessageList(), [])
self.assertEqual(component.getTextContentErrorMessageList(), [])
self.assertEqual(component.getTextContentWarningMessageList(), [])
self.assertEqual(component.getTextContentWarningMessageList(), [])
self.assertEqual(component.getReference(), invalid_reference)
self.assertEqual(component.getReference(), invalid_reference)
...
@@ -2515,6 +2514,67 @@ class %s(Interface):
...
@@ -2515,6 +2514,67 @@ class %s(Interface):
person_type.setTypeInterfaceList(person_original_interface_type_list)
person_type.setTypeInterfaceList(person_original_interface_type_list)
self.commit()
self.commit()
from Products.ERP5Type.Core.MixinComponent import MixinComponent
class TestZodbMixinComponent(TestZodbInterfaceComponent):
"""
Tests specific to ZODB Mixin Component.
"""
_portal_type = '
Mixin
Component
'
_document_class = MixinComponent
def _generateReference(self, base_name):
return base_name + '
Mixin
'
def _getValidSourceCode(self, class_name):
return '''class %s:
def test42(self):
"""
Return 42
"""
''' % class_name
def testAssignToPortalTypeClass(self):
"""
Create a new Document Component inheriting from Person Document and try to
assign it to Person Portal Type, then create a new Person and check
whether it has been successfully added to its Portal Type class bases and
that the newly-defined function on ZODB Component can be called as well as
methods from Person Document
"""
import erp5.portal_type
person_type = self.portal.portal_types.Person
person_type_class = erp5.portal_type.Person
component = self._newComponent('
TestPortalTypeMixin
')
self.tic()
self.failIfModuleImportable('
TestPortalTypeMixin
')
self.assertFalse('
TestPortalTypeMixin
' in person_type.getMixinTypeList())
component.validate()
self.assertModuleImportable('
TestPortalTypeMixin
')
self.assertTrue('
TestPortalTypeMixin
' in person_type.getMixinTypeList())
from erp5.component.mixin.TestPortalTypeMixin import TestPortalTypeMixin
person_type_class.loadClass()
person_type_class_mro_list = person_type_class.__mro__
self.assertFalse(TestPortalTypeMixin in person_type_class_mro_list)
person_original_mixin_type_list = list(person_type.getTypeMixinList())
try:
person_type.setTypeMixinList(person_original_mixin_type_list +
['
TestPortalTypeMixin
'])
self.commit()
self.assertEqual(person_type_class.__isghost__, True)
person_type_class.loadClass()
person_type_class_mro_list = person_type_class.__mro__
from erp5.component.mixin.TestPortalTypeMixin import TestPortalTypeMixin
self.assertTrue(TestPortalTypeMixin in person_type_class_mro_list)
finally:
person_type.setTypeMixinList(person_original_mixin_type_list)
self.commit()
def test_suite():
def test_suite():
suite = unittest.TestSuite()
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPortalTypeClass))
suite.addTest(unittest.makeSuite(TestPortalTypeClass))
...
@@ -2522,4 +2582,6 @@ def test_suite():
...
@@ -2522,4 +2582,6 @@ def test_suite():
suite.addTest(unittest.makeSuite(TestZodbExtensionComponent))
suite.addTest(unittest.makeSuite(TestZodbExtensionComponent))
suite.addTest(unittest.makeSuite(TestZodbDocumentComponent))
suite.addTest(unittest.makeSuite(TestZodbDocumentComponent))
suite.addTest(unittest.makeSuite(TestZodbTestComponent))
suite.addTest(unittest.makeSuite(TestZodbTestComponent))
suite.addTest(unittest.makeSuite(TestZodbInterfaceComponent))
suite.addTest(unittest.makeSuite(TestZodbMixinComponent))
return suite
return suite
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment