Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Xiaowu Zhang
slapos.core
Commits
cc05ee0c
Commit
cc05ee0c
authored
Jul 31, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_pdm: Clean up testSlapOSPDMAlarm
* Use single API * Unify usage of _simulateScript with the mixin
parent
ce3be333
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
68 deletions
+31
-68
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
...ateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
+11
-52
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.xml
...teItem/portal_components/test.erp5.testSlapOSPDMAlarm.xml
+20
-16
No files found.
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.py
View file @
cc05ee0c
# Copyright (c) 2013 Nexedi SA and Contributors. All Rights Reserved.
import
transaction
from
erp5.component.test.SlapOSTestCaseMixin
import
SlapOSTestCaseMixin
from
Products.ERP5Type.tests.utils
import
createZODBPythonScript
class
TestSlapOSUpgradeDecisionProcess
(
SlapOSTestCaseMixin
):
def
afterSetUp
(
self
):
SlapOSTestCaseMixin
.
afterSetUp
(
self
)
...
...
@@ -18,21 +15,6 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
upgrade_decision
.
confirm
()
return
upgrade_decision
def
_makeComputer
(
self
,
new_id
):
# Clone computer document
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
computer
=
self
.
portal
.
computer_module
\
.
template_computer
.
Base_createCloneDocument
(
batch_mode
=
1
)
computer
.
edit
(
title
=
"computer ticket %s"
%
(
new_id
,
),
reference
=
"TESTCOMPT-%s"
%
(
new_id
,
),
source_administration_value
=
person
)
computer
.
validate
()
return
computer
def
_makeHostingSubscription
(
self
,
slap_state
=
"start_requested"
):
hosting_subscription
=
self
.
portal
\
.
hosting_subscription_module
.
template_hosting_subscription
\
...
...
@@ -46,24 +28,6 @@ class TestSlapOSUpgradeDecisionProcess(SlapOSTestCaseMixin):
return
hosting_subscription
def
_simulateScript
(
self
,
script_name
,
fake_return
=
'True'
):
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
raise
ValueError
(
'Precondition failed: %s exists in custom'
%
script_name
)
createZODBPythonScript
(
self
.
portal
.
portal_skins
.
custom
,
script_name
,
'*args, **kwargs'
,
'# Script body
\
n
'
"""portal_workflow = context.portal_workflow
portal_workflow.doActionFor(context, action='edit_action', comment='Visited by %s')
return %s
"""
%
(
script_name
,
fake_return
))
transaction
.
commit
()
def
_dropScript
(
self
,
script_name
):
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
test_alarm_upgrade_decision_process_hosting_subscription
(
self
):
upgrade_decision
=
self
.
_makeUpgradeDecision
()
upgrade_decision
.
start
()
...
...
@@ -84,7 +48,7 @@ return %s
upgrade_decision
.
plan
()
self
.
tic
()
self
.
_simulateScript
(
'UpgradeDecision_notify'
)
self
.
_simulateScript
(
'UpgradeDecision_notify'
,
'True'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_planned
.
\
activeSense
()
...
...
@@ -102,7 +66,7 @@ return %s
upgrade_decision
.
stop
()
self
.
tic
()
self
.
_simulateScript
(
'UpgradeDecision_notifyDelivered'
)
self
.
_simulateScript
(
'UpgradeDecision_notifyDelivered'
,
'True'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_pdm_upgrade_decision_process_stopped
.
\
activeSense
()
...
...
@@ -114,15 +78,12 @@ return %s
upgrade_decision
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_computer_create_upgrade_decision
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
computer
.
edit
(
allocation_scope
=
'open/public'
)
computer2
=
self
.
_makeComputer
(
self
.
generateNewId
())
computer2
.
edit
(
allocation_scope
=
'open/personal'
)
computer3
=
self
.
_makeComputer
(
self
.
generateNewId
())
computer3
.
edit
(
allocation_scope
=
'open/friend'
)
computer
=
self
.
_makeComputer
(
allocation_scope
=
'open/public'
)[
0
]
computer2
=
self
.
_makeComputer
(
allocation_scope
=
'open/personal'
)[
0
]
computer3
=
self
.
_makeComputer
(
allocation_scope
=
'open/friend'
)[
0
]
self
.
tic
()
self
.
_simulateScript
(
'Computer_checkAndCreateUpgradeDecision'
)
self
.
_simulateScript
(
'Computer_checkAndCreateUpgradeDecision'
,
'True'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_pdm_computer_create_upgrade_decision
.
\
activeSense
()
...
...
@@ -146,7 +107,7 @@ return %s
self
.
tic
()
self
.
_simulateScript
(
'HostingSubscription_createUpgradeDecision'
)
self
.
_simulateScript
(
'HostingSubscription_createUpgradeDecision'
,
'True'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_pdm_hosting_subscription_create_upgrade_decision
.
\
activeSense
()
...
...
@@ -168,7 +129,7 @@ return %s
hosting_subscription2
=
self
.
_makeHostingSubscription
(
slap_state
=
"destroy_requested"
)
self
.
tic
()
self
.
_simulateScript
(
'HostingSubscription_createUpgradeDecision'
)
self
.
_simulateScript
(
'HostingSubscription_createUpgradeDecision'
,
'True'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_pdm_hosting_subscription_create_upgrade_decision
.
\
activeSense
()
...
...
@@ -183,13 +144,11 @@ return %s
hosting_subscription2
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_alarm_create_upgrade_decision_closed_computer
(
self
):
computer
=
self
.
_makeComputer
(
self
.
new_id
)
computer
.
edit
(
allocation_scope
=
'close/oudtated'
)
computer2
=
self
.
_makeComputer
(
self
.
generateNewId
())
computer2
.
edit
(
allocation_scope
=
'close/maintenance'
)
computer
=
self
.
_makeComputer
(
allocation_scope
=
'close/oudtated'
)[
0
]
computer2
=
self
.
_makeComputer
(
allocation_scope
=
'close/maintenance'
)[
0
]
self
.
tic
()
self
.
_simulateScript
(
'Computer_checkAndCreateUpgradeDecision'
)
self
.
_simulateScript
(
'Computer_checkAndCreateUpgradeDecision'
,
'True'
)
try
:
self
.
portal
.
portal_alarms
.
slapos_pdm_computer_create_upgrade_decision
.
\
activeSense
()
...
...
master/bt5/slapos_pdm/TestTemplateItem/portal_components/test.erp5.testSlapOSPDMAlarm.xml
View file @
cc05ee0c
...
...
@@ -100,24 +100,28 @@
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
patches.WorkflowTool
"
/>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
Workflow
"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</tuple>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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