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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Georgios Dagkakis
erp5
Commits
b51728f4
Commit
b51728f4
authored
May 22, 2017
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5-upgrader: new test for sequentiality of activities run by upgrader
parent
c6794993
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
1 deletion
+82
-1
bt5/erp5_upgrader/TestTemplateItem/portal_components/test.erp5.testUpgrader.py
...tTemplateItem/portal_components/test.erp5.testUpgrader.py
+82
-1
No files found.
bt5/erp5_upgrader/TestTemplateItem/portal_components/test.erp5.testUpgrader.py
View file @
b51728f4
...
@@ -135,12 +135,19 @@ class TestUpgrader(ERP5TypeTestCase):
...
@@ -135,12 +135,19 @@ class TestUpgrader(ERP5TypeTestCase):
id=script_constraint_id)
id=script_constraint_id)
script_constraint.edit(script_id=self.script_id, constraint_type="
pre_upgrade
")
script_constraint.edit(script_id=self.script_id, constraint_type="
pre_upgrade
")
def
stepCreatePersonPropertySheet(self, sequence=None
):
def
_createPersonEmptyPropertySheet(self
):
portal = self.portal
portal = self.portal
property_sheet = getattr(portal.portal_property_sheets, self.property_sheet_id, None)
property_sheet = getattr(portal.portal_property_sheets, self.property_sheet_id, None)
if property_sheet is None:
if property_sheet is None:
property_sheet = portal.portal_property_sheets.newContent(
property_sheet = portal.portal_property_sheets.newContent(
portal_type="
Property
Sheet
", id=self.property_sheet_id)
portal_type="
Property
Sheet
", id=self.property_sheet_id)
return property_sheet
def stepCreatePersonEmptyPropertySheet(self, sequence=None):
self._createPersonEmptyPropertySheet()
def stepCreatePersonPropertySheet(self, sequence=None):
property_sheet = self._createPersonEmptyPropertySheet()
script_constraint_id = "
person_old_reference_constraint
"
script_constraint_id = "
person_old_reference_constraint
"
script_constraint = getattr(property_sheet, script_constraint_id, None)
script_constraint = getattr(property_sheet, script_constraint_id, None)
if script_constraint is None:
if script_constraint is None:
...
@@ -768,3 +775,77 @@ class TestUpgrader(ERP5TypeTestCase):
...
@@ -768,3 +775,77 @@ class TestUpgrader(ERP5TypeTestCase):
"""
"""
sequence_list.addSequenceString(sequence_string)
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
sequence_list.play(self)
def _setPersonTitleConstraintForUpgraderStep(self, step):
portal = self.portal
skin_folder = portal.portal_skins.custom
script_id = "
Person_
%
s_setTitleConstraint
" % step
custom_script = getattr(skin_folder, script_id, None)
if custom_script is None:
skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript(script_id)
custom_script = getattr(skin_folder, script_id)
custom_script.ZPythonScript_edit('fixit=False, **kw',
"
{
step_string
}
=
'M. {step_string}'
\
n
"
"
if
context
.
getTitle
()
!=
{
step_string
}:
\
n
"
"
if
fixit
:
\
n
"
"
context
.
setTitle
({
step_string
})
\
n
"
"
else
:
\
n
"
"
return
[
\
"Person's title is wrong
\
"
,]
\
n
"
"return []"
.
format
(
step_string
=
step
)
)
property_sheet_id
=
self
.
property_sheet_id
property_sheet
=
getattr
(
portal
.
portal_property_sheets
,
property_sheet_id
,
None
)
script_constraint_id
=
"person_title_%s_constraint"
%
step
script_constraint
=
getattr
(
property_sheet
,
script_constraint_id
,
None
)
if
script_constraint
is
None
:
script_constraint
=
property_sheet
.
newContent
(
portal_type
=
"Script Constraint"
,
id
=
script_constraint_id
)
script_constraint
.
edit
(
script_id
=
script_id
,
constraint_type
=
"%s"
%
step
)
def
stepSetPersonTitlePreUpgradeConstraint
(
self
,
sequence
=
None
):
self
.
_setPersonTitleConstraintForUpgraderStep
(
'pre_upgrade'
)
def
stepSetPersonTitleUpgradeConstraint
(
self
,
sequence
=
None
):
self
.
_setPersonTitleConstraintForUpgraderStep
(
'upgrader'
)
def
stepSetPersonTitlePostUpgradeConstraint
(
self
,
sequence
=
None
):
self
.
_setPersonTitleConstraintForUpgraderStep
(
'post_upgrade'
)
def
stepCheckPersonTitleHasBeenSetByPersonTitlePostUpgradeConstraint
(
self
,
sequence
=
None
):
person
=
sequence
[
'person'
]
title
=
person
.
getTitle
()
self
.
assertEqual
(
title
,
'M. post_upgrade'
)
def
stepCheckPersonTitleHistory
(
self
,
sequence
=
None
):
person
=
sequence
[
'person'
]
self
.
assertEqual
(
[
x
.
changes
for
x
in
self
.
portal
.
person_module
[
'1'
].
Base_getZODBHistoryList
()[
-
3
:]],
[(
'title:M. pre_upgrade'
,),
(
'title:M. upgrader'
,),
(
'title:M. post_upgrade'
,)])
def
test_upgrade_activities_are_run_sequentially
(
self
):
"""
Check that activities spawned by the upgrader are always run in the same
order : pre-upgrade, upgrade, post-upgrade
"""
sequence_list
=
SequenceList
()
sequence_string
=
"""
stepCreatePerson
stepValidatePerson
stepCreatePersonEmptyPropertySheet
stepSetConstraintInPersonPortalType
stepSetPersonTitlePreUpgradeConstraint
stepSetPersonTitleUpgradeConstraint
stepSetPersonTitlePostUpgradeConstraint
stepTic
stepRunFullUpgrader
stepTic
stepCheckPersonTitleHasBeenSetByPersonTitlePostUpgradeConstraint
stepCheckPersonTitleHistory
"""
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
\ No newline at end of file
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