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
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
0c26d066
Commit
0c26d066
authored
Apr 28, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP testUpgradeInstanceWithOldDataFs
parent
93259130
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
96 additions
and
3 deletions
+96
-3
product/ERP5Type/tests/testUpgradeInstanceWithOldDataFs.py
product/ERP5Type/tests/testUpgradeInstanceWithOldDataFs.py
+96
-3
No files found.
product/ERP5Type/tests/testUpgradeInstanceWithOldDataFs.py
View file @
0c26d066
...
@@ -26,8 +26,75 @@
...
@@ -26,8 +26,75 @@
#
#
##############################################################################
##############################################################################
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.Core.Folder
import
Folder
from
ZODB.broken
import
PersistentBroken
import
os
import
json
class
TestUpgradeInstanceWithOldDataFs
(
ERP5TypeTestCase
):
class
TestUpgradeInstanceWithOldDataFs
(
ERP5TypeTestCase
):
object_dump_path
=
os
.
path
.
join
(
os
.
environ
[
'INSTANCE_HOME'
],
'%s.json'
%
__name__
)
def
setUpOnce
(
self
):
# a mapping of document properties keyed by their path
document_property_dict
=
{}
def
getAllowedContentTypes
(
container
):
if
container
.
getPortalType
()
==
'Trash Tool'
:
return
[
'Trash Bin'
]
if
container
.
getPortalType
()
in
(
# These types accept anything, but actually creating
# documents often fail.
'Trash Bin'
,
'Introspection Tool'
,
'Session Tool'
,
# We don't want to create new types
'Types Tool'
,
'Solver Tool'
,
):
return
[]
return
[
x
.
getId
()
for
x
in
container
.
allowedContentTypes
()]
def
createSubContent
(
container
,
level
):
if
level
==
0
:
return
for
allowed_content_type
in
getAllowedContentTypes
(
container
):
document
=
container
.
newContent
(
portal_type
=
allowed_content_type
,)
if
hasattr
(
document
,
'_setTitle'
):
# XXX some documents (Id Generator) did not have setTitle when reference
# database was created.
document
.
setTitle
(
'{} in {}'
.
format
(
allowed_content_type
,
container
.
getTitle
(),
))
createSubContent
(
document
,
level
-
1
)
def
recordProperties
(
document
):
document_property_dict
[
document
.
getPath
()]
=
{
'title'
:
document
.
getTitle
(),
'uid'
:
document
.
getUid
()
}
if
isinstance
(
document
,
Folder
):
for
sub_document
in
document
.
objectValues
():
recordProperties
(
sub_document
)
for
module
in
self
.
portal
.
objectValues
():
if
isinstance
(
module
,
Folder
):
createSubContent
(
module
,
4
)
recordProperties
(
module
)
with
open
(
self
.
object_dump_path
,
'w'
)
as
f
:
json
.
dump
(
document_property_dict
,
f
,
sort_keys
=
True
,
indent
=
2
,
)
print
(
'Saved dump at '
+
self
.
object_dump_path
)
def
getBusinessTemplateList
(
self
):
def
getBusinessTemplateList
(
self
):
return
(
'erp5_core_proxy_field_legacy'
,
return
(
'erp5_core_proxy_field_legacy'
,
'erp5_full_text_mroonga_catalog'
,
'erp5_full_text_mroonga_catalog'
,
...
@@ -40,7 +107,11 @@ class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
...
@@ -40,7 +107,11 @@ class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
'erp5_trade'
,
'erp5_trade'
,
'erp5_accounting'
,
'erp5_accounting'
,
'erp5_configurator_standard_trade_template'
,
'erp5_configurator_standard_trade_template'
,
'erp5_upgrader'
)
'erp5_invoicing'
,
'erp5_simplified_invoicing'
,
'erp5_configurator_standard_invoicing_template'
,
'erp5_upgrader'
,
)
def
testUpgrade
(
self
):
def
testUpgrade
(
self
):
if
not
self
.
portal
.
portal_templates
.
getRepositoryList
():
if
not
self
.
portal
.
portal_templates
.
getRepositoryList
():
...
@@ -54,6 +125,7 @@ class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
...
@@ -54,6 +125,7 @@ class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
''
,
''
,
"""return (('erp5_base',
"""return (('erp5_base',
'erp5_configurator_standard_trade_template',
'erp5_configurator_standard_trade_template',
'erp5_configurator_standard_invoicing_template',
'erp5_configurator_standard',
'erp5_configurator_standard',
'erp5_jquery',
'erp5_jquery',
'erp5_xhtml_style'),
'erp5_xhtml_style'),
...
@@ -63,7 +135,7 @@ class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
...
@@ -63,7 +135,7 @@ class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
alarm
=
self
.
portal
.
portal_alarms
.
promise_check_upgrade
alarm
=
self
.
portal
.
portal_alarms
.
promise_check_upgrade
alarm
.
solve
()
alarm
.
solve
()
self
.
tic
()
self
.
tic
()
self
.
assertEqual
s
(
alarm
.
getLastActiveProcess
().
getResultList
(),
[])
self
.
assertEqual
(
alarm
.
getLastActiveProcess
().
getResultList
(),
[])
# Make sure that *all* Portal Type can be loaded after upgrade
# Make sure that *all* Portal Type can be loaded after upgrade
import
erp5.portal_type
import
erp5.portal_type
...
@@ -75,6 +147,27 @@ class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
...
@@ -75,6 +147,27 @@ class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
portal_type_class
.
loadClass
()
portal_type_class
.
loadClass
()
if
issubclass
(
portal_type_class
,
ERP5BaseBroken
):
if
issubclass
(
portal_type_class
,
ERP5BaseBroken
):
error_list
.
append
(
portal_type_id
)
error_list
.
append
(
portal_type_id
)
self
.
assertEqual
s
(
self
.
assertEqual
(
error_list
,
[],
error_list
,
[],
msg
=
"The following Portal Type classes could not be loaded (see zLOG.log): %r"
%
error_list
)
msg
=
"The following Portal Type classes could not be loaded (see zLOG.log): %r"
%
error_list
)
# check all documents are same as before dump
with
open
(
self
.
object_dump_path
,
'r'
)
as
f
:
reference
=
json
.
load
(
f
)
actual
=
{}
for
path
,
property_dict
in
reference
.
items
():
document
=
self
.
portal
.
restrictedTraverse
(
str
(
path
),
None
)
if
document
is
not
None
:
actual
[
path
]
=
{
k
:
document
.
getProperty
(
k
)
for
k
in
property_dict
}
if
isinstance
(
document
,
PersistentBroken
):
actual
[
path
][
'is_broken'
]
=
True
# ignore `title` differences for id generators, in the ERP5 version used
# to produce the dump, id generators title accessors where broken.
for
path
in
actual
:
if
path
.
startswith
(
'/erp5/portal_ids/'
):
actual
[
path
][
'title'
]
=
reference
[
path
][
'title'
]
self
.
maxDiff
=
None
# we dump + load as json to eliminate small differences in data types such as long and int
self
.
assertEqual
(
json
.
loads
(
json
.
dumps
(
actual
)),
reference
)
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