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
Paul Graydon
erp5
Commits
ec1a895c
Commit
ec1a895c
authored
Jun 29, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: replace most 'self.Portal()' by 'self.portal' in ERP5Type
parent
cf7e940c
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
102 additions
and
132 deletions
+102
-132
product/ERP5Type/tests/CodingStyleTestCase.py
product/ERP5Type/tests/CodingStyleTestCase.py
+1
-1
product/ERP5Type/tests/ERP5TypeTestCase.py
product/ERP5Type/tests/ERP5TypeTestCase.py
+26
-27
product/ERP5Type/tests/SecurityTestCase.py
product/ERP5Type/tests/SecurityTestCase.py
+1
-1
product/ERP5Type/tests/namingConventionTest.py
product/ERP5Type/tests/namingConventionTest.py
+1
-1
product/ERP5Type/tests/testCacheTool.py
product/ERP5Type/tests/testCacheTool.py
+13
-20
product/ERP5Type/tests/testCachedSkinsTool.py
product/ERP5Type/tests/testCachedSkinsTool.py
+3
-3
product/ERP5Type/tests/testConstraint.py
product/ERP5Type/tests/testConstraint.py
+5
-8
product/ERP5Type/tests/testDynamicClassGeneration.py
product/ERP5Type/tests/testDynamicClassGeneration.py
+15
-15
product/ERP5Type/tests/testERP5Type.py
product/ERP5Type/tests/testERP5Type.py
+10
-28
product/ERP5Type/tests/testFolder.py
product/ERP5Type/tests/testFolder.py
+3
-3
product/ERP5Type/tests/testFolderMigration.py
product/ERP5Type/tests/testFolderMigration.py
+2
-2
product/ERP5Type/tests/testLocalizer.py
product/ERP5Type/tests/testLocalizer.py
+1
-1
product/ERP5Type/tests/testMemcachedTool.py
product/ERP5Type/tests/testMemcachedTool.py
+6
-6
product/ERP5Type/tests/testPerformance.py
product/ERP5Type/tests/testPerformance.py
+4
-4
product/ERP5Type/tests/testSessionTool.py
product/ERP5Type/tests/testSessionTool.py
+8
-8
product/ERP5Type/tests/testTransactionalVariable.py
product/ERP5Type/tests/testTransactionalVariable.py
+1
-1
product/ERP5Type/tests/testXMLMatrix.py
product/ERP5Type/tests/testXMLMatrix.py
+2
-3
No files found.
product/ERP5Type/tests/CodingStyleTestCase.py
View file @
ec1a895c
...
@@ -74,7 +74,7 @@ class CodingStyleTestCase(ERP5TypeTestCase):
...
@@ -74,7 +74,7 @@ class CodingStyleTestCase(ERP5TypeTestCase):
and gather all consistency messages.
and gather all consistency messages.
"""
"""
# Find the list if skins to test - we only test the last business template
# Find the list if skins to test - we only test the last business template
portal_templates
=
self
.
getPortal
()
.
portal_templates
portal_templates
=
self
.
portal
.
portal_templates
skin_id_list
=
[]
skin_id_list
=
[]
for
business_template
in
portal_templates
.
contentValues
():
for
business_template
in
portal_templates
.
contentValues
():
if
business_template
.
getTitle
()
in
self
.
getTestedBusinessTemplateList
():
if
business_template
.
getTitle
()
in
self
.
getTestedBusinessTemplateList
():
...
...
product/ERP5Type/tests/ERP5TypeTestCase.py
View file @
ec1a895c
...
@@ -56,7 +56,6 @@ from zope.site.hooks import setSite
...
@@ -56,7 +56,6 @@ from zope.site.hooks import setSite
from
Testing
import
ZopeTestCase
from
Testing
import
ZopeTestCase
from
Testing.ZopeTestCase
import
PortalTestCase
,
user_name
from
Testing.ZopeTestCase
import
PortalTestCase
,
user_name
from
Products.CMFCore.utils
import
getToolByName
from
Products.DCWorkflow.DCWorkflow
import
ValidationFailed
from
Products.DCWorkflow.DCWorkflow
import
ValidationFailed
from
Products.PythonScripts.PythonScript
import
PythonScript
from
Products.PythonScripts.PythonScript
import
PythonScript
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
ConstantGetter
from
Products.ERP5Type.Accessor.Constant
import
PropertyGetter
as
ConstantGetter
...
@@ -235,7 +234,7 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
...
@@ -235,7 +234,7 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
try
:
try
:
PortalTestCase
.
login
(
self
,
user_name
)
PortalTestCase
.
login
(
self
,
user_name
)
except
AttributeError
:
except
AttributeError
:
uf
=
self
.
getPortal
()
.
acl_users
uf
=
self
.
portal
.
acl_users
uf
.
_doAddUser
(
'ERP5TypeTestCase'
,
''
,
[
'Manager'
,
'Member'
,
'Assignee'
,
uf
.
_doAddUser
(
'ERP5TypeTestCase'
,
''
,
[
'Manager'
,
'Member'
,
'Assignee'
,
'Assignor'
,
'Author'
,
'Auditor'
,
'Associate'
],
[])
'Assignor'
,
'Author'
,
'Auditor'
,
'Associate'
],
[])
return
PortalTestCase
.
login
(
self
,
user_name
)
return
PortalTestCase
.
login
(
self
,
user_name
)
...
@@ -245,7 +244,7 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
...
@@ -245,7 +244,7 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
Change current Skin
Change current Skin
"""
"""
request
=
self
.
app
.
REQUEST
request
=
self
.
app
.
REQUEST
self
.
getPortal
()
.
portal_skins
.
changeSkin
(
skin_name
)
self
.
portal
.
portal_skins
.
changeSkin
(
skin_name
)
request
.
set
(
'portal_skin'
,
skin_name
)
request
.
set
(
'portal_skin'
,
skin_name
)
def
logout
(
self
):
def
logout
(
self
):
...
@@ -298,71 +297,71 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
...
@@ -298,71 +297,71 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
# Utility methods specific to ERP5Type
# Utility methods specific to ERP5Type
def
getTemplateTool
(
self
):
def
getTemplateTool
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_templates'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_templates'
,
None
)
def
getPreferenceTool
(
self
)
:
def
getPreferenceTool
(
self
)
:
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_preferences'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_preferences'
,
None
)
def
getTrashTool
(
self
):
def
getTrashTool
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_trash'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_trash'
,
None
)
def
getPasswordTool
(
self
):
def
getPasswordTool
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_password'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_password'
,
None
)
def
getSkinsTool
(
self
):
def
getSkinsTool
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_skins'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_skins'
,
None
)
def
getCategoryTool
(
self
):
def
getCategoryTool
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_categories'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_categories'
,
None
)
def
getWorkflowTool
(
self
):
def
getWorkflowTool
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_workflow'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_workflow'
,
None
)
def
getCatalogTool
(
self
):
def
getCatalogTool
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_catalog'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_catalog'
,
None
)
def
getTypesTool
(
self
):
def
getTypesTool
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_types'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_types'
,
None
)
getTypeTool
=
getTypesTool
getTypeTool
=
getTypesTool
def
getRuleTool
(
self
):
def
getRuleTool
(
self
):
return
getattr
(
self
.
getPortal
()
,
'portal_rules'
,
None
)
return
getattr
(
self
.
portal
,
'portal_rules'
,
None
)
def
getSimulationTool
(
self
):
def
getSimulationTool
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_simulation'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_simulation'
,
None
)
def
getSQLConnection
(
self
):
def
getSQLConnection
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'erp5_sql_connection'
,
None
)
return
get
attr
(
self
.
portal
,
'erp5_sql_connection'
,
None
)
def
getPortalId
(
self
):
def
getPortalId
(
self
):
return
self
.
getPortal
()
.
getId
()
return
self
.
portal
.
getId
()
def
getDomainTool
(
self
):
def
getDomainTool
(
self
):
return
get
ToolByName
(
self
.
getPortal
()
,
'portal_domains'
,
None
)
return
get
attr
(
self
.
portal
,
'portal_domains'
,
None
)
def
getAlarmTool
(
self
):
def
getAlarmTool
(
self
):
return
getattr
(
self
.
getPortal
()
,
'portal_alarms'
,
None
)
return
getattr
(
self
.
portal
,
'portal_alarms'
,
None
)
def
getActivityTool
(
self
):
def
getActivityTool
(
self
):
return
getattr
(
self
.
getPortal
()
,
'portal_activities'
,
None
)
return
getattr
(
self
.
portal
,
'portal_activities'
,
None
)
def
getArchiveTool
(
self
):
def
getArchiveTool
(
self
):
return
getattr
(
self
.
getPortal
()
,
'portal_archives'
,
None
)
return
getattr
(
self
.
portal
,
'portal_archives'
,
None
)
def
getCacheTool
(
self
):
def
getCacheTool
(
self
):
return
getattr
(
self
.
getPortal
()
,
'portal_caches'
,
None
)
return
getattr
(
self
.
portal
,
'portal_caches'
,
None
)
def
getOrganisationModule
(
self
):
def
getOrganisationModule
(
self
):
return
getattr
(
self
.
getPortal
()
,
'organisation_module'
,
return
getattr
(
self
.
portal
,
'organisation_module'
,
getattr
(
self
.
getPortal
()
,
'organisation'
,
None
))
getattr
(
self
.
portal
,
'organisation'
,
None
))
def
getPersonModule
(
self
):
def
getPersonModule
(
self
):
return
getattr
(
self
.
getPortal
()
,
'person_module'
,
return
getattr
(
self
.
portal
,
'person_module'
,
getattr
(
self
.
getPortal
()
,
'person'
,
None
))
getattr
(
self
.
portal
,
'person'
,
None
))
def
getCurrencyModule
(
self
):
def
getCurrencyModule
(
self
):
return
getattr
(
self
.
getPortal
()
,
'currency_module'
,
return
getattr
(
self
.
portal
,
'currency_module'
,
getattr
(
self
.
getPortal
()
,
'currency'
,
None
))
getattr
(
self
.
portal
,
'currency'
,
None
))
def
_addPropertySheet
(
self
,
portal_type_name
,
def
_addPropertySheet
(
self
,
portal_type_name
,
property_sheet_name
=
'TestPropertySheet'
,
property_sheet_name
=
'TestPropertySheet'
,
...
...
product/ERP5Type/tests/SecurityTestCase.py
View file @
ec1a895c
...
@@ -134,7 +134,7 @@ class SecurityTestCase(ERP5TypeTestCase):
...
@@ -134,7 +134,7 @@ class SecurityTestCase(ERP5TypeTestCase):
if
username
is
None
:
if
username
is
None
:
newSecurityManager
(
None
,
SpecialUsers
.
nobody
)
newSecurityManager
(
None
,
SpecialUsers
.
nobody
)
else
:
else
:
uf
=
self
.
getPortal
()
.
acl_users
uf
=
self
.
portal
.
acl_users
user
=
uf
.
getUserById
(
username
)
user
=
uf
.
getUserById
(
username
)
self
.
assertNotEquals
(
user
,
None
,
'No user %s'
%
username
)
self
.
assertNotEquals
(
user
,
None
,
'No user %s'
%
username
)
newSecurityManager
(
None
,
user
.
__of__
(
uf
))
newSecurityManager
(
None
,
user
.
__of__
(
uf
))
...
...
product/ERP5Type/tests/namingConventionTest.py
View file @
ec1a895c
...
@@ -68,7 +68,7 @@ class TestNamingConvention(ERP5TypeTestCase):
...
@@ -68,7 +68,7 @@ class TestNamingConvention(ERP5TypeTestCase):
def
testNamingConvention
(
self
):
def
testNamingConvention
(
self
):
result
=
'installed templates: %s
\
n
'
%
repr
(
self
.
getBusinessTemplateList
())
result
=
'installed templates: %s
\
n
'
%
repr
(
self
.
getBusinessTemplateList
())
result
+=
self
.
getPortal
()
.
portal_skins
.
erp5_core
.
ERP5Site_checkNamingConventions
(
html_output
=
None
)
result
+=
self
.
portal
.
portal_skins
.
erp5_core
.
ERP5Site_checkNamingConventions
(
html_output
=
None
)
problems_re
=
re
.
compile
(
'([0-9]+) problems found'
)
problems_re
=
re
.
compile
(
'([0-9]+) problems found'
)
problems
=
int
(
problems_re
.
search
(
result
).
group
(
1
))
problems
=
int
(
problems_re
.
search
(
result
).
group
(
1
))
self
.
assertEqual
(
0
,
problems
,
result
)
self
.
assertEqual
(
0
,
problems
,
result
)
...
...
product/ERP5Type/tests/testCacheTool.py
View file @
ec1a895c
...
@@ -72,19 +72,17 @@ class TestCacheTool(ERP5TypeTestCase):
...
@@ -72,19 +72,17 @@ class TestCacheTool(ERP5TypeTestCase):
self
.
commit
()
self
.
commit
()
def
login
(
self
):
def
login
(
self
):
uf
=
self
.
getPortal
()
.
acl_users
uf
=
self
.
portal
.
acl_users
uf
.
_doAddUser
(
'admin'
,
''
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'admin'
,
''
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'ERP5TypeTestCase'
,
''
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'ERP5TypeTestCase'
,
''
,
[
'Manager'
],
[])
user
=
uf
.
getUserById
(
'admin'
).
__of__
(
uf
)
user
=
uf
.
getUserById
(
'admin'
).
__of__
(
uf
)
newSecurityManager
(
None
,
user
)
newSecurityManager
(
None
,
user
)
def
checkCacheTool
(
self
):
def
checkCacheTool
(
self
):
portal
=
self
.
getPortal
()
self
.
assertIsNot
(
None
,
self
.
portal
.
portal_caches
)
self
.
assertNotEqual
(
None
,
getattr
(
portal
,
'portal_caches'
,
None
))
def
checkPortalTypes
(
self
):
def
checkPortalTypes
(
self
):
portal
=
self
.
getPortal
()
portal_types
=
self
.
portal
.
portal_types
portal_types
=
portal
.
portal_types
typeinfo_names
=
(
"Cache Factory"
,
typeinfo_names
=
(
"Cache Factory"
,
"Ram Cache"
,
"Ram Cache"
,
"Distributed Ram Cache"
,
"Distributed Ram Cache"
,
...
@@ -108,8 +106,7 @@ class TestCacheTool(ERP5TypeTestCase):
...
@@ -108,8 +106,7 @@ class TestCacheTool(ERP5TypeTestCase):
priority
=
1
)
priority
=
1
)
def
createCacheFactories
(
self
):
def
createCacheFactories
(
self
):
portal
=
self
.
getPortal
()
portal_caches
=
self
.
portal
.
portal_caches
portal_caches
=
portal
.
portal_caches
# Cache plugins are organised into 'Cache factories' so we create
# Cache plugins are organised into 'Cache factories' so we create
# factories first ram_cache_factory (to test Ram Cache Plugin)
# factories first ram_cache_factory (to test Ram Cache Plugin)
...
@@ -175,7 +172,7 @@ class TestCacheTool(ERP5TypeTestCase):
...
@@ -175,7 +172,7 @@ class TestCacheTool(ERP5TypeTestCase):
self
.
assertTrue
(
'erp5_user_factory'
in
CachingMethod
.
factories
)
self
.
assertTrue
(
'erp5_user_factory'
in
CachingMethod
.
factories
)
def
createCachedMethod
(
self
):
def
createCachedMethod
(
self
):
portal
=
self
.
getPortal
()
portal
=
self
.
portal
if
getattr
(
portal
,
self
.
python_script_id
,
None
)
is
not
None
:
if
getattr
(
portal
,
self
.
python_script_id
,
None
)
is
not
None
:
portal
.
manage_delObjects
(
ids
=
[
self
.
python_script_id
])
portal
.
manage_delObjects
(
ids
=
[
self
.
python_script_id
])
## add test cached method
## add test cached method
...
@@ -194,7 +191,7 @@ return result
...
@@ -194,7 +191,7 @@ return result
def
test_01_CacheFactoryOnePlugin
(
self
):
def
test_01_CacheFactoryOnePlugin
(
self
):
""" Test cache factory containing only one cache plugin. """
""" Test cache factory containing only one cache plugin. """
portal
=
self
.
getPortal
()
portal
=
self
.
portal
py_script_obj
=
getattr
(
portal
,
self
.
python_script_id
)
py_script_obj
=
getattr
(
portal
,
self
.
python_script_id
)
for
cf_name
,
clear_allowed
in
((
'ram_cache_factory'
,
True
),
for
cf_name
,
clear_allowed
in
((
'ram_cache_factory'
,
True
),
(
'distributed_ram_cache_factory'
,
False
),
(
'distributed_ram_cache_factory'
,
False
),
...
@@ -207,8 +204,7 @@ return result
...
@@ -207,8 +204,7 @@ return result
def
test_02_CacheFactoryMultiPlugins
(
self
):
def
test_02_CacheFactoryMultiPlugins
(
self
):
""" Test a cache factory containing multiple cache plugins. """
""" Test a cache factory containing multiple cache plugins. """
portal
=
self
.
getPortal
()
py_script_obj
=
getattr
(
self
.
portal
,
self
.
python_script_id
)
py_script_obj
=
getattr
(
portal
,
self
.
python_script_id
)
cf_name
=
'erp5_user_factory'
cf_name
=
'erp5_user_factory'
my_cache
=
CachingMethod
(
py_script_obj
,
my_cache
=
CachingMethod
(
py_script_obj
,
'py_script_obj'
,
'py_script_obj'
,
...
@@ -217,15 +213,13 @@ return result
...
@@ -217,15 +213,13 @@ return result
def
_getCacheCookieValue
(
self
):
def
_getCacheCookieValue
(
self
):
portal
=
self
.
getPortal
()
return
self
.
portal
.
getCacheCookie
(
'cache_tool_test'
)
return
portal
.
getCacheCookie
(
'cache_tool_test'
)
def
_callCache
(
self
,
my_cache
,
real_calculation
=
False
,
result
=
""
):
def
_callCache
(
self
,
my_cache
,
real_calculation
=
False
,
result
=
""
):
portal
=
self
.
getPortal
()
before_cookie_value
=
self
.
_getCacheCookieValue
()
before_cookie_value
=
self
.
_getCacheCookieValue
()
start
=
time
.
time
()
start
=
time
.
time
()
cached
=
my_cache
(
self
.
nb_iterations
,
cached
=
my_cache
(
self
.
nb_iterations
,
portal_path
=
(
''
,
portal
.
getId
()),
portal_path
=
(
''
,
self
.
portal
.
getId
()),
result
=
result
)
result
=
result
)
end
=
time
.
time
()
end
=
time
.
time
()
calculation_time
=
end
-
start
calculation_time
=
end
-
start
...
@@ -238,7 +232,7 @@ return result
...
@@ -238,7 +232,7 @@ return result
return
calculation_time
return
calculation_time
def
_cacheFactoryInstanceTest
(
self
,
my_cache
,
cf_name
,
clear_allowed
):
def
_cacheFactoryInstanceTest
(
self
,
my_cache
,
cf_name
,
clear_allowed
):
portal
=
self
.
getPortal
()
portal
=
self
.
portal
print
print
print
"="
*
40
print
"="
*
40
print
"TESTING:"
,
cf_name
print
"TESTING:"
,
cf_name
...
@@ -311,7 +305,7 @@ return result
...
@@ -311,7 +305,7 @@ return result
print
print
print
"="
*
40
print
"="
*
40
print
"TESTING: Concurrent RamCache"
print
"TESTING: Concurrent RamCache"
portal
=
self
.
getPortal
()
portal
=
self
.
portal
result
=
'Something short'
result
=
'Something short'
py_script_obj
=
getattr
(
portal
,
self
.
python_script_id
)
py_script_obj
=
getattr
(
portal
,
self
.
python_script_id
)
...
@@ -366,7 +360,7 @@ return result
...
@@ -366,7 +360,7 @@ return result
print
print
print
'='
*
40
print
'='
*
40
print
'TESTING: Long Keys and Large values'
print
'TESTING: Long Keys and Large values'
portal
=
self
.
getPortal
()
portal
=
self
.
portal
# import the local and clear it
# import the local and clear it
from
Products.ERP5Type.CachePlugins.DistributedRamCache
import
\
from
Products.ERP5Type.CachePlugins.DistributedRamCache
import
\
connection_pool
connection_pool
...
@@ -446,9 +440,8 @@ return 'a' * 1024 * 1024 * 25
...
@@ -446,9 +440,8 @@ return 'a' * 1024 * 1024 * 25
print
print
print
"="
*
40
print
"="
*
40
print
"TESTING: Cache Expiration Time"
print
"TESTING: Cache Expiration Time"
portal
=
self
.
getPortal
()
py_script_obj
=
getattr
(
portal
,
self
.
python_script_id
)
py_script_obj
=
getattr
(
self
.
portal
,
self
.
python_script_id
)
cache_factory_list
=
(
'ram_cache_factory'
,
'distributed_ram_cache_factory'
,
cache_factory_list
=
(
'ram_cache_factory'
,
'distributed_ram_cache_factory'
,
'distributed_persistent_cache_factory'
)
'distributed_persistent_cache_factory'
)
...
...
product/ERP5Type/tests/testCachedSkinsTool.py
View file @
ec1a895c
...
@@ -58,7 +58,7 @@ class TestCachedSkinsTool(ERP5TypeTestCase):
...
@@ -58,7 +58,7 @@ class TestCachedSkinsTool(ERP5TypeTestCase):
self
.
getSkinnableObject
().
changeSkin
(
skinname
=
None
)
self
.
getSkinnableObject
().
changeSkin
(
skinname
=
None
)
def
login
(
self
):
def
login
(
self
):
uf
=
self
.
getPortal
()
.
acl_users
uf
=
self
.
portal
.
acl_users
uf
.
_doAddUser
(
'vincent'
,
''
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'vincent'
,
''
,
[
'Manager'
],
[])
user
=
uf
.
getUserById
(
'vincent'
).
__of__
(
uf
)
user
=
uf
.
getUserById
(
'vincent'
).
__of__
(
uf
)
newSecurityManager
(
None
,
user
)
newSecurityManager
(
None
,
user
)
...
@@ -67,13 +67,13 @@ class TestCachedSkinsTool(ERP5TypeTestCase):
...
@@ -67,13 +67,13 @@ class TestCachedSkinsTool(ERP5TypeTestCase):
"""
"""
Return the skinnable object (access to SkinsTool through cache).
Return the skinnable object (access to SkinsTool through cache).
"""
"""
return
self
.
getPortal
()
return
self
.
portal
def
getSkinsTool
(
self
):
def
getSkinsTool
(
self
):
"""
"""
Return the SkinsTool (access to SkinsSool without cache).
Return the SkinsTool (access to SkinsSool without cache).
"""
"""
return
self
.
getPortal
()
.
portal_skins
return
self
.
portal
.
portal_skins
def
getTestedSkinFolder
(
self
):
def
getTestedSkinFolder
(
self
):
"""
"""
...
...
product/ERP5Type/tests/testConstraint.py
View file @
ec1a895c
...
@@ -50,20 +50,19 @@ class TestConstraint(PropertySheetTestCase):
...
@@ -50,20 +50,19 @@ class TestConstraint(PropertySheetTestCase):
return
(
'erp5_base'
,)
return
(
'erp5_base'
,)
def
login
(
self
):
def
login
(
self
):
uf
=
self
.
getPortal
()
.
acl_users
uf
=
self
.
portal
.
acl_users
uf
.
_doAddUser
(
'rc'
,
''
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'rc'
,
''
,
[
'Manager'
],
[])
user
=
uf
.
getUserById
(
'rc'
).
__of__
(
uf
)
user
=
uf
.
getUserById
(
'rc'
).
__of__
(
uf
)
newSecurityManager
(
None
,
user
)
newSecurityManager
(
None
,
user
)
def
stepLoginAsAssignee
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepLoginAsAssignee
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
uf
=
self
.
getPortal
()
.
acl_users
uf
=
self
.
portal
.
acl_users
uf
.
_doAddUser
(
'member'
,
''
,
[
'Member'
,
'Assignee'
],
[])
uf
.
_doAddUser
(
'member'
,
''
,
[
'Member'
,
'Assignee'
],
[])
user
=
uf
.
getUserById
(
'member'
).
__of__
(
uf
)
user
=
uf
.
getUserById
(
'member'
).
__of__
(
uf
)
newSecurityManager
(
None
,
user
)
newSecurityManager
(
None
,
user
)
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
self
.
login
()
self
.
login
()
self
.
portal
=
self
.
getPortal
()
self
.
category_tool
=
self
.
getCategoryTool
()
self
.
category_tool
=
self
.
getCategoryTool
()
self
.
createCategories
()
self
.
createCategories
()
portal_property_sheets
=
self
.
portal
.
portal_property_sheets
portal_property_sheets
=
self
.
portal
.
portal_property_sheets
...
@@ -99,8 +98,7 @@ class TestConstraint(PropertySheetTestCase):
...
@@ -99,8 +98,7 @@ class TestConstraint(PropertySheetTestCase):
"""
"""
Delete all objects in the module.
Delete all objects in the module.
"""
"""
portal
=
self
.
getPortal
()
module
=
self
.
portal
.
getDefaultModule
(
self
.
object_portal_type
)
module
=
portal
.
getDefaultModule
(
self
.
object_portal_type
)
module
.
manage_delObjects
(
module
.
contentIds
())
module
.
manage_delObjects
(
module
.
contentIds
())
def
_makeOne
(
self
):
def
_makeOne
(
self
):
...
@@ -115,8 +113,7 @@ class TestConstraint(PropertySheetTestCase):
...
@@ -115,8 +113,7 @@ class TestConstraint(PropertySheetTestCase):
"""
"""
Create a object which will be tested.
Create a object which will be tested.
"""
"""
portal
=
self
.
getPortal
()
module
=
self
.
portal
.
getDefaultModule
(
self
.
object_portal_type
)
module
=
portal
.
getDefaultModule
(
self
.
object_portal_type
)
object
=
module
.
newContent
(
portal_type
=
self
.
object_portal_type
)
object
=
module
.
newContent
(
portal_type
=
self
.
object_portal_type
)
group1
=
object
.
portal_categories
.
restrictedTraverse
(
'group/testGroup1'
)
group1
=
object
.
portal_categories
.
restrictedTraverse
(
'group/testGroup1'
)
if
sequence
:
if
sequence
:
...
@@ -1292,7 +1289,7 @@ class TestConstraint(PropertySheetTestCase):
...
@@ -1292,7 +1289,7 @@ class TestConstraint(PropertySheetTestCase):
"""Tests PropertyTypeValidity can repairs categories when this property
"""Tests PropertyTypeValidity can repairs categories when this property
is added on the class later.
is added on the class later.
"""
"""
self
.
getPortal
()
.
portal_categories
.
newContent
(
self
.
portal
.
portal_categories
.
newContent
(
portal_type
=
'Base Category'
,
portal_type
=
'Base Category'
,
id
=
'testing_category'
)
id
=
'testing_category'
)
constraint
=
self
.
_createGenericConstraint
(
constraint
=
self
.
_createGenericConstraint
(
...
...
product/ERP5Type/tests/testDynamicClassGeneration.py
View file @
ec1a895c
...
@@ -137,7 +137,7 @@ class TestPortalTypeClass(ERP5TypeTestCase):
...
@@ -137,7 +137,7 @@ class TestPortalTypeClass(ERP5TypeTestCase):
Take an existing object, change the mixin definitions of its portal type.
Take an existing object, change the mixin definitions of its portal type.
Check that the new methods are there.
Check that the new methods are there.
"""
"""
portal
=
self
.
getPortal
()
portal
=
self
.
portal
person_module
=
portal
.
person_module
person_module
=
portal
.
person_module
person
=
person_module
.
newContent
(
id
=
'John Dough'
,
portal_type
=
'Person'
)
person
=
person_module
.
newContent
(
id
=
'John Dough'
,
portal_type
=
'Person'
)
...
@@ -162,7 +162,7 @@ class TestPortalTypeClass(ERP5TypeTestCase):
...
@@ -162,7 +162,7 @@ class TestPortalTypeClass(ERP5TypeTestCase):
Take an existing object, change its document class
Take an existing object, change its document class
Check that the new methods are there.
Check that the new methods are there.
"""
"""
portal
=
self
.
getPortal
()
portal
=
self
.
portal
person_module
=
portal
.
person_module
person_module
=
portal
.
person_module
person
=
person_module
.
newContent
(
id
=
'Eva Dough'
,
portal_type
=
'Person'
)
person
=
person_module
.
newContent
(
id
=
'Eva Dough'
,
portal_type
=
'Person'
)
...
@@ -355,7 +355,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
...
@@ -355,7 +355,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
be created, it's necessary that the category properties referenced
be created, it's necessary that the category properties referenced
in the web-based Property Sheet exist)
in the web-based Property Sheet exist)
"""
"""
new_base_category
=
self
.
getPortal
()
.
portal_categories
.
newContent
(
new_base_category
=
self
.
portal
.
portal_categories
.
newContent
(
id
=
base_category_id
,
portal_type
=
'Base Category'
)
id
=
base_category_id
,
portal_type
=
'Base Category'
)
# Create a dummy sub-category
# Create a dummy sub-category
...
@@ -366,7 +366,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
...
@@ -366,7 +366,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
portal_type
=
'Category'
)
portal_type
=
'Category'
)
if
operation_type
==
'change'
:
if
operation_type
==
'change'
:
self
.
getPortal
()
.
portal_categories
.
newContent
(
self
.
portal
.
portal_categories
.
newContent
(
id
=
base_category_id
+
'_renamed'
,
id
=
base_category_id
+
'_renamed'
,
portal_type
=
'Base Category'
)
portal_type
=
'Base Category'
)
...
@@ -457,7 +457,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
...
@@ -457,7 +457,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
Create a new Category Membership Arity Constraint within test
Create a new Category Membership Arity Constraint within test
Property Sheet (with or without acquisition)
Property Sheet (with or without acquisition)
"""
"""
self
.
getPortal
()
.
portal_categories
.
newContent
(
self
.
portal
.
portal_categories
.
newContent
(
id
=
reference
,
portal_type
=
'Base Category'
)
id
=
reference
,
portal_type
=
'Base Category'
)
self
.
test_property_sheet
.
newContent
(
self
.
test_property_sheet
.
newContent
(
...
@@ -505,7 +505,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
...
@@ -505,7 +505,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
"""
"""
Create a test Property Sheet (and its properties)
Create a test Property Sheet (and its properties)
"""
"""
portal
=
self
.
getPortal
()
portal
=
self
.
portal
# Create the test Property Sheet
# Create the test Property Sheet
try
:
try
:
...
@@ -622,7 +622,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
...
@@ -622,7 +622,7 @@ class TestZodbPropertySheet(ERP5TypeTestCase):
"""
"""
import
erp5
import
erp5
portal
=
self
.
getPortal
()
portal
=
self
.
portal
person_type
=
portal
.
portal_types
.
Person
person_type
=
portal
.
portal_types
.
Person
self
.
assertFalse
(
'TestMigration'
in
person_type
.
getTypePropertySheetList
())
self
.
assertFalse
(
'TestMigration'
in
person_type
.
getTypePropertySheetList
())
...
@@ -1255,7 +1255,7 @@ class _TestZodbComponent(SecurityTestCase):
...
@@ -1255,7 +1255,7 @@ class _TestZodbComponent(SecurityTestCase):
return
(
'erp5_base'
,)
return
(
'erp5_base'
,)
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
self
.
_component_tool
=
self
.
getPortal
()
.
portal_components
self
.
_component_tool
=
self
.
portal
.
portal_components
self
.
_module
=
__import__
(
self
.
_getComponentModuleName
(),
self
.
_module
=
__import__
(
self
.
_getComponentModuleName
(),
fromlist
=
[
'erp5.component'
])
fromlist
=
[
'erp5.component'
])
self
.
_component_tool
.
reset
(
force
=
True
,
self
.
_component_tool
.
reset
(
force
=
True
,
...
@@ -1973,7 +1973,7 @@ class TestZodbExtensionComponent(_TestZodbComponent):
...
@@ -1973,7 +1973,7 @@ class TestZodbExtensionComponent(_TestZodbComponent):
# Add an External Method using the Extension Component defined above and
# Add an External Method using the Extension Component defined above and
# check that it returns 42
# check that it returns 42
from
Products.ExternalMethod.ExternalMethod
import
manage_addExternalMethod
from
Products.ExternalMethod.ExternalMethod
import
manage_addExternalMethod
manage_addExternalMethod
(
self
.
getPortal
()
,
manage_addExternalMethod
(
self
.
portal
,
'TestExternalMethod'
,
'TestExternalMethod'
,
'title'
,
'title'
,
'TestExternalMethodComponent'
,
'TestExternalMethodComponent'
,
...
@@ -1981,7 +1981,7 @@ class TestZodbExtensionComponent(_TestZodbComponent):
...
@@ -1981,7 +1981,7 @@ class TestZodbExtensionComponent(_TestZodbComponent):
self
.
tic
()
self
.
tic
()
external_method
=
self
.
getPortal
()
.
TestExternalMethod
external_method
=
self
.
portal
.
TestExternalMethod
self
.
assertEqual
(
external_method
(),
42
)
self
.
assertEqual
(
external_method
(),
42
)
# Check that the External Method returns expected result through Publisher
# Check that the External Method returns expected result through Publisher
...
@@ -2000,11 +2000,11 @@ class TestZodbExtensionComponent(_TestZodbComponent):
...
@@ -2000,11 +2000,11 @@ class TestZodbExtensionComponent(_TestZodbComponent):
# Add a Python Script with the External Method defined above and check
# Add a Python Script with the External Method defined above and check
# that it returns 42
# that it returns 42
from
Products.PythonScripts.PythonScript
import
manage_addPythonScript
from
Products.PythonScripts.PythonScript
import
manage_addPythonScript
manage_addPythonScript
(
self
.
getPortal
()
,
'TestPythonScript'
)
manage_addPythonScript
(
self
.
portal
,
'TestPythonScript'
)
self
.
getPortal
()
.
TestPythonScript
.
write
(
'return context.TestExternalMethod()'
)
self
.
portal
.
TestPythonScript
.
write
(
'return context.TestExternalMethod()'
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
self
.
getPortal
()
.
TestPythonScript
(),
42
)
self
.
assertEqual
(
self
.
portal
.
TestPythonScript
(),
42
)
# Invalidate the Extension Component and check that it's not callable
# Invalidate the Extension Component and check that it's not callable
# anymore
# anymore
...
@@ -2066,12 +2066,12 @@ class TestPortalType(Person):
...
@@ -2066,12 +2066,12 @@ class TestPortalType(Person):
# be available
# be available
self
.
assertModuleImportable
(
'TestPortalType'
)
self
.
assertModuleImportable
(
'TestPortalType'
)
person_type
=
self
.
getPortal
()
.
portal_types
.
Person
person_type
=
self
.
portal
.
portal_types
.
Person
person_type_class
=
person_type
.
getTypeClass
()
person_type_class
=
person_type
.
getTypeClass
()
self
.
assertEqual
(
person_type_class
,
'Person'
)
self
.
assertEqual
(
person_type_class
,
'Person'
)
# Create a new Person
# Create a new Person
person_module
=
self
.
getPortal
()
.
person_module
person_module
=
self
.
portal
.
person_module
person
=
person_module
.
newContent
(
id
=
'Foo Bar'
,
portal_type
=
'Person'
)
person
=
person_module
.
newContent
(
id
=
'Foo Bar'
,
portal_type
=
'Person'
)
self
.
assertTrue
(
PersonDocument
in
person
.
__class__
.
mro
())
self
.
assertTrue
(
PersonDocument
in
person
.
__class__
.
mro
())
...
...
product/ERP5Type/tests/testERP5Type.py
View file @
ec1a895c
...
@@ -160,24 +160,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -160,24 +160,6 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def
getRandomString
(
self
):
def
getRandomString
(
self
):
return
str
(
randint
(
-
10000000
,
100000000
))
return
str
(
randint
(
-
10000000
,
100000000
))
def
getTemplateTool
(
self
):
return
getattr
(
self
.
portal
,
'portal_templates'
,
None
)
def
getCategoryTool
(
self
):
return
getattr
(
self
.
portal
,
'portal_categories'
,
None
)
def
getTypeTool
(
self
):
return
getattr
(
self
.
portal
,
'portal_types'
,
None
)
# Here are the tests
def
testHasTemplateTool
(
self
):
# Test if portal_templates was created
self
.
assertNotEquals
(
self
.
getTemplateTool
(),
None
)
def
testHasCategoryTool
(
self
):
# Test if portal_categories was created
self
.
assertNotEquals
(
self
.
getCategoryTool
(),
None
)
def
testTemplateToolHasGetId
(
self
):
def
testTemplateToolHasGetId
(
self
):
# Test if portal_templates has getId method (RAD)
# Test if portal_templates has getId method (RAD)
self
.
assertEqual
(
self
.
getTemplateTool
().
getId
(),
'portal_templates'
)
self
.
assertEqual
(
self
.
getTemplateTool
().
getId
(),
'portal_templates'
)
...
@@ -363,7 +345,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -363,7 +345,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
of a region and should thus be accessible from the region
of a region and should thus be accessible from the region
category through getRegionRelated accessors
category through getRegionRelated accessors
"""
"""
region_category
=
self
.
getPortal
()
.
portal_categories
.
region
region_category
=
self
.
portal
.
portal_categories
.
region
category_title
=
"Solar System"
category_title
=
"Solar System"
category_id
=
"solar_system"
category_id
=
"solar_system"
...
@@ -527,7 +509,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -527,7 +509,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
.
manage_addPythonScript
(
id
=
method_id
)
.
manage_addPythonScript
(
id
=
method_id
)
script
=
custom_skin
[
method_id
]
script
=
custom_skin
[
method_id
]
script
.
ZPythonScript_edit
(
''
,
"context.setTitle('reseted')"
)
script
.
ZPythonScript_edit
(
''
,
"context.setTitle('reseted')"
)
self
.
getPortal
()
.
changeSkin
(
None
)
self
.
portal
.
changeSkin
(
None
)
# copy / pasted person have their title reseted
# copy / pasted person have their title reseted
folder
=
self
.
getPersonModule
()
folder
=
self
.
getPersonModule
()
...
@@ -627,7 +609,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -627,7 +609,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
portal_type
=
"Category"
,
portal_type
=
"Category"
,
id
=
"zeta"
,
id
=
"zeta"
,
title
=
"Zeta System"
,
)
title
=
"Zeta System"
,
)
function_category
=
self
.
getPortal
()
.
portal_categories
.
function
function_category
=
self
.
portal
.
portal_categories
.
function
nofunction
=
function_category
.
newContent
(
nofunction
=
function_category
.
newContent
(
portal_type
=
"Category"
,
portal_type
=
"Category"
,
id
=
"nofunction"
,
id
=
"nofunction"
,
...
@@ -1565,7 +1547,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -1565,7 +1547,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
float_index
=
2.0
)
float_index
=
2.0
)
addCustomAction
(
'action1'
,
'python: here.getDescription()=="foo"'
)
addCustomAction
(
'action1'
,
'python: here.getDescription()=="foo"'
)
obj
=
self
.
getOrganisationModule
().
newContent
(
portal_type
=
'Organisation'
)
obj
=
self
.
getOrganisationModule
().
newContent
(
portal_type
=
'Organisation'
)
action_tool
=
self
.
getPortal
()
.
portal_actions
action_tool
=
self
.
portal
.
portal_actions
actions
=
action_tool
.
listFilteredActionsFor
(
obj
)
actions
=
action_tool
.
listFilteredActionsFor
(
obj
)
action_id_list
=
[
x
[
'id'
]
for
x
in
actions
.
get
(
'object_action'
,[])]
action_id_list
=
[
x
[
'id'
]
for
x
in
actions
.
get
(
'object_action'
,[])]
self
.
assertTrue
(
'action1'
not
in
action_id_list
)
self
.
assertTrue
(
'action1'
not
in
action_id_list
)
...
@@ -1826,7 +1808,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -1826,7 +1808,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
"""
"""
portal
=
self
.
portal
portal
=
self
.
portal
# Clear out all generated methods.
# Clear out all generated methods.
self
.
portal
.
portal_types
.
resetDynamicDocuments
()
portal
.
portal_types
.
resetDynamicDocuments
()
# Create a new temporary person object.
# Create a new temporary person object.
from
Products.ERP5Type.Document
import
newTempPerson
from
Products.ERP5Type.Document
import
newTempPerson
...
@@ -2175,7 +2157,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -2175,7 +2157,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
# Category Accessors raises Unauthorized when you try to access objects
# Category Accessors raises Unauthorized when you try to access objects
# you cannot Access, unless you explictly pass checked_permission=
# you cannot Access, unless you explictly pass checked_permission=
region_category
=
self
.
getPortal
()
.
portal_categories
.
region
region_category
=
self
.
portal
.
portal_categories
.
region
beta_id
=
"beta"
beta_id
=
"beta"
beta_title
=
"Beta System"
beta_title
=
"Beta System"
beta
=
region_category
.
newContent
(
beta
=
region_category
.
newContent
(
...
@@ -2234,7 +2216,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -2234,7 +2216,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
# Acquired Accessors raises Unauthorized when you try to access objects
# Acquired Accessors raises Unauthorized when you try to access objects
# you cannot Access, unless you explictly pass checked_permission=
# you cannot Access, unless you explictly pass checked_permission=
region_category
=
self
.
getPortal
()
.
portal_categories
.
region
region_category
=
self
.
portal
.
portal_categories
.
region
beta_id
=
"beta"
beta_id
=
"beta"
beta_title
=
"Beta System"
beta_title
=
"Beta System"
beta
=
region_category
.
newContent
(
beta
=
region_category
.
newContent
(
...
@@ -2316,7 +2298,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -2316,7 +2298,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
def
test_category_accessor_to_non_existing_documents
(
self
):
def
test_category_accessor_to_non_existing_documents
(
self
):
# tests behaviour of category accessors with relations to non existing
# tests behaviour of category accessors with relations to non existing
# documents.
# documents.
region_category
=
self
.
getPortal
()
.
portal_categories
.
region
region_category
=
self
.
portal
.
portal_categories
.
region
beta_id
=
"beta"
beta_id
=
"beta"
beta_title
=
"Beta System"
beta_title
=
"Beta System"
beta
=
region_category
.
newContent
(
beta
=
region_category
.
newContent
(
...
@@ -3030,7 +3012,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
...
@@ -3030,7 +3012,7 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor):
"""Tests action priority
"""Tests action priority
"""
"""
portal
=
self
.
getPortalObject
()
portal
=
self
.
getPortalObject
()
portal_actions
=
self
.
getPortal
()
.
portal_actions
portal_actions
=
self
.
portal
.
portal_actions
try
:
try
:
module
=
self
.
getPersonModule
()
module
=
self
.
getPersonModule
()
person
=
module
.
newContent
(
id
=
'1'
,
portal_type
=
'Person'
)
person
=
module
.
newContent
(
id
=
'1'
,
portal_type
=
'Person'
)
...
@@ -3118,7 +3100,7 @@ class TestAccessControl(ERP5TypeTestCase):
...
@@ -3118,7 +3100,7 @@ class TestAccessControl(ERP5TypeTestCase):
).
manage_proxy
((
'Manager'
,))
).
manage_proxy
((
'Manager'
,))
def
test
(
self
):
def
test
(
self
):
self
.
getPortal
()
.
person_module
.
newContent
().
Base_immediateReindexObject
()
self
.
portal
.
person_module
.
newContent
().
Base_immediateReindexObject
()
def
test_suite
():
def
test_suite
():
...
...
product/ERP5Type/tests/testFolder.py
View file @
ec1a895c
...
@@ -101,7 +101,7 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
...
@@ -101,7 +101,7 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
"""
"""
id_generator_script_name
=
'testIdGenerator'
id_generator_script_name
=
'testIdGenerator'
id_generator_id_list
=
[
'first_id'
,
'second_id'
]
id_generator_id_list
=
[
'first_id'
,
'second_id'
]
createZODBPythonScript
(
self
.
getPortal
()
.
portal_skins
.
erp5_core
,
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
erp5_core
,
id_generator_script_name
,
''
,
id_generator_script_name
,
''
,
'return %s[len(context)]'
%
(
repr
(
id_generator_id_list
),
))
'return %s[len(context)]'
%
(
repr
(
id_generator_id_list
),
))
self
.
folder
.
setIdGenerator
(
id_generator_script_name
)
self
.
folder
.
setIdGenerator
(
id_generator_script_name
)
...
@@ -168,10 +168,10 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
...
@@ -168,10 +168,10 @@ class TestFolder(ERP5TypeTestCase, LogInterceptor):
def
_createUpgradeObjectClassPythonScript
(
self
):
def
_createUpgradeObjectClassPythonScript
(
self
):
"""Create a simple python script """
"""Create a simple python script """
createZODBPythonScript
(
self
.
getPortal
()
.
portal_skins
.
custom
,
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
"test_upgradeObject"
,
'x'
,
"test_upgradeObject"
,
'x'
,
'return [1]'
)
'return [1]'
)
return
self
.
getPortal
()
.
portal_skins
.
custom
.
test_upgradeObject
return
self
.
portal
.
portal_skins
.
custom
.
test_upgradeObject
def
test_upgradeObjectClass
(
self
):
def
test_upgradeObjectClass
(
self
):
...
...
product/ERP5Type/tests/testFolderMigration.py
View file @
ec1a895c
...
@@ -52,7 +52,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
...
@@ -52,7 +52,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
Executed before each test_*.
Executed before each test_*.
"""
"""
self
.
login
()
self
.
login
()
self
.
folder
=
self
.
getPortal
()
.
newContent
(
id
=
'TestFolder'
,
self
.
folder
=
self
.
portal
.
newContent
(
id
=
'TestFolder'
,
portal_type
=
'Folder'
)
portal_type
=
'Folder'
)
def
beforeTearDown
(
self
):
def
beforeTearDown
(
self
):
...
@@ -60,7 +60,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
...
@@ -60,7 +60,7 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
Executed after each test_*.
Executed after each test_*.
"""
"""
self
.
folder
.
manage_delObjects
(
ids
=
list
(
self
.
folder
.
objectIds
()))
self
.
folder
.
manage_delObjects
(
ids
=
list
(
self
.
folder
.
objectIds
()))
self
.
getPortal
()
.
manage_delObjects
(
ids
=
[
self
.
folder
.
getId
(),])
self
.
portal
.
manage_delObjects
(
ids
=
[
self
.
folder
.
getId
(),])
clearCache
()
clearCache
()
self
.
tic
()
self
.
tic
()
...
...
product/ERP5Type/tests/testLocalizer.py
View file @
ec1a895c
...
@@ -119,7 +119,7 @@ class TestLocalizer(ERP5TypeTestCase):
...
@@ -119,7 +119,7 @@ class TestLocalizer(ERP5TypeTestCase):
tmp_obj
=
self
.
portal
.
portal_templates
.
newContent
()
tmp_obj
=
self
.
portal
.
portal_templates
.
newContent
()
self
.
tic
()
self
.
tic
()
tmp_obj
.
activate
().
test_activity
()
tmp_obj
.
activate
().
test_activity
()
# here we don't call self.tic() that calls self.
getPortal()
that
# here we don't call self.tic() that calls self.
portal
that
# reinvoke setSite(portal).
# reinvoke setSite(portal).
setSite
()
setSite
()
self
.
commit
()
self
.
commit
()
...
...
product/ERP5Type/tests/testMemcachedTool.py
View file @
ec1a895c
...
@@ -55,8 +55,8 @@ class TestMemcachedTool(ERP5TypeTestCase):
...
@@ -55,8 +55,8 @@ class TestMemcachedTool(ERP5TypeTestCase):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestMemcachedTool
,
self
).
setUp
()
super
(
TestMemcachedTool
,
self
).
setUp
()
installRealMemcachedTool
(
self
.
getPortal
()
)
installRealMemcachedTool
(
self
.
portal
)
memcached_tool
=
self
.
getPortal
()
.
portal_memcached
memcached_tool
=
self
.
portal
.
portal_memcached
#create Memcache Plugin
#create Memcache Plugin
url_string
=
"%(hostname)s:%(port)s"
%
_getVolatileMemcachedServerDict
()
url_string
=
"%(hostname)s:%(port)s"
%
_getVolatileMemcachedServerDict
()
if
getattr
(
memcached_tool
,
'default_memcached_plugin'
,
None
)
is
None
:
if
getattr
(
memcached_tool
,
'default_memcached_plugin'
,
None
)
is
None
:
...
@@ -77,17 +77,17 @@ class TestMemcachedTool(ERP5TypeTestCase):
...
@@ -77,17 +77,17 @@ class TestMemcachedTool(ERP5TypeTestCase):
self
.
login
()
self
.
login
()
def
login
(
self
):
def
login
(
self
):
uf
=
self
.
getPortal
()
.
acl_users
uf
=
self
.
portal
.
acl_users
uf
.
_doAddUser
(
'vincent'
,
''
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'vincent'
,
''
,
[
'Manager'
],
[])
user
=
uf
.
getUserById
(
'vincent'
).
__of__
(
uf
)
user
=
uf
.
getUserById
(
'vincent'
).
__of__
(
uf
)
newSecurityManager
(
None
,
user
)
newSecurityManager
(
None
,
user
)
def
getMemcachedDict
(
self
):
def
getMemcachedDict
(
self
):
return
self
.
getPortal
()
.
portal_memcached
.
getMemcachedDict
(
key_prefix
=
'unit_test'
,
return
self
.
portal
.
portal_memcached
.
getMemcachedDict
(
key_prefix
=
'unit_test'
,
plugin_path
=
'portal_memcached/default_memcached_plugin'
)
plugin_path
=
'portal_memcached/default_memcached_plugin'
)
def
getMemcachedDictWithExpiration
(
self
):
def
getMemcachedDictWithExpiration
(
self
):
return
self
.
getPortal
()
.
portal_memcached
.
getMemcachedDict
(
return
self
.
portal
.
portal_memcached
.
getMemcachedDict
(
key_prefix
=
'unit_test'
,
key_prefix
=
'unit_test'
,
plugin_path
=
'portal_memcached/memcached_plugin_with_expiration'
)
plugin_path
=
'portal_memcached/memcached_plugin_with_expiration'
)
...
@@ -101,7 +101,7 @@ class TestMemcachedTool(ERP5TypeTestCase):
...
@@ -101,7 +101,7 @@ class TestMemcachedTool(ERP5TypeTestCase):
'USE_MEMCACHED_TOOL'
)
'USE_MEMCACHED_TOOL'
)
self
.
assertFalse
(
os
.
access
(
memcached_tool_enable_path
,
os
.
F_OK
),
self
.
assertFalse
(
os
.
access
(
memcached_tool_enable_path
,
os
.
F_OK
),
'A static file %s is obsolete. Please remove it and retry this unit test.'
%
memcached_tool_enable_path
)
'A static file %s is obsolete. Please remove it and retry this unit test.'
%
memcached_tool_enable_path
)
memcached_tool
=
self
.
getPortal
()
.
portal_memcached
memcached_tool
=
self
.
portal
.
portal_memcached
try
:
try
:
import
memcache
import
memcache
except
ImportError
:
except
ImportError
:
...
...
product/ERP5Type/tests/testPerformance.py
View file @
ec1a895c
...
@@ -131,7 +131,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
...
@@ -131,7 +131,7 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
"""
"""
Return the bar module
Return the bar module
"""
"""
return
self
.
getPortal
()
[
'bar_module'
]
return
self
.
portal
[
'bar_module'
]
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
"""
"""
...
@@ -158,16 +158,16 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
...
@@ -158,16 +158,16 @@ class TestPerformance(ERP5TypeTestCase, LogInterceptor):
self
.
abort
()
self
.
abort
()
self
.
bar_module
.
manage_delObjects
(
list
(
self
.
bar_module
.
objectIds
()))
self
.
bar_module
.
manage_delObjects
(
list
(
self
.
bar_module
.
objectIds
()))
self
.
foo_module
.
manage_delObjects
(
list
(
self
.
foo_module
.
objectIds
()))
self
.
foo_module
.
manage_delObjects
(
list
(
self
.
foo_module
.
objectIds
()))
gender
=
self
.
getPortal
()
.
portal_categories
[
'gender'
]
gender
=
self
.
portal
.
portal_categories
[
'gender'
]
gender
.
manage_delObjects
(
list
(
gender
.
objectIds
()))
gender
.
manage_delObjects
(
list
(
gender
.
objectIds
()))
gender
=
self
.
getPortal
()
.
portal_caches
.
clearAllCache
()
gender
=
self
.
portal
.
portal_caches
.
clearAllCache
()
self
.
tic
()
self
.
tic
()
def
checkViewBarObject
(
self
,
min
,
max
,
quiet
=
quiet
,
prefix
=
None
):
def
checkViewBarObject
(
self
,
min
,
max
,
quiet
=
quiet
,
prefix
=
None
):
# Some init to display form with some value
# Some init to display form with some value
if
prefix
is
None
:
if
prefix
is
None
:
prefix
=
''
prefix
=
''
gender
=
self
.
getPortal
()
.
portal_categories
[
'gender'
]
gender
=
self
.
portal
.
portal_categories
[
'gender'
]
if
'male'
not
in
gender
.
objectIds
():
if
'male'
not
in
gender
.
objectIds
():
gender
.
newContent
(
id
=
'male'
,
title
=
'Male'
,
portal_type
=
'Category'
)
gender
.
newContent
(
id
=
'male'
,
title
=
'Male'
,
portal_type
=
'Category'
)
if
'female'
not
in
gender
.
objectIds
():
if
'female'
not
in
gender
.
objectIds
():
...
...
product/ERP5Type/tests/testSessionTool.py
View file @
ec1a895c
...
@@ -58,7 +58,7 @@ class TestSessionTool(ERP5TypeTestCase):
...
@@ -58,7 +58,7 @@ class TestSessionTool(ERP5TypeTestCase):
def
afterSetUp
(
self
):
def
afterSetUp
(
self
):
# create a Memcached Plugin
# create a Memcached Plugin
memcached_tool
=
self
.
getPortal
()
.
portal_memcached
memcached_tool
=
self
.
portal
.
portal_memcached
#create Memcache Plugin
#create Memcache Plugin
if
getattr
(
memcached_tool
,
'default_memcached_plugin'
,
None
)
is
None
:
if
getattr
(
memcached_tool
,
'default_memcached_plugin'
,
None
)
is
None
:
memcached_tool
.
newContent
(
id
=
'default_memcached_plugin'
,
memcached_tool
.
newContent
(
id
=
'default_memcached_plugin'
,
...
@@ -68,7 +68,7 @@ class TestSessionTool(ERP5TypeTestCase):
...
@@ -68,7 +68,7 @@ class TestSessionTool(ERP5TypeTestCase):
self
.
login
()
self
.
login
()
def
login
(
self
):
def
login
(
self
):
uf
=
self
.
getPortal
()
.
acl_users
uf
=
self
.
portal
.
acl_users
uf
.
_doAddUser
(
'ivan'
,
''
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'ivan'
,
''
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'ERP5TypeTestCase'
,
''
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'ERP5TypeTestCase'
,
''
,
[
'Manager'
],
[])
user
=
uf
.
getUserById
(
'ivan'
).
__of__
(
uf
)
user
=
uf
.
getUserById
(
'ivan'
).
__of__
(
uf
)
...
@@ -107,7 +107,7 @@ class TestSessionTool(ERP5TypeTestCase):
...
@@ -107,7 +107,7 @@ class TestSessionTool(ERP5TypeTestCase):
def
stepTestAcquisitionRamSessionStorage
(
self
,
sequence
=
None
,
\
def
stepTestAcquisitionRamSessionStorage
(
self
,
sequence
=
None
,
\
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
from
Products.ERP5Type.Document
import
newTempOrder
from
Products.ERP5Type.Document
import
newTempOrder
portal_sessions
=
self
.
getPortal
()
.
portal_sessions
portal_sessions
=
self
.
portal
.
portal_sessions
session
=
portal_sessions
.
newContent
(
session
=
portal_sessions
.
newContent
(
self
.
session_id
,
\
self
.
session_id
,
\
attr_1
=
newTempOrder
(
portal_sessions
,
'1'
),
\
attr_1
=
newTempOrder
(
portal_sessions
,
'1'
),
\
...
@@ -123,7 +123,7 @@ class TestSessionTool(ERP5TypeTestCase):
...
@@ -123,7 +123,7 @@ class TestSessionTool(ERP5TypeTestCase):
def
stepModifySession
(
self
,
sequence
=
None
,
\
def
stepModifySession
(
self
,
sequence
=
None
,
\
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
""" Modify session and check that modifications are updated in storage backend."""
""" Modify session and check that modifications are updated in storage backend."""
portal_sessions
=
self
.
getPortal
()
.
portal_sessions
portal_sessions
=
self
.
portal
.
portal_sessions
session
=
portal_sessions
.
newContent
(
self
.
session_id
,
\
session
=
portal_sessions
.
newContent
(
self
.
session_id
,
\
**
primitives_kw
)
**
primitives_kw
)
session
=
portal_sessions
[
self
.
session_id
]
session
=
portal_sessions
[
self
.
session_id
]
...
@@ -162,7 +162,7 @@ class TestSessionTool(ERP5TypeTestCase):
...
@@ -162,7 +162,7 @@ class TestSessionTool(ERP5TypeTestCase):
def
stepDeleteClearSession
(
self
,
sequence
=
None
,
\
def
stepDeleteClearSession
(
self
,
sequence
=
None
,
\
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
""" Get session object and check keys stored in previous test. """
""" Get session object and check keys stored in previous test. """
portal_sessions
=
self
.
getPortal
()
.
portal_sessions
portal_sessions
=
self
.
portal
.
portal_sessions
session
=
portal_sessions
.
newContent
(
self
.
session_id
,
\
session
=
portal_sessions
.
newContent
(
self
.
session_id
,
\
**
primitives_kw
)
**
primitives_kw
)
# delete it
# delete it
...
@@ -228,12 +228,12 @@ class TestSessionTool(ERP5TypeTestCase):
...
@@ -228,12 +228,12 @@ class TestSessionTool(ERP5TypeTestCase):
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
""" Test expire session which uses different cache plugin. """
""" Test expire session which uses different cache plugin. """
interval
=
3
interval
=
3
portal_sessions
=
self
.
getPortal
()
.
portal_sessions
portal_sessions
=
self
.
portal
.
portal_sessions
portal_sessions
.
manage_delObjects
(
self
.
session_id
)
portal_sessions
.
manage_delObjects
(
self
.
session_id
)
session
=
portal_sessions
.
getSession
(
self
.
session_id
,
session_duration
=
interval
)
session
=
portal_sessions
.
getSession
(
self
.
session_id
,
session_duration
=
interval
)
session
[
'key'
]
=
'value'
session
[
'key'
]
=
'value'
time
.
sleep
(
interval
+
1
)
time
.
sleep
(
interval
+
1
)
session
=
self
.
getPortal
()
.
portal_sessions
.
getSession
(
self
.
session_id
)
session
=
self
.
portal
.
portal_sessions
.
getSession
(
self
.
session_id
)
# session should be an emty dic as it expired
# session should be an emty dic as it expired
self
.
assert_
(
session
==
{})
self
.
assert_
(
session
==
{})
...
@@ -245,7 +245,7 @@ class TestSessionTool(ERP5TypeTestCase):
...
@@ -245,7 +245,7 @@ class TestSessionTool(ERP5TypeTestCase):
session
.
clear
()
session
.
clear
()
session
[
'key'
]
=
'value'
session
[
'key'
]
=
'value'
self
.
getPortal
()
.
person_module
.
newContent
(
portal_type
=
'Person'
,
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
,
default_address_city
=
'test'
,
default_address_city
=
'test'
,
default_address_region
=
'test'
,
default_address_region
=
'test'
,
default_address_street_address
=
'test'
,
default_address_street_address
=
'test'
,
...
...
product/ERP5Type/tests/testTransactionalVariable.py
View file @
ec1a895c
...
@@ -109,7 +109,7 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
...
@@ -109,7 +109,7 @@ class TestTransactionalVariable(ERP5TypeTestCase, LogInterceptor):
# in order to detect the difference between their behaviors.
# in order to detect the difference between their behaviors.
tv
[
'toto'
]
=
'titi'
tv
[
'toto'
]
=
'titi'
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
self
.
assertEqual
(
tv
[
'toto'
],
'titi'
)
portal
=
self
.
getPortal
()
portal
=
self
.
portal
vattr
=
'_v_erp5type_test_durability'
vattr
=
'_v_erp5type_test_durability'
setattr
(
portal
,
vattr
,
'dummy'
)
setattr
(
portal
,
vattr
,
'dummy'
)
self
.
assertEqual
(
getattr
(
portal
,
vattr
),
'dummy'
)
self
.
assertEqual
(
getattr
(
portal
,
vattr
),
'dummy'
)
...
...
product/ERP5Type/tests/testXMLMatrix.py
View file @
ec1a895c
...
@@ -57,12 +57,11 @@ class TestXMLMatrix(ERP5TypeTestCase, LogInterceptor):
...
@@ -57,12 +57,11 @@ class TestXMLMatrix(ERP5TypeTestCase, LogInterceptor):
"""
"""
Some pre-configuration
Some pre-configuration
"""
"""
uf
=
self
.
getPortal
()
.
acl_users
uf
=
self
.
portal
.
acl_users
uf
.
_doAddUser
(
'manager'
,
''
,
[
'Manager'
],
[])
uf
.
_doAddUser
(
'manager'
,
''
,
[
'Manager'
],
[])
user
=
uf
.
getUserById
(
'manager'
).
__of__
(
uf
)
user
=
uf
.
getUserById
(
'manager'
).
__of__
(
uf
)
newSecurityManager
(
None
,
user
)
newSecurityManager
(
None
,
user
)
portal
=
self
.
getPortal
()
module
=
self
.
portal
.
purchase_order_module
module
=
portal
.
purchase_order_module
order
=
module
.
newContent
(
portal_type
=
'Purchase Order'
)
order
=
module
.
newContent
(
portal_type
=
'Purchase Order'
)
self
.
matrix
=
order
.
newContent
(
portal_type
=
'Purchase Order Line'
)
self
.
matrix
=
order
.
newContent
(
portal_type
=
'Purchase Order Line'
)
self
.
_catch_log_errors
(
ignored_level
=
PROBLEM
)
self
.
_catch_log_errors
(
ignored_level
=
PROBLEM
)
...
...
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