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
Ophélie Gagnard
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, \
...
@@ -14,30 +14,47 @@ from AccessControl.SecurityManagement import getSecurityManager, \
from
DateTime
import
DateTime
from
DateTime
import
DateTime
import
json
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
joinSlapOS
(
self
,
web_site
,
reference
):
def
findMessage
(
email
,
body
):
def
findMessage
(
email
,
body
):
for
candidate
in
reversed
(
self
.
portal
.
MailHost
.
getMessageList
()):
for
candidate
in
reversed
(
self
.
portal
.
MailHost
.
getMessageList
()):
if
[
q
for
q
in
candidate
[
1
]
if
email
in
q
]
and
body
in
candidate
[
2
]:
if
[
q
for
q
in
candidate
[
1
]
if
email
in
q
]
and
body
in
candidate
[
2
]:
return
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
'
expected_message
=
'You will receive a confirmation email to activate your account.
'
#
self.assertTrue(expected_message in credential_request_form,
self
.
assertTrue
(
expected_message
in
credential_request_form
,
#
'%s not in %s' % (expected_message, credential_request_form))
'%s not in %s'
%
(
expected_message
,
credential_request_form
))
email
=
'%s@example.com'
%
reference
email
=
'%s@example.com'
%
reference
request
=
web_site
.
ERP5Site
_newCredentialRequest
(
request
=
self
.
web_site
.
hateoas
.
connection
.
WebSection
_newCredentialRequest
(
reference
=
reference
,
reference
=
reference
,
first_name
=
'Joe'
,
default_email_text
=
email
,
first_name
=
"Joe"
,
last_name
=
reference
,
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'
self
.
assertTrue
(
'Thanks for your registration. You will be receive an email to activate your account.'
in
request
,
request
)
'0receive%20an%20email%20to%20activate%20your%20account.'
in
request
)
self
.
tic
()
self
.
tic
()
...
@@ -50,7 +67,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -50,7 +67,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self
.
assertTrue
(
'ERP5Site_activeLogin'
in
to_click_url
)
self
.
assertTrue
(
'ERP5Site_activeLogin'
in
to_click_url
)
join_key
=
to_click_url
.
split
(
'='
)[
-
1
]
join_key
=
to_click_url
.
split
(
'='
)[
-
1
]
self
.
assertNotEqual
(
join_key
,
None
)
web_site
.
ERP5Site_activeLogin
(
key
=
join_key
)
web_site
.
ERP5Site_activeLogin
(
key
=
join_key
)
self
.
tic
()
self
.
tic
()
...
@@ -58,6 +75,19 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -58,6 +75,19 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
welcome_message
=
findMessage
(
email
,
"the creation of you new ERP5 account"
)
welcome_message
=
findMessage
(
email
,
"the creation of you new ERP5 account"
)
self
.
assertNotEqual
(
None
,
welcome_message
)
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
):
def
requestComputer
(
self
,
title
):
requestXml
=
self
.
portal
.
portal_slap
.
requestComputer
(
title
)
requestXml
=
self
.
portal
.
portal_slap
.
requestComputer
(
title
)
self
.
tic
()
self
.
tic
()
...
@@ -83,38 +113,44 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -83,38 +113,44 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
else
:
else
:
self
.
assertEqual
(
'destroy_requested'
,
software_installation
.
getSlapState
())
self
.
assertEqual
(
'destroy_requested'
,
software_installation
.
getSlapState
())
@
changeSkin
(
'
Hosting
'
)
@
changeSkin
(
'
RJS
'
)
def
setServerOpenPublic
(
self
,
server
):
def
setServerOpenPublic
(
self
,
server
):
server
.
Computer_updateAllocationScope
(
server
.
edit
(
allocation_scope
=
'open/public'
,
subject_list
=
[]
)
allocation_scope
=
'open/public'
)
self
.
assertEqual
(
'open/public'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'open/public'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'close'
,
server
.
getCapacityScope
())
self
.
assertEqual
(
'close'
,
server
.
getCapacityScope
())
server
.
edit
(
capacity_scope
=
'open'
)
server
.
edit
(
capacity_scope
=
'open'
)
self
.
tic
()
self
.
tic
()
@
changeSkin
(
'
Hosting
'
)
@
changeSkin
(
'
RJS
'
)
def
setServerOpenPersonal
(
self
,
server
):
def
setServerOpenPersonal
(
self
,
server
):
server
.
Computer_updateAllocationScope
(
server
.
edit
(
allocation_scope
=
'open/personal'
,
subject_list
=
[])
allocation_scope
=
'open/personal'
,
subject_list
=
[])
self
.
assertEqual
(
'open/personal'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'open/personal'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
tic
()
self
.
tic
()
@
changeSkin
(
'
Hosting
'
)
@
changeSkin
(
'
RJS
'
)
def
setServerOpenFriend
(
self
,
server
,
friend_list
=
None
):
def
setServerOpenFriend
(
self
,
server
,
friend_list
=
None
):
if
friend_list
is
None
:
if
friend_list
is
None
:
friend_list
=
[]
friend_list
=
[]
server
.
Computer_updateAllocationScope
(
server
.
edit
(
allocation_scope
=
'open/friend'
,
subject_list
=
friend_list
)
allocation_scope
=
'open/friend'
,
subject_list
=
friend_list
)
self
.
assertEqual
(
'open/friend'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'open/friend'
,
server
.
getAllocationScope
())
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
assertEqual
(
'open'
,
server
.
getCapacityScope
())
self
.
assertSameSet
(
friend_list
,
server
.
getSubjectList
())
self
.
assertSameSet
(
friend_list
,
server
.
getSubjectList
())
self
.
tic
()
self
.
tic
()
@
changeSkin
(
'Hosting'
)
def
_getCurrentHostingSubscriptionList
(
self
):
def
WebSection_getCurrentHostingSubscriptionList
(
self
):
person
=
self
.
portal
.
ERP5Site_getAuthenticatedMemberPersonValue
()
return
self
.
web_site
.
hosting
.
myspace
.
my_services
\
.
WebSection_getCurrentHostingSubscriptionList
()
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
):
def
formatComputer
(
self
,
computer
,
partition_count
=
10
):
computer_dict
=
dict
(
computer_dict
=
dict
(
...
@@ -287,7 +323,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -287,7 +323,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# let's find instances of user and check connection strings
# let's find instances of user and check connection strings
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
self
.
WebSection
_getCurrentHostingSubscriptionList
()
self
.
_getCurrentHostingSubscriptionList
()
if
q
.
getTitle
()
==
instance_title
]
if
q
.
getTitle
()
==
instance_title
]
self
.
assertEqual
(
1
,
len
(
hosting_subscription_list
))
self
.
assertEqual
(
1
,
len
(
hosting_subscription_list
))
hosting_subscription
=
hosting_subscription_list
[
0
]
hosting_subscription
=
hosting_subscription_list
[
0
]
...
@@ -320,7 +356,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -320,7 +356,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# let's find instances of user and check connection strings
# let's find instances of user and check connection strings
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
self
.
WebSection
_getCurrentHostingSubscriptionList
()
self
.
_getCurrentHostingSubscriptionList
()
if
q
.
getTitle
()
==
instance_title
]
if
q
.
getTitle
()
==
instance_title
]
self
.
assertEqual
(
0
,
len
(
hosting_subscription_list
))
self
.
assertEqual
(
0
,
len
(
hosting_subscription_list
))
...
@@ -342,7 +378,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -342,7 +378,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# let's find instances of user and check connection strings
# let's find instances of user and check connection strings
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
self
.
WebSection
_getCurrentHostingSubscriptionList
()
self
.
_getCurrentHostingSubscriptionList
()
if
q
.
getTitle
()
==
instance_title
]
if
q
.
getTitle
()
==
instance_title
]
self
.
assertEqual
(
0
,
len
(
hosting_subscription_list
))
self
.
assertEqual
(
0
,
len
(
hosting_subscription_list
))
...
@@ -446,7 +482,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -446,7 +482,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# let's find instances of user and check connection strings
# let's find instances of user and check connection strings
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
hosting_subscription_list
=
[
q
.
getObject
()
for
q
in
self
.
WebSection
_getCurrentHostingSubscriptionList
()
self
.
_getCurrentHostingSubscriptionList
()
if
q
.
getTitle
()
==
instance_title
]
if
q
.
getTitle
()
==
instance_title
]
self
.
assertEqual
(
1
,
len
(
hosting_subscription_list
))
self
.
assertEqual
(
1
,
len
(
hosting_subscription_list
))
hosting_subscription
=
hosting_subscription_list
[
0
]
hosting_subscription
=
hosting_subscription_list
[
0
]
...
@@ -469,6 +505,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -469,6 +505,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
# is covered by unit tests
# is covered by unit tests
packing_list_line_list
=
subscription
.
getAggregateRelatedValueList
(
packing_list_line_list
=
subscription
.
getAggregateRelatedValueList
(
portal_type
=
'Sale Packing List Line'
)
portal_type
=
'Sale Packing List Line'
)
if
len
(
packing_list_line_list
)
<
2
:
raise
ValueError
(
subscription
)
self
.
assertTrue
(
len
(
packing_list_line_list
)
>=
2
)
self
.
assertTrue
(
len
(
packing_list_line_list
)
>=
2
)
for
packing_list_line
in
packing_list_line_list
:
for
packing_list_line
in
packing_list_line_list
:
packing_list
=
packing_list_line
.
getParentValue
()
packing_list
=
packing_list_line
.
getParentValue
()
...
@@ -572,15 +610,15 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -572,15 +610,15 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
portal_type
=
'Open Sale Order Line'
)
portal_type
=
'Open Sale Order Line'
)
self
.
assertEqual
(
len
(
line_list
),
0
)
self
.
assertEqual
(
len
(
line_list
),
0
)
@
changeSkin
(
'
Hosting
'
)
@
changeSkin
(
'
RJS
'
)
def
usePayzenManually
(
self
,
web_site
,
user_reference
):
def
usePayzenManually
(
self
,
web_site
,
user_reference
):
# No more acknowledgment
# No more acknowledgment
acknowledgement_json
=
\
#
acknowledgement_json = \
web_site
.
AcknowledgementTool_getUserUnreadAcknowledgementJSON
()
#
web_site.AcknowledgementTool_getUserUnreadAcknowledgementJSON()
acknowledgement_dict
=
json
.
loads
(
acknowledgement_json
)
#
acknowledgement_dict = json.loads(acknowledgement_json)
self
.
assertTrue
(
'result'
in
acknowledgement_dict
,
"%s"
%
acknowledgement_dict
)
#
self.assertTrue('result' in acknowledgement_dict, "%s" % acknowledgement_dict)
message_list
=
acknowledgement_dict
[
'result'
]
#
message_list = acknowledgement_dict['result']
self
.
assertEquals
(
len
(
message_list
),
0
,
"%s"
%
message_list
)
#
self.assertEquals(len(message_list), 0, "%s" % message_list)
# User received an email for payment
# User received an email for payment
email
=
'%s@example.com'
%
user_reference
email
=
'%s@example.com'
%
user_reference
...
@@ -603,7 +641,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -603,7 +641,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
def
test_default_scenario
(
self
):
def
test_default_scenario
(
self
):
# some preparation
# some preparation
self
.
logout
()
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
# lets join as owner, which will own few computers
owner_reference
=
'owner-%s'
%
self
.
generateNewId
()
owner_reference
=
'owner-%s'
%
self
.
generateNewId
()
...
@@ -653,6 +691,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -653,6 +691,7 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self
.
formatComputer
(
personal_server
)
self
.
formatComputer
(
personal_server
)
self
.
formatComputer
(
friend_server
)
self
.
formatComputer
(
friend_server
)
# join as the another visitor and request software instance on public
# join as the another visitor and request software instance on public
# computer
# computer
self
.
logout
()
self
.
logout
()
...
@@ -762,7 +801,6 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -762,7 +801,6 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self
.
assertOpenSaleOrderCoverage
(
public_reference
)
self
.
assertOpenSaleOrderCoverage
(
public_reference
)
# generate simulation for open order
# generate simulation for open order
self
.
stepCallUpdateOpenOrderSimulationAlarm
()
self
.
stepCallUpdateOpenOrderSimulationAlarm
()
self
.
tic
()
self
.
tic
()
...
@@ -858,53 +896,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
...
@@ -858,53 +896,8 @@ class TestSlapOSDefaultScenario(TestSlapOSSecurityMixin):
self
.
login
(
friend_person
.
getUserId
())
self
.
login
(
friend_person
.
getUserId
())
self
.
usePayzenManually
(
self
.
web_site
,
friend_reference
)
self
.
usePayzenManually
(
self
.
web_site
,
friend_reference
)
class
TestSlapOSDefaultCRMEscalation
(
TestSlapOSSecurityMixin
):
class
TestSlapOSDefaultCRMEscalation
(
DefaultScenarioMixin
):
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
)
@
changeSkin
(
'Hosting'
)
def
WebSection_getCurrentHostingSubscriptionList
(
self
):
return
self
.
web_site
.
hosting
.
myspace
.
my_services
\
.
WebSection_getCurrentHostingSubscriptionList
()
def
personRequestInstanceNotReady
(
self
,
**
kw
):
def
personRequestInstanceNotReady
(
self
,
**
kw
):
response
=
self
.
portal
.
portal_slap
.
requestComputerPartition
(
**
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 @@
...
@@ -46,8 +46,7 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<value>
<tuple>
<tuple>
<string>
W: 24, 4: Unused variable \'credential_request_form\' (unused-variable)
</string>
<string>
W: 15, 0: Unused import json (unused-import)
</string>
<string>
W:867, 4: Unused variable \'credential_request_form\' (unused-variable)
</string>
</tuple>
</tuple>
</value>
</value>
</item>
</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