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
Paul Graydon
slapos.core
Commits
12242b8e
Commit
12242b8e
authored
Apr 13, 2018
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_erp5: Update testSlapOSERP5DefaultScenario
Still WIP
parent
6a016d05
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
83 deletions
+75
-83
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5DefaultScenario.py
...tal_components/test.erp5.testSlapOSERP5DefaultScenario.py
+74
-81
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5DefaultScenario.xml
...al_components/test.erp5.testSlapOSERP5DefaultScenario.xml
+1
-2
No files found.
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5DefaultScenario.py
View file @
12242b8e
...
...
@@ -14,30 +14,47 @@ from AccessControl.SecurityManagement import getSecurityManager, \
from
DateTime
import
DateTime
import
json
class
TestSlapOSDefaultScenario
(
TestSlapOSSecurityMixin
):
class
DefaultScenarioMixin
(
TestSlapOSSecurityMixin
):
def
afterSetUp
(
self
):
TestSlapOSSecurityMixin
.
afterSetUp
(
self
)
preference
=
self
.
portal
.
portal_preferences
.
getActiveSystemPreference
()
preference
.
edit
(
preferred_credential_alarm_automatic_call
=
0
,
preferred_credential_recovery_automatic_approval
=
0
,
preferred_credential_request_automatic_approval
=
1
)
@
changeSkin
(
'Hal'
)
def
joinSlapOS
(
self
,
web_site
,
reference
):
def
findMessage
(
email
,
body
):
for
candidate
in
reversed
(
self
.
portal
.
MailHost
.
getMessageList
()):
if
[
q
for
q
in
candidate
[
1
]
if
email
in
q
]
and
body
in
candidate
[
2
]:
return
candidate
[
2
]
credential_request_form
=
self
.
web_site
.
ERP5Site_viewCredentialRequestF
orm
()
credential_request_form
=
self
.
web_site
.
hateoas
.
connection
.
join_f
orm
()
#expected_message = 'Vifib Cloud is a distributed cloud around the
'
#
self.assertTrue(expected_message in credential_request_form,
#
'%s not in %s' % (expected_message, credential_request_form))
expected_message
=
'You will receive a confirmation email to activate your account.
'
self
.
assertTrue
(
expected_message
in
credential_request_form
,
'%s not in %s'
%
(
expected_message
,
credential_request_form
))
email
=
'%s@example.com'
%
reference
request
=
web_site
.
ERP5Site
_newCredentialRequest
(
request
=
self
.
web_site
.
hateoas
.
connection
.
WebSection
_newCredentialRequest
(
reference
=
reference
,
first_name
=
'Joe'
,
default_email_text
=
email
,
first_name
=
"Joe"
,
last_name
=
reference
,
default_email_text
=
email
password
=
"demo_functional_user"
,
default_telephone_text
=
"12345678"
,
corporate_name
=
"Nexedi"
,
default_address_city
=
"Campos"
,
default_address_street_address
=
"Av Pelinca"
,
default_address_zip_code
=
"28480"
,
)
self
.
assertTrue
(
'Thanks%20for%20your%20registration.%20You%20will%20be%2'
'0receive%20an%20email%20to%20activate%20your%20account.'
in
request
)
self
.
assertTrue
(
'Thanks for your registration. You will be receive an email to activate your account.'
in
request
,
request
)
self
.
tic
()
...
...
@@ -50,7 +67,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self
.
assertTrue
(
'ERP5Site_activeLogin'
in
to_click_url
)
join_key
=
to_click_url
.
split
(
'='
)[
-
1
]
self
.
assertNotEqual
(
join_key
,
None
)
web_site
.
ERP5Site_activeLogin
(
key
=
join_key
)
self
.
tic
()
...
...
@@ -58,6 +75,19 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
welcome_message
=
findMessage
(
email
,
"the creation of you new ERP5 account"
)
self
.
assertNotEqual
(
None
,
welcome_message
)
def
_getCurrentHostingSubscriptionList
(
self
):
person
=
self
.
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
()
if
person
is
not
None
:
return
self
.
portal
.
portal_catalog
(
portal_type
=
"Hosting Subscription"
,
default_destination_section_uid
=
person
.
getUid
(),
validation_state
=
'validated'
)
return
[]
class
TestSlapOSDefaultScenario
(
DefaultScenarioMixin
):
def
requestComputer
(
self
,
title
):
requestXml
=
self
.
portal
.
portal_slap
.
requestComputer
(
title
)
self
.
tic
()
...
...
@@ -83,38 +113,44 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
else
:
self
.
assertEqual
(
'destroy_requested'
,
software_installation
.
getSlapState
())
@
changeSkin
(
'
Hosting
'
)
@
changeSkin
(
'
RJS
'
)
def
setServerOpenPublic
(
self
,
server
):
server
.
Computer_updateAllocationScope
(
allocation_scope
=
'open/public'
,
subject_list
=
[]
)
server
.
edit
(
allocation_scope
=
'open/public'
)
self
.
assertEqual
(
'open/public'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'close'
,
server
.
getCapacityScope
())
server
.
edit
(
capacity_scope
=
'open'
)
self
.
tic
()
@
changeSkin
(
'
Hosting
'
)
@
changeSkin
(
'
RJS
'
)
def
setServerOpenPersonal
(
self
,
server
):
server
.
Computer_updateAllocationScope
(
server
.
edit
(
allocation_scope
=
'open/personal'
,
subject_list
=
[])
self
.
assertEqual
(
'open/personal'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
tic
()
@
changeSkin
(
'
Hosting
'
)
@
changeSkin
(
'
RJS
'
)
def
setServerOpenFriend
(
self
,
server
,
friend_list
=
None
):
if
friend_list
is
None
:
friend_list
=
[]
server
.
Computer_updateAllocationScope
(
server
.
edit
(
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
())
self
.
tic
()
@
changeSkin
(
'Hosting'
)
def
WebSection_getCurrentHostingSubscriptionList
(
self
):
return
self
.
web_site
.
hosting
.
myspace
.
my_services
\
.
WebSection_getCurrentHostingSubscriptionList
()
def
_getCurrentHostingSubscriptionList
(
self
):
person
=
self
.
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
()
if
person
is
not
None
:
return
self
.
portal
.
portal_catalog
(
portal_type
=
"Hosting Subscription"
,
default_destination_section_uid
=
person
.
getUid
(),
validation_state
=
'validated'
)
return
[]
def
formatComputer
(
self
,
computer
,
partition_count
=
10
):
computer_dict
=
dict
(
...
...
@@ -287,7 +323,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# let's find instances of user and check connection strings
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
self
.
WebSection
_getCurrentHostingSubscriptionList
()
self
.
_getCurrentHostingSubscriptionList
()
if
q
.
getTitle
()
==
instance_title
]
self
.
assertEqual
(
1
,
len
(
hosting_subscription_list
))
hosting_subscription
=
hosting_subscription_list
[
0
]
...
...
@@ -320,7 +356,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# let's find instances of user and check connection strings
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
self
.
WebSection
_getCurrentHostingSubscriptionList
()
self
.
_getCurrentHostingSubscriptionList
()
if
q
.
getTitle
()
==
instance_title
]
self
.
assertEqual
(
0
,
len
(
hosting_subscription_list
))
...
...
@@ -342,7 +378,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# let's find instances of user and check connection strings
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
self
.
WebSection
_getCurrentHostingSubscriptionList
()
self
.
_getCurrentHostingSubscriptionList
()
if
q
.
getTitle
()
==
instance_title
]
self
.
assertEqual
(
0
,
len
(
hosting_subscription_list
))
...
...
@@ -446,7 +482,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# let's find instances of user and check connection strings
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
self
.
WebSection
_getCurrentHostingSubscriptionList
()
self
.
_getCurrentHostingSubscriptionList
()
if
q
.
getTitle
()
==
instance_title
]
self
.
assertEqual
(
1
,
len
(
hosting_subscription_list
))
hosting_subscription
=
hosting_subscription_list
[
0
]
...
...
@@ -469,6 +505,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# is covered by unit tests
packing_list_line_list
=
subscription
.
getAggregateRelatedValueList
(
portal_type
=
'Sale Packing List Line'
)
if
len
(
packing_list_line_list
)
<
2
:
raise
ValueError
(
subscription
)
self
.
assertTrue
(
len
(
packing_list_line_list
)
>=
2
)
for
packing_list_line
in
packing_list_line_list
:
packing_list
=
packing_list_line
.
getParentValue
()
...
...
@@ -572,15 +610,15 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
portal_type
=
'Open Sale Order Line'
)
self
.
assertEqual
(
len
(
line_list
),
0
)
@
changeSkin
(
'
Hosting
'
)
@
changeSkin
(
'
RJS
'
)
def
usePayzenManually
(
self
,
web_site
,
user_reference
):
# No more acknowledgment
acknowledgement_json
=
\
web_site
.
AcknowledgementTool_getUserUnreadAcknowledgementJSON
()
acknowledgement_dict
=
json
.
loads
(
acknowledgement_json
)
self
.
assertTrue
(
'result'
in
acknowledgement_dict
,
"%s"
%
acknowledgement_dict
)
message_list
=
acknowledgement_dict
[
'result'
]
self
.
assertEquals
(
len
(
message_list
),
0
,
"%s"
%
message_list
)
#
acknowledgement_json = \
#
web_site.AcknowledgementTool_getUserUnreadAcknowledgementJSON()
#
acknowledgement_dict = json.loads(acknowledgement_json)
#
self.assertTrue('result' in acknowledgement_dict, "%s" % acknowledgement_dict)
#
message_list = acknowledgement_dict['result']
#
self.assertEquals(len(message_list), 0, "%s" % message_list)
# User received an email for payment
email
=
'%s@example.com'
%
user_reference
...
...
@@ -603,7 +641,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
def
test_default_scenario
(
self
):
# some preparation
self
.
logout
()
self
.
web_site
=
self
.
portal
.
web_site_module
.
hosting
self
.
web_site
=
self
.
portal
.
web_site_module
.
hosting
js
# lets join as owner, which will own few computers
owner_reference
=
'owner-%s'
%
self
.
generateNewId
()
...
...
@@ -653,6 +691,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self
.
formatComputer
(
personal_server
)
self
.
formatComputer
(
friend_server
)
# join as the another visitor and request software instance on public
# computer
self
.
logout
()
...
...
@@ -762,7 +801,6 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self
.
assertOpenSaleOrderCoverage
(
public_reference
)
# generate simulation for open order
self
.
stepCallUpdateOpenOrderSimulationAlarm
()
self
.
tic
()
...
...
@@ -858,53 +896,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self
.
login
(
friend_person
.
getUserId
())
self
.
usePayzenManually
(
self
.
web_site
,
friend_reference
)
class
TestSlapOSDefaultCRMEscalation
(
TestSlapOSSecurityMixin
):
def
joinSlapOS
(
self
,
web_site
,
reference
):
def
findMessage
(
email
,
body
):
for
candidate
in
reversed
(
self
.
portal
.
MailHost
.
getMessageList
()):
if
[
q
for
q
in
candidate
[
1
]
if
email
in
q
]
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
,
first_name
=
'Joe'
,
last_name
=
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
,
"the creation of you new ERP5 account"
)
self
.
assertNotEqual
(
None
,
welcome_message
)
class
TestSlapOSDefaultCRMEscalation
(
DefaultScenarioMixin
):
@
changeSkin
(
'Hosting'
)
def
WebSection_getCurrentHostingSubscriptionList
(
self
):
return
self
.
web_site
.
hosting
.
myspace
.
my_services
\
.
WebSection_getCurrentHostingSubscriptionList
()
def
personRequestInstanceNotReady
(
self
,
**
kw
):
response
=
self
.
portal
.
portal_slap
.
requestComputerPartition
(
**
kw
)
...
...
master/bt5/slapos_erp5/TestTemplateItem/portal_components/test.erp5.testSlapOSERP5DefaultScenario.xml
View file @
12242b8e
...
...
@@ -46,8 +46,7 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W: 24, 4: Unused variable \'credential_request_form\' (unused-variable)
</string>
<string>
W:867, 4: Unused variable \'credential_request_form\' (unused-variable)
</string>
<string>
W: 15, 0: Unused import json (unused-import)
</string>
</tuple>
</value>
</item>
...
...
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