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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eugene Shen
erp5
Commits
0876853b
Commit
0876853b
authored
Jan 25, 2012
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Component generic tests to the parent abstract class.
parent
9a0f36ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
45 deletions
+53
-45
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+53
-45
No files found.
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
0876853b
...
@@ -1204,36 +1204,36 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
...
@@ -1204,36 +1204,36 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
self
.
fail
(
"Creating a Category Expression with syntax error raises "
\
self
.
fail
(
"Creating a Category Expression with syntax error raises "
\
"an error"
)
"an error"
)
import
abc
class
_TestZodbComponent
(
ERP5TypeTestCase
):
class
_TestZodbComponent
(
ERP5TypeTestCase
):
__metaclass__
=
abc
.
ABCMeta
def
getBusinessTemplateList
(
self
):
def
getBusinessTemplateList
(
self
):
return
(
'erp5_base'
,
return
(
'erp5_base'
,
'erp5_core_component'
)
'erp5_core_component'
)
class
TestZodbExtensionComponent
(
_TestZodbComponent
):
def
_newExtension
(
self
,
component_tool
,
extension_name
,
text_content
):
return
component_tool
.
newContent
(
id
=
'erp5.component.extension.%s'
%
extension_name
,
reference
=
extension_name
,
text_content
=
text_content
,
portal_type
=
'Extension Component'
)
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
"""
Create a new Extension component
"""
self
.
_portal
=
self
.
getPortal
()
self
.
_portal
=
self
.
getPortal
()
self
.
_component_tool
=
self
.
_portal
.
portal_components
self
.
_component_tool
=
self
.
_portal
.
portal_components
self
.
_module
=
__import__
(
self
.
_getComponentModuleName
(),
fromlist
=
[
'erp5.component'
])
self
.
_component_tool
.
reset
()
self
.
_component_tool
.
reset
()
@
abc
.
abstractmethod
def
_newComponent
(
self
,
reference
,
text_content
):
pass
@
abc
.
abstractmethod
def
_getComponentModuleName
(
self
):
pass
def
testValidateInvalidate
(
self
):
def
testValidateInvalidate
(
self
):
"""
"""
The new
Extension Component should only be in erp5.component.extension
The new
Component should only be in erp5.component.XXX when validated,
when validated,
otherwise an AttributeError should be raised
otherwise an AttributeError should be raised
"""
"""
import
erp5.component.extension
test_component
=
self
.
_newComponent
(
test_component
=
self
.
_newExtension
(
self
.
_component_tool
,
'TestValidateInvalidateComponent'
,
'TestValidateInvalidateComponent'
,
'def foobar(*args, **kwargs):
\
n
return "ValidateInvalidate"'
)
'def foobar(*args, **kwargs):
\
n
return "ValidateInvalidate"'
)
...
@@ -1241,23 +1241,53 @@ class TestZodbExtensionComponent(_TestZodbComponent):
...
@@ -1241,23 +1241,53 @@ class TestZodbExtensionComponent(_TestZodbComponent):
transaction
.
commit
()
transaction
.
commit
()
self
.
tic
()
self
.
tic
()
self
.
assertHasAttribute
(
erp5
.
component
.
extension
,
self
.
assertHasAttribute
(
self
.
_module
,
'TestValidateInvalidateComponent'
)
'TestValidateInvalidateComponent'
)
test_component
.
invalidate
()
test_component
.
invalidate
()
transaction
.
commit
()
transaction
.
commit
()
self
.
tic
()
self
.
tic
()
self
.
failIfHasAttribute
(
erp5
.
component
.
extension
,
self
.
failIfHasAttribute
(
self
.
_module
,
'TestValidateInvalidateComponent'
)
'TestValidateInvalidateComponent'
)
test_component
.
validate
()
test_component
.
validate
()
transaction
.
commit
()
transaction
.
commit
()
self
.
tic
()
self
.
tic
()
self
.
assertHasAttribute
(
erp5
.
component
.
extension
,
self
.
assertHasAttribute
(
self
.
_module
,
'TestValidateInvalidateComponent'
)
'TestValidateInvalidateComponent'
)
def
testSourceCodeWithSyntaxError
(
self
):
test_component
=
self
.
_newComponent
(
'TestComponentWithSyntaxError'
,
'def foobar(*args, **kwargs):
\
n
return 42'
)
self
.
assertEqual
(
test_component
.
checkConsistency
(),
[])
test_component
.
validate
()
transaction
.
commit
()
self
.
tic
()
self
.
assertHasAttribute
(
self
.
_module
,
'TestComponentWithSyntaxError'
)
test_component
.
setTextContent
(
'def foobar(*args, **kwargs)
\
n
return 42'
)
transaction
.
commit
()
self
.
tic
()
self
.
assertNotEqual
(
test_component
.
checkConsistency
(),
[])
from
Products.ERP5Type.Core.ExtensionComponent
import
ExtensionComponent
class
TestZodbExtensionComponent
(
_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
=
'Extension Component'
)
def
_getComponentModuleName
(
self
):
return
ExtensionComponent
.
_getDynamicModuleNamespace
()
def
testExternalMethod
(
self
):
def
testExternalMethod
(
self
):
test_component
=
self
.
_newExtension
(
test_component
=
self
.
_newComponent
(
self
.
_component_tool
,
'TestExternalMethodComponent'
,
'TestExternalMethodComponent'
,
'def foobar(*args, **kwargs):
\
n
return 42'
)
'def foobar(*args, **kwargs):
\
n
return 42'
)
...
@@ -1265,8 +1295,7 @@ class TestZodbExtensionComponent(_TestZodbComponent):
...
@@ -1265,8 +1295,7 @@ class TestZodbExtensionComponent(_TestZodbComponent):
transaction
.
commit
()
transaction
.
commit
()
self
.
tic
()
self
.
tic
()
import
erp5.component.extension
self
.
assertHasAttribute
(
self
.
_module
,
self
.
assertHasAttribute
(
erp5
.
component
.
extension
,
'TestExternalMethodComponent'
)
'TestExternalMethodComponent'
)
# Add an External Method using the Extension Component defined above and
# Add an External Method using the Extension Component defined above and
...
@@ -1308,27 +1337,6 @@ class TestZodbExtensionComponent(_TestZodbComponent):
...
@@ -1308,27 +1337,6 @@ class TestZodbExtensionComponent(_TestZodbComponent):
else
:
else
:
raise
AssertionError
(
"TestExternalMethod should not be callable"
)
raise
AssertionError
(
"TestExternalMethod should not be callable"
)
def
testSourceCodeWithSyntaxError
(
self
):
import
erp5.component.extension
test_component
=
self
.
_newExtension
(
self
.
_component_tool
,
'TestComponentWithSyntaxError'
,
'def foobar(*args, **kwargs):
\
n
return 42'
)
self
.
assertEqual
(
test_component
.
checkConsistency
(),
[])
test_component
.
validate
()
transaction
.
commit
()
self
.
tic
()
self
.
assertHasAttribute
(
erp5
.
component
.
extension
,
'TestComponentWithSyntaxError'
)
test_component
.
setTextContent
(
'def foobar(*args, **kwargs)
\
n
return 42'
)
transaction
.
commit
()
self
.
tic
()
self
.
assertNotEqual
(
test_component
.
checkConsistency
(),
[])
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestPortalTypeClass
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestPortalTypeClass
))
...
...
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