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
Thomas Leymonerie
slapos.core
Commits
ab3cee7d
Commit
ab3cee7d
authored
Oct 31, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge to modules following conventions.
parent
5affd3d0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
219 additions
and
224 deletions
+219
-224
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCorePersonRequestComputer.py
...d/TestTemplateItem/testSlapOSCorePersonRequestComputer.py
+0
-220
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCorePersonSlapInterfaceWorkflow.py
...TemplateItem/testSlapOSCorePersonSlapInterfaceWorkflow.py
+216
-0
master/bt5/slapos_cloud/bt/revision
master/bt5/slapos_cloud/bt/revision
+1
-1
master/bt5/slapos_cloud/bt/template_test_id_list
master/bt5/slapos_cloud/bt/template_test_id_list
+2
-3
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCorePersonRequestComputer.py
deleted
100644 → 0
View file @
5affd3d0
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from
Products.SlapOS.tests.testSlapOSMixin
import
testSlapOSMixin
import
transaction
from
AccessControl.SecurityManagement
import
getSecurityManager
,
\
setSecurityManager
class
TestSlapOSCorePersonRequestComputer
(
testSlapOSMixin
):
def
generateNewComputerTitle
(
self
):
return
'My Comp %s'
%
self
.
generateNewId
()
def
afterSetUp
(
self
):
super
(
TestSlapOSCorePersonRequestComputer
,
self
).
afterSetUp
()
portal
=
self
.
getPortalObject
()
new_id
=
self
.
generateNewId
()
# Clone person document
person_user
=
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
person_user
.
edit
(
title
=
"live_test_%s"
%
new_id
,
reference
=
"live_test_%s"
%
new_id
,
default_email_text
=
"live_test_%s@example.org"
%
new_id
,
)
person_user
.
validate
()
for
assignment
in
person_user
.
contentValues
(
portal_type
=
"Assignment"
):
assignment
.
open
()
transaction
.
commit
()
# XXX Tic is needed to reindex the created open order
self
.
tic
()
# Login as new user
self
.
login
(
person_user
.
getReference
())
new_person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
self
.
assertEquals
(
person_user
.
getRelativeUrl
(),
new_person
.
getRelativeUrl
())
def
beforeTearDown
(
self
):
pass
def
test_request_requiredParameter
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
# computer_title is mandatory
self
.
assertRaises
(
TypeError
,
person
.
requestComputer
)
# if provided does not raise
computer_title
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
def
test_request
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
computer_title
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
# check what is returned via request
computer_url
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url
)
self
.
assertNotEqual
(
None
,
computer_absolute_url
)
self
.
assertNotEqual
(
None
,
computer_reference
)
def
test_request_createdComputer
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
previous_id
=
self
.
getPortalObject
().
portal_ids
\
.
generateNewId
(
id_group
=
'slap_computer_reference'
,
id_generator
=
'uid'
)
computer_title
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
# check what is returned via request
computer_url
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url
)
self
.
assertNotEqual
(
None
,
computer_absolute_url
)
self
.
assertNotEqual
(
None
,
computer_reference
)
# check that title is ok
computer
=
person
.
restrictedTraverse
(
computer_url
)
self
.
assertEqual
(
computer_title
,
computer
.
getTitle
())
# check that data are sane
self
.
assertEqual
(
computer_absolute_url
,
computer
.
absolute_url
())
self
.
assertEqual
(
computer_reference
,
computer
.
getReference
())
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
1
),
computer
.
getReference
())
self
.
assertEqual
(
'validated'
,
computer
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
computer
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
computer
.
getCapacityScope
())
def
test_request_notReindexedCompute
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
computer_title
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
transaction
.
commit
()
self
.
assertRaises
(
NotImplementedError
,
person
.
requestComputer
,
computer_title
=
computer_title
)
def
test_multiple_request_createdComputer
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
previous_id
=
self
.
getPortalObject
().
portal_ids
\
.
generateNewId
(
id_group
=
'slap_computer_reference'
,
id_generator
=
'uid'
)
computer_title
=
self
.
generateNewComputerTitle
()
computer_title2
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
# check what is returned via request
computer_url
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url
)
self
.
assertNotEqual
(
None
,
computer_absolute_url
)
self
.
assertNotEqual
(
None
,
computer_reference
)
# check that title is ok
computer
=
person
.
restrictedTraverse
(
computer_url
)
self
.
assertEqual
(
computer_title
,
computer
.
getTitle
())
# check that data are sane
self
.
assertEqual
(
computer_absolute_url
,
computer
.
absolute_url
())
self
.
assertEqual
(
computer_reference
,
computer
.
getReference
())
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
1
),
computer
.
getReference
())
self
.
assertEqual
(
'validated'
,
computer
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
computer
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
computer
.
getCapacityScope
())
self
.
tic
()
# request again the same computer
person
.
requestComputer
(
computer_title
=
computer_title
)
# check what is returned via request
computer_url
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url
)
self
.
assertNotEqual
(
None
,
computer_absolute_url
)
self
.
assertNotEqual
(
None
,
computer_reference
)
# check that title is ok
computer
=
person
.
restrictedTraverse
(
computer_url
)
self
.
assertEqual
(
computer_title
,
computer
.
getTitle
())
# check that data are sane
self
.
assertEqual
(
computer_absolute_url
,
computer
.
absolute_url
())
self
.
assertEqual
(
computer_reference
,
computer
.
getReference
())
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
1
),
computer
.
getReference
())
self
.
assertEqual
(
'validated'
,
computer
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
computer
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
computer
.
getCapacityScope
())
# and now another one
person
.
requestComputer
(
computer_title
=
computer_title2
)
# check what is returned via request
computer_url2
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url2
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference2
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url2
)
self
.
assertNotEqual
(
None
,
computer_absolute_url2
)
self
.
assertNotEqual
(
None
,
computer_reference2
)
# check that computers are really different objects
self
.
assertNotEqual
(
computer_url2
,
computer_url
)
# check that title is ok
computer2
=
person
.
restrictedTraverse
(
computer_url2
)
self
.
assertEqual
(
computer_title2
,
computer2
.
getTitle
())
# check that data are sane
self
.
assertEqual
(
computer_absolute_url2
,
computer2
.
absolute_url
())
self
.
assertEqual
(
computer_reference2
,
computer2
.
getReference
())
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
2
),
computer2
.
getReference
())
self
.
assertEqual
(
'validated'
,
computer2
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
computer2
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
computer2
.
getCapacityScope
())
def
test_request_duplicatedComputer
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
computer_title
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
# check what is returned via request
computer_url
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url
)
self
.
assertNotEqual
(
None
,
computer_absolute_url
)
self
.
assertNotEqual
(
None
,
computer_reference
)
# check that title is ok
computer
=
person
.
restrictedTraverse
(
computer_url
)
sm
=
getSecurityManager
()
try
:
self
.
login
()
computer2
=
computer
.
Base_createCloneDocument
(
batch_mode
=
1
)
computer2
.
validate
()
finally
:
setSecurityManager
(
sm
)
self
.
tic
()
self
.
assertRaises
(
NotImplementedError
,
person
.
requestComputer
,
computer_title
=
computer_title
)
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCorePerson
Request
.py
→
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCorePerson
SlapInterfaceWorkflow
.py
View file @
ab3cee7d
...
...
@@ -3,6 +3,8 @@ from Products.SlapOS.tests.testSlapOSMixin import \
testSlapOSMixin
import
transaction
from
Products.ERP5Type.tests.backportUnittest
import
expectedFailure
from
AccessControl.SecurityManagement
import
getSecurityManager
,
\
setSecurityManager
class
TestSlapOSCorePersonRequest
(
testSlapOSMixin
):
...
...
@@ -562,3 +564,217 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin):
self
.
assertEquals
(
"start_requested"
,
hosting_subscription2
.
getSlapState
())
self
.
assertNotEquals
(
hosting_subscription
.
getRelativeUrl
(),
hosting_subscription2
.
getRelativeUrl
())
class
TestSlapOSCorePersonRequestComputer
(
testSlapOSMixin
):
def
generateNewComputerTitle
(
self
):
return
'My Comp %s'
%
self
.
generateNewId
()
def
afterSetUp
(
self
):
super
(
TestSlapOSCorePersonRequestComputer
,
self
).
afterSetUp
()
portal
=
self
.
getPortalObject
()
new_id
=
self
.
generateNewId
()
# Clone person document
person_user
=
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
person_user
.
edit
(
title
=
"live_test_%s"
%
new_id
,
reference
=
"live_test_%s"
%
new_id
,
default_email_text
=
"live_test_%s@example.org"
%
new_id
,
)
person_user
.
validate
()
for
assignment
in
person_user
.
contentValues
(
portal_type
=
"Assignment"
):
assignment
.
open
()
transaction
.
commit
()
# XXX Tic is needed to reindex the created open order
self
.
tic
()
# Login as new user
self
.
login
(
person_user
.
getReference
())
new_person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
self
.
assertEquals
(
person_user
.
getRelativeUrl
(),
new_person
.
getRelativeUrl
())
def
beforeTearDown
(
self
):
pass
def
test_request_requiredParameter
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
# computer_title is mandatory
self
.
assertRaises
(
TypeError
,
person
.
requestComputer
)
# if provided does not raise
computer_title
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
def
test_request
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
computer_title
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
# check what is returned via request
computer_url
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url
)
self
.
assertNotEqual
(
None
,
computer_absolute_url
)
self
.
assertNotEqual
(
None
,
computer_reference
)
def
test_request_createdComputer
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
previous_id
=
self
.
getPortalObject
().
portal_ids
\
.
generateNewId
(
id_group
=
'slap_computer_reference'
,
id_generator
=
'uid'
)
computer_title
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
# check what is returned via request
computer_url
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url
)
self
.
assertNotEqual
(
None
,
computer_absolute_url
)
self
.
assertNotEqual
(
None
,
computer_reference
)
# check that title is ok
computer
=
person
.
restrictedTraverse
(
computer_url
)
self
.
assertEqual
(
computer_title
,
computer
.
getTitle
())
# check that data are sane
self
.
assertEqual
(
computer_absolute_url
,
computer
.
absolute_url
())
self
.
assertEqual
(
computer_reference
,
computer
.
getReference
())
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
1
),
computer
.
getReference
())
self
.
assertEqual
(
'validated'
,
computer
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
computer
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
computer
.
getCapacityScope
())
def
test_request_notReindexedCompute
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
computer_title
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
transaction
.
commit
()
self
.
assertRaises
(
NotImplementedError
,
person
.
requestComputer
,
computer_title
=
computer_title
)
def
test_multiple_request_createdComputer
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
previous_id
=
self
.
getPortalObject
().
portal_ids
\
.
generateNewId
(
id_group
=
'slap_computer_reference'
,
id_generator
=
'uid'
)
computer_title
=
self
.
generateNewComputerTitle
()
computer_title2
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
# check what is returned via request
computer_url
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url
)
self
.
assertNotEqual
(
None
,
computer_absolute_url
)
self
.
assertNotEqual
(
None
,
computer_reference
)
# check that title is ok
computer
=
person
.
restrictedTraverse
(
computer_url
)
self
.
assertEqual
(
computer_title
,
computer
.
getTitle
())
# check that data are sane
self
.
assertEqual
(
computer_absolute_url
,
computer
.
absolute_url
())
self
.
assertEqual
(
computer_reference
,
computer
.
getReference
())
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
1
),
computer
.
getReference
())
self
.
assertEqual
(
'validated'
,
computer
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
computer
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
computer
.
getCapacityScope
())
self
.
tic
()
# request again the same computer
person
.
requestComputer
(
computer_title
=
computer_title
)
# check what is returned via request
computer_url
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url
)
self
.
assertNotEqual
(
None
,
computer_absolute_url
)
self
.
assertNotEqual
(
None
,
computer_reference
)
# check that title is ok
computer
=
person
.
restrictedTraverse
(
computer_url
)
self
.
assertEqual
(
computer_title
,
computer
.
getTitle
())
# check that data are sane
self
.
assertEqual
(
computer_absolute_url
,
computer
.
absolute_url
())
self
.
assertEqual
(
computer_reference
,
computer
.
getReference
())
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
1
),
computer
.
getReference
())
self
.
assertEqual
(
'validated'
,
computer
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
computer
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
computer
.
getCapacityScope
())
# and now another one
person
.
requestComputer
(
computer_title
=
computer_title2
)
# check what is returned via request
computer_url2
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url2
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference2
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url2
)
self
.
assertNotEqual
(
None
,
computer_absolute_url2
)
self
.
assertNotEqual
(
None
,
computer_reference2
)
# check that computers are really different objects
self
.
assertNotEqual
(
computer_url2
,
computer_url
)
# check that title is ok
computer2
=
person
.
restrictedTraverse
(
computer_url2
)
self
.
assertEqual
(
computer_title2
,
computer2
.
getTitle
())
# check that data are sane
self
.
assertEqual
(
computer_absolute_url2
,
computer2
.
absolute_url
())
self
.
assertEqual
(
computer_reference2
,
computer2
.
getReference
())
self
.
assertEqual
(
'COMP-%s'
%
(
previous_id
+
2
),
computer2
.
getReference
())
self
.
assertEqual
(
'validated'
,
computer2
.
getValidationState
())
self
.
assertEqual
(
'open/personal'
,
computer2
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
computer2
.
getCapacityScope
())
def
test_request_duplicatedComputer
(
self
):
person
=
self
.
getPortalObject
().
ERP5Site_getAuthenticatedMemberPersonValue
()
computer_title
=
self
.
generateNewComputerTitle
()
person
.
requestComputer
(
computer_title
=
computer_title
)
# check what is returned via request
computer_url
=
person
.
REQUEST
.
get
(
'computer'
)
computer_absolute_url
=
person
.
REQUEST
.
get
(
'computer_url'
)
computer_reference
=
person
.
REQUEST
.
get
(
'computer_reference'
)
self
.
assertNotEqual
(
None
,
computer_url
)
self
.
assertNotEqual
(
None
,
computer_absolute_url
)
self
.
assertNotEqual
(
None
,
computer_reference
)
# check that title is ok
computer
=
person
.
restrictedTraverse
(
computer_url
)
sm
=
getSecurityManager
()
try
:
self
.
login
()
computer2
=
computer
.
Base_createCloneDocument
(
batch_mode
=
1
)
computer2
.
validate
()
finally
:
setSecurityManager
(
sm
)
self
.
tic
()
self
.
assertRaises
(
NotImplementedError
,
person
.
requestComputer
,
computer_title
=
computer_title
)
master/bt5/slapos_cloud/bt/revision
View file @
ab3cee7d
177
\ No newline at end of file
178
\ No newline at end of file
master/bt5/slapos_cloud/bt/template_test_id_list
View file @
ab3cee7d
testSlapOSCorePersonComputerSupply
testSlapOSCorePersonRequest
testSlapOSCorePersonRequestComputer
testSlapOSShadow
testSlapOSCoreAllocation
testSlapOSCoreComputerSlapInterfaceWorkflow
testSlapOSCoreComputerPartitionSlapInterfaceWorkflow
testSlapOSCoreInstanceSlapInterfaceWorkflow
testSlapOSCorePersonSlapInterfaceWorkflow
\ 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