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
Carlos Ramos Carreño
slapos.core
Commits
cedc1dc7
Commit
cedc1dc7
authored
Nov 08, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initialise testing of default scenario.
parent
665ab6a5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
1 deletion
+138
-1
master/bt5/slapos_erp5/TestTemplateItem/testSlapOSDefaultScenario.py
...slapos_erp5/TestTemplateItem/testSlapOSDefaultScenario.py
+136
-0
master/bt5/slapos_erp5/bt/revision
master/bt5/slapos_erp5/bt/revision
+1
-1
master/bt5/slapos_erp5/bt/template_test_id_list
master/bt5/slapos_erp5/bt/template_test_id_list
+1
-0
No files found.
master/bt5/slapos_erp5/TestTemplateItem/testSlapOSDefaultScenario.py
0 → 100644
View file @
cedc1dc7
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.
#
##############################################################################
from
testSlapOSSecurityGroup
import
TestSlapOSSecurityMixin
import
re
from
xml_marshaller
import
xml_marshaller
def
changeSkin
(
skin_name
):
def
decorator
(
func
):
def
wrapped
(
self
,
*
args
,
**
kwargs
):
default_skin
=
self
.
portal
.
portal_skins
.
default_skin
self
.
portal
.
portal_skins
.
changeSkin
(
skin_name
)
self
.
app
.
REQUEST
.
set
(
'portal_skin'
,
skin_name
)
try
:
v
=
func
(
self
,
*
args
,
**
kwargs
)
finally
:
self
.
portal
.
portal_skins
.
changeSkin
(
default_skin
)
self
.
app
.
REQUEST
.
set
(
'portal_skin'
,
default_skin
)
return
v
return
wrapped
return
decorator
class
TestSlapOSDefaultScenario
(
TestSlapOSSecurityMixin
):
def
joinSlapOS
(
self
,
web_site
,
reference
):
def
findMessage
(
email
,
body
):
for
candidate
in
reversed
(
self
.
portal
.
MailHost
.
getMessageList
()):
if
email
in
candidate
[
1
]
\
and
body
in
candidate
[
2
]:
return
candidate
[
2
]
credential_request_form
=
self
.
web_site
.
ERP5Site_viewCredentialRequestForm
()
self
.
assertTrue
(
'Vifib Cloud is a distributed cloud around the'
in
credential_request_form
)
email
=
'%s@example.com'
%
reference
request
=
web_site
.
ERP5Site_newCredentialRequest
(
reference
=
reference
,
default_email_text
=
email
)
self
.
assertTrue
(
'Thanks%20for%20your%20registration.%20You%20will%20be%2'
'0receive%20an%20email%20to%20activate%20your%20account.'
in
request
)
self
.
tic
()
to_click_message
=
findMessage
(
email
,
'You have requested one user'
)
self
.
assertNotEqual
(
None
,
to_click_message
)
to_click_url
=
re
.
search
(
'href="(.+?)"'
,
to_click_message
).
group
(
1
)
self
.
assertTrue
(
'ERP5Site_activeLogin'
in
to_click_url
)
join_key
=
to_click_url
.
split
(
'='
)[
-
1
]
web_site
.
ERP5Site_activeLogin
(
key
=
join_key
)
self
.
tic
()
welcome_message
=
findMessage
(
email
,
"de votre nouveau compte ERP5"
)
self
.
assertNotEqual
(
None
,
welcome_message
)
def
addServerViaSlapTool
(
self
,
title
):
requestXml
=
self
.
portal
.
portal_slap
.
requestComputer
(
title
)
self
.
assertTrue
(
'marshal'
in
requestXml
)
computer
=
xml_marshaller
.
loads
(
requestXml
)
computer_id
=
getattr
(
computer
,
'_computer_id'
,
None
)
self
.
assertNotEqual
(
None
,
computer_id
)
self
.
tic
()
return
computer_id
@
changeSkin
(
'Hosting'
)
def
setServerOpenPublic
(
self
,
server
):
server
.
Computer_updateAllocationScope
(
allocation_scope
=
'open/public'
,
subject_list
=
[])
self
.
assertEqual
(
'open/public'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'close'
,
server
.
getCapacityScope
())
@
changeSkin
(
'Hosting'
)
def
setServerOpenPersonal
(
self
,
server
):
server
.
Computer_updateAllocationScope
(
allocation_scope
=
'open/personal'
,
subject_list
=
[])
self
.
assertEqual
(
'open/personal'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
@
changeSkin
(
'Hosting'
)
def
setServerOpenFriend
(
self
,
server
,
friend_list
=
None
):
if
friend_list
is
None
:
friend_list
=
[]
server
.
Computer_updateAllocationScope
(
allocation_scope
=
'open/friend'
,
subject_list
=
friend_list
)
self
.
assertEqual
(
'open/friend'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
assertSameSet
(
friend_list
,
server
.
getSubjectList
())
def
test
(
self
):
# some preparation
self
.
logout
()
self
.
web_site
=
self
.
portal
.
web_site_module
.
hosting
# lets join as owner, which will own few computers
owner_reference
=
'owner-%s'
%
self
.
generateNewId
()
self
.
joinSlapOS
(
self
.
web_site
,
owner_reference
)
# hooray, now it is time to create computers
self
.
login
(
owner_reference
)
public_server_title
=
'Public Server for %s'
%
owner_reference
public_server_id
=
self
.
addServerViaSlapTool
(
public_server_title
)
public_server
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Computer'
,
reference
=
public_server_id
)
self
.
assertNotEqual
(
None
,
public_server
)
self
.
setServerOpenPublic
(
public_server
)
personal_server_title
=
'Personal Server for %s'
%
owner_reference
personal_server_id
=
self
.
addServerViaSlapTool
(
personal_server_title
)
personal_server
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Computer'
,
reference
=
personal_server_id
)
self
.
assertNotEqual
(
None
,
personal_server
)
self
.
setServerOpenPersonal
(
personal_server
)
friend_server_title
=
'Friend Server for %s'
%
owner_reference
friend_server_id
=
self
.
addServerViaSlapTool
(
friend_server_title
)
friend_server
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Computer'
,
reference
=
friend_server_id
)
self
.
assertNotEqual
(
None
,
friend_server
)
self
.
setServerOpenFriend
(
friend_server
)
# remove the assertion after test is finished
self
.
assertTrue
(
False
,
'Test not finished'
)
master/bt5/slapos_erp5/bt/revision
View file @
cedc1dc7
67
68
\ No newline at end of file
\ No newline at end of file
master/bt5/slapos_erp5/bt/template_test_id_list
View file @
cedc1dc7
testSlapOSDefaultScenario
testSlapOSGroupRoleSecurity
testSlapOSGroupRoleSecurity
testSlapOSLocalPermissionSlapOSInteractionWorkflow
testSlapOSLocalPermissionSlapOSInteractionWorkflow
testSlapOSSkinSelection
testSlapOSSkinSelection
\ 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