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
Eric Zheng
slapos.core
Commits
0feaf356
Commit
0feaf356
authored
Dec 04, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check that Person_isAllowedToAllocate is used during allocation
parent
496d5613
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
1 deletion
+62
-1
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudAlarm.py
...bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudAlarm.py
+61
-0
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCloudAlarm.py
View file @
0feaf356
...
...
@@ -180,6 +180,67 @@ class TestSlapOSAllocation(testSlapOSMixin):
super
(
TestSlapOSAllocation
,
self
).
\
_makeTree
(
requested_template_id
=
requested_template_id
)
def
_simulatePerson_isAllowedToAllocate
(
self
):
script_name
=
'Person_isAllowedToAllocate'
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 Person_isAllowedToAllocate')
return True"""
)
transaction
.
commit
()
def
_simulatePerson_isNotAllowedToAllocate
(
self
):
script_name
=
'Person_isAllowedToAllocate'
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
'
"""return False"""
)
transaction
.
commit
()
def
_dropPerson_isAllowedToAllocate
(
self
):
script_name
=
'Person_isAllowedToAllocate'
if
script_name
in
self
.
portal
.
portal_skins
.
custom
.
objectIds
():
self
.
portal
.
portal_skins
.
custom
.
manage_delObjects
(
script_name
)
transaction
.
commit
()
def
test_person_allocation_checked
(
self
):
self
.
_makeTree
()
self
.
_simulatePerson_isAllowedToAllocate
()
try
:
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
finally
:
self
.
_dropPerson_isAllowedToAllocate
()
self
.
assertEqual
(
'Visited by Person_isAllowedToAllocate'
,
self
.
person_user
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_no_allocation_if_person_is_not_allowed
(
self
):
self
.
_makeTree
()
self
.
_makeComputer
()
self
.
_installSoftware
(
self
.
computer
,
self
.
software_instance
.
getUrlString
())
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
self
.
_simulatePerson_isNotAllowedToAllocate
()
try
:
self
.
software_instance
.
SoftwareInstance_tryToAllocatePartition
()
finally
:
self
.
_dropPerson_isAllowedToAllocate
()
self
.
assertEqual
(
None
,
self
.
software_instance
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
self
.
assertEqual
(
'Allocation failed: Allocation disallowed'
,
self
.
software_instance
.
workflow_history
[
'edit_workflow'
][
-
1
][
'comment'
])
def
test_allocation_no_free_partition
(
self
):
self
.
_makeTree
()
...
...
master/bt5/slapos_cloud/bt/revision
View file @
0feaf356
303
\ No newline at end of file
304
\ 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