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
Lu Xu
slapos.core
Commits
6bc6390a
Commit
6bc6390a
authored
Oct 23, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test internal implementation of Person.requestComputer
parent
3ddf7e69
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
222 additions
and
2 deletions
+222
-2
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCorePersonRequestComputer.py
...d/TestTemplateItem/testSlapOSCorePersonRequestComputer.py
+219
-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
-1
No files found.
master/bt5/slapos_cloud/TestTemplateItem/testSlapOSCorePersonRequestComputer.py
0 → 100644
View file @
6bc6390a
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
from
Products.SlapOS.tests.testSlapOSMixin
import
testSlapOSMixin
import
transaction
class
TestSlapOSCorePersonRequestComputer
(
testSlapOSMixin
):
def
generateNewId
(
self
):
return
self
.
getPortalObject
().
portal_ids
.
generateNewId
(
id_group
=
(
'slapos_core_test'
))
def
generateNewComputerTitle
(
self
):
return
'My Comp %s'
%
self
.
generateNewId
()
def
afterSetUp
(
self
):
portal
=
self
.
getPortalObject
()
new_id
=
self
.
generateNewId
()
self
.
setupPortalCertificateAuthority
()
# 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
.
updateLocalRolesOnSecurityGroups
()
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
)
computer2
=
computer
.
Base_createCloneDocument
(
batch_mode
=
1
)
computer2
.
validate
()
self
.
tic
()
self
.
assertRaises
(
NotImplementedError
,
person
.
requestComputer
,
computer_title
=
computer_title
)
master/bt5/slapos_cloud/bt/revision
View file @
6bc6390a
66
67
\ No newline at end of file
\ No newline at end of file
master/bt5/slapos_cloud/bt/template_test_id_list
View file @
6bc6390a
testSlapOSShadow
testSlapOSShadow
testSlapOSCorePersonRequest
testSlapOSCorePersonRequest
\ No newline at end of file
testSlapOSCorePersonRequestComputer
\ 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