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
Bryan Kaperick
erp5
Commits
6e45e47d
Commit
6e45e47d
authored
Jan 25, 2012
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test to check whether a Document Component is properly assigned to a Portal Type class.
parent
0876853b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
0 deletions
+77
-0
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+77
-0
No files found.
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
6e45e47d
...
@@ -1337,9 +1337,86 @@ class TestZodbExtensionComponent(_TestZodbComponent):
...
@@ -1337,9 +1337,86 @@ class TestZodbExtensionComponent(_TestZodbComponent):
else
:
else
:
raise
AssertionError
(
"TestExternalMethod should not be callable"
)
raise
AssertionError
(
"TestExternalMethod should not be callable"
)
from
Products.ERP5Type.Core.DocumentComponent
import
DocumentComponent
class
TestZodbDocumentComponent
(
_TestZodbComponent
):
def
_newComponent
(
self
,
reference
,
text_content
):
return
self
.
_component_tool
.
newContent
(
id
=
'%s.%s'
%
(
self
.
_getComponentModuleName
(),
reference
),
reference
=
reference
,
text_content
=
text_content
,
portal_type
=
'Document Component'
)
def
_getComponentModuleName
(
self
):
return
DocumentComponent
.
_getDynamicModuleNamespace
()
def
testAssignToPortalTypeClass
(
self
):
from
Products.ERP5.Document.Person
import
Person
as
PersonDocument
self
.
failIfHasAttribute
(
self
.
_module
,
'TestPortalType'
)
# 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_component
=
self
.
_newComponent
(
'TestPortalType'
,
"""
from Products.ERP5Type.Document.Person import Person
class TestPortalType(Person):
def test42(self):
return 42
"""
)
test_component
.
validate
()
transaction
.
commit
()
self
.
tic
()
# As TestPortalType Document Component has been validated, it should now
# be available
self
.
assertHasAttribute
(
self
.
_module
,
'TestPortalType'
)
person_type
=
self
.
_portal
.
portal_types
.
Person
person_type_class
=
person_type
.
getTypeClass
()
self
.
assertEquals
(
person_type_class
,
'Person'
)
# Create a new Person
person_module
=
self
.
_portal
.
person_module
person
=
person_module
.
newContent
(
id
=
'Foo Bar'
,
portal_type
=
'Person'
)
self
.
assertTrue
(
PersonDocument
in
person
.
__class__
.
mro
())
# There is no reason that TestPortalType Document Component has been
# assigned to a Person, otherwise there is something really bad going on
self
.
failIfHasAttribute
(
person
,
'test42'
)
self
.
assertFalse
(
self
.
_module
.
TestPortalType
in
person
.
__class__
.
mro
())
# Reset Portal Type classes to ghost to make sure that everything is reset
self
.
_component_tool
.
reset
()
# TestPortalType must be in available type class list
self
.
assertTrue
(
'TestPortalType'
in
person_type
.
getDocumentTypeList
())
try
:
person_type
.
setTypeClass
(
'TestPortalType'
)
transaction
.
commit
()
self
.
assertHasAttribute
(
person
,
'test42'
)
self
.
assertEquals
(
person
.
test42
(),
42
)
# The Portal Type class should not be in ghost state by now as we tried
# to access test42() defined in TestPortalType Document Component
self
.
assertHasAttribute
(
self
.
_module
,
'TestPortalType'
)
self
.
assertTrue
(
self
.
_module
.
TestPortalType
.
TestPortalType
in
person
.
__class__
.
mro
())
self
.
assertTrue
(
PersonDocument
in
person
.
__class__
.
mro
())
finally
:
person_type
.
setTypeClass
(
'Person'
)
transaction
.
commit
()
def
test_suite
():
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
(
TestZodbExtensionComponent
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestZodbExtensionComponent
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestZodbDocumentComponent
))
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