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
Titouan Soulard
slapos.core
Commits
a98f4acd
Commit
a98f4acd
authored
Sep 02, 2020
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: Allow skip Payment if the user has a acceptable contract
parent
9dddb882
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
39 deletions
+67
-39
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_testPaymentBalance.py
...ription_request/SubscriptionRequest_testPaymentBalance.py
+19
-4
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionScenario.py
...al_components/test.erp5.testSlapOSSubscriptionScenario.py
+48
-35
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_testPaymentBalance.py
View file @
a98f4acd
portal
=
context
.
getPortalObject
()
payment
=
context
.
SubscriptionRequest_verifyPaymentBalanceIsReady
()
payment
=
context
.
SubscriptionRequest_verifyPaymentBalanceIsReady
()
if
payment
is
not
None
and
payment
.
getSimulationState
()
in
[
'stopped'
,
'deliveried'
]:
# Payment Transaction is payed
return
True
# Payment Transaction ins't payed
if
payment
is
not
None
:
if
payment
.
getSimulationState
()
in
[
'stopped'
,
'deliveried'
]:
# Payment Transaction is payed
return
True
person
=
context
.
getDestinationSectionValue
()
contract
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
"Cloud Contract"
,
default_destination_section_uid
=
person
.
getUid
(),
validation_state
=
[
'invalidated'
,
'validated'
],
)
if
(
contract
is
not
None
and
contract
.
getMaximumInvoiceDelay
()
>
0
and
\
not
(
person
.
Entity_statSlapOSOutstandingAmount
()
>
0
)):
return
True
# Payment Transaction isn't payed
return
False
return
False
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionScenario.py
View file @
a98f4acd
...
@@ -235,30 +235,37 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -235,30 +235,37 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
payment
=
invoice
.
getCausalityRelatedValue
(
portal_type
=
"Payment Transaction"
)
payment
=
invoice
.
getCausalityRelatedValue
(
portal_type
=
"Payment Transaction"
)
self
.
assertNotEqual
(
payment
,
None
)
self
.
assertNotEqual
(
payment
,
None
)
def
checkPlannedSubscriptionRequest
(
self
,
subscription_request
,
email
,
subscription_condition
,
slave
=
0
):
def
checkPlannedSubscriptionRequest
(
self
,
subscription_request
,
email
,
self
.
checkSubscriptionRequest
(
subscription_request
,
email
,
subscription_condition
,
slave
=
slave
)
subscription_condition
,
slave
=
0
):
self
.
checkSubscriptionRequest
(
subscription_request
,
email
,
subscription_condition
,
slave
=
slave
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"planned"
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"planned"
)
def
checkOrderedSubscriptionRequest
(
self
,
subscription_request
,
email
,
def
checkOrderedSubscriptionRequest
(
self
,
subscription_request
,
email
,
subscription_condition
,
slave
=
0
,
subscription_condition
,
slave
=
0
,
notification_message
=
"subscription_request-confirmation-with-password"
):
notification_message
=
"subscription_request-confirmation-with-password"
):
self
.
checkSubscriptionRequest
(
subscription_request
,
email
,
subscription_condition
,
slave
=
slave
)
self
.
checkSubscriptionRequest
(
subscription_request
,
email
,
subscription_condition
,
slave
=
slave
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"ordered"
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"ordered"
)
self
.
checkBootstrapUser
(
subscription_request
)
self
.
checkBootstrapUser
(
subscription_request
)
self
.
checkEmailNotification
(
subscription_request
,
notification_message
)
self
.
checkEmailNotification
(
subscription_request
,
notification_message
)
def
checkConfirmedSubscriptionRequest
(
self
,
subscription_request
,
email
,
subscription_condition
,
slave
=
0
,
def
checkConfirmedSubscriptionRequest
(
self
,
subscription_request
,
email
,
notification_message
=
"subscription_request-payment-is-ready"
):
subscription_condition
,
slave
=
0
,
self
.
checkSubscriptionRequest
(
subscription_request
,
email
,
subscription_condition
,
slave
=
slave
)
notification_message
=
"subscription_request-payment-is-ready"
):
self
.
checkSubscriptionRequest
(
subscription_request
,
email
,
subscription_condition
,
slave
=
slave
)
payment
=
subscription_request
.
SubscriptionRequest_verifyPaymentBalanceIsReady
()
payment
=
subscription_request
.
SubscriptionRequest_verifyPaymentBalanceIsReady
()
self
.
assertNotEqual
(
payment
,
None
)
self
.
assertNotEqual
(
payment
,
None
)
self
.
assertEqual
(
payment
.
getSimulationState
(),
'started'
)
self
.
assertEqual
(
payment
.
getSimulationState
(),
'started'
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"confirmed"
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"confirmed"
)
self
.
checkEmailPaymentNotification
(
subscription_request
,
notification_message
)
self
.
checkEmailPaymentNotification
(
subscription_request
,
notification_message
)
def
checkStartedSubscriptionRequest
(
self
,
subscription_request
,
email
,
subscription_condition
,
slave
=
0
,
def
checkStartedSubscriptionRequest
(
self
,
subscription_request
,
email
,
notification_message
=
"subscription_request-instance-is-ready"
):
subscription_condition
,
slave
=
0
,
self
.
checkSubscriptionRequest
(
subscription_request
,
email
,
subscription_condition
,
slave
=
slave
)
notification_message
=
"subscription_request-instance-is-ready"
):
self
.
checkSubscriptionRequest
(
subscription_request
,
email
,
subscription_condition
,
slave
=
slave
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"started"
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"started"
)
self
.
checkEmailInstanceNotification
(
subscription_request
,
notification_message
)
self
.
checkEmailInstanceNotification
(
subscription_request
,
notification_message
)
...
@@ -301,7 +308,8 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -301,7 +308,8 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
authAmount
=
(
int
(
self
.
expected_individual_price_with_tax
*
100
)
*
1
-
int
(
self
.
expected_reservation_fee
*
100
))
*
quantity
authAmount
=
(
int
(
self
.
expected_individual_price_with_tax
*
100
)
*
1
-
int
(
self
.
expected_reservation_fee
*
100
))
*
quantity
self
.
assertEqual
(
payment
.
getSourceSection
(),
self
.
expected_source_section
)
self
.
assertEqual
(
payment
.
getSourceSection
(),
self
.
expected_source_section
)
self
.
assertEqual
(
payment
.
getSourcePayment
(),
"%s/bank_account"
%
self
.
expected_source_section
)
self
.
assertEqual
(
payment
.
getSourcePayment
(),
"%s/bank_account"
%
self
.
expected_source_section
)
self
.
assertEqual
(
int
(
payment
.
PaymentTransaction_getTotalPayablePrice
()
*
100
),
self
.
assertEqual
(
int
(
payment
.
PaymentTransaction_getTotalPayablePrice
()
*
100
),
...
@@ -373,7 +381,8 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -373,7 +381,8 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
# Check Payment
# Check Payment
self
.
assertEqual
(
payment
.
getSourceSection
(),
self
.
expected_source_section
)
self
.
assertEqual
(
payment
.
getSourceSection
(),
self
.
expected_source_section
)
self
.
assertEqual
(
payment
.
getSourcePayment
(),
"%s/bank_account"
%
self
.
expected_source_section
)
self
.
assertEqual
(
payment
.
getSourcePayment
(),
"%s/bank_account"
%
self
.
expected_source_section
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
payment
.
getSimulationState
(),
"stopped"
)
self
.
assertEqual
(
payment
.
getSimulationState
(),
"stopped"
)
...
@@ -411,8 +420,10 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -411,8 +420,10 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self
.
assertEqual
(
line
.
getQuantity
(),
quantity
)
self
.
assertEqual
(
line
.
getQuantity
(),
quantity
)
self
.
assertEqual
(
round
(
line
.
getPrice
(),
2
),
self
.
expected_reservation_fee_without_tax
)
self
.
assertEqual
(
round
(
line
.
getPrice
(),
2
),
self
.
expected_reservation_fee_without_tax
)
if
line
.
getResource
()
==
"service_module/slapos_tax"
:
if
line
.
getResource
()
==
"service_module/slapos_tax"
:
self
.
assertEqual
(
round
(
line
.
getQuantity
(),
2
),
round
(
self
.
expected_reservation_quantity_tax
*
quantity
,
2
))
self
.
assertEqual
(
round
(
line
.
getQuantity
(),
2
),
self
.
assertEqual
(
round
(
line
.
getTotalPrice
(),
2
),
round
(
self
.
expected_reservation_tax
*
quantity
,
2
))
round
(
self
.
expected_reservation_quantity_tax
*
quantity
,
2
))
self
.
assertEqual
(
round
(
line
.
getTotalPrice
(),
2
),
round
(
self
.
expected_reservation_tax
*
quantity
,
2
))
self
.
assertEqual
(
round
(
invoice
.
getTotalPrice
(),
2
),
self
.
expected_reservation_fee
*
quantity
)
self
.
assertEqual
(
round
(
invoice
.
getTotalPrice
(),
2
),
self
.
expected_reservation_fee
*
quantity
)
...
@@ -836,14 +847,23 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -836,14 +847,23 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
# Instances should be allocated
# Instances should be allocated
self
.
checkAllocationOnRelatedInstance
(
subscription_request
)
self
.
checkAllocationOnRelatedInstance
(
subscription_request
)
if
not
self
.
expected_free_reservation
:
# In a scenario where invitation token is used, we expect
# that this script outputs True as user is below the maximum limit.
expected_test_payment_balance
=
False
expected_slap_state_after_subscription_is_confirmed
=
'stop_requested'
else
:
expected_test_payment_balance
=
True
expected_slap_state_after_subscription_is_confirmed
=
'start_requested'
# Check if instance is on confirmed state
# Check if instance is on confirmed state
for
subscription_request
in
subscription_request_list
:
for
subscription_request
in
subscription_request_list
:
self
.
checkConfirmedSubscriptionRequest
(
subscription_request
,
self
.
checkConfirmedSubscriptionRequest
(
subscription_request
,
default_email_text
,
self
.
subscription_condition
)
default_email_text
,
self
.
subscription_condition
)
# Assert that First month isn't payed
self
.
assertEqual
(
expected_test_payment_balance
,
self
.
assertFalse
(
subscription_request
.
SubscriptionRequest_testPaymentBalance
())
subscription_request
.
SubscriptionRequest_testPaymentBalance
())
self
.
assertEquals
(
'start_requested'
,
self
.
assertEquals
(
'start_requested'
,
subscription_request
.
getAggregateValue
().
getSlapState
())
subscription_request
.
getAggregateValue
().
getSlapState
())
...
@@ -853,10 +873,10 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -853,10 +873,10 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self
.
tic
()
self
.
tic
()
for
subscription_request
in
subscription_request_list
:
for
subscription_request
in
subscription_request_list
:
self
.
assert
False
(
self
.
assert
Equal
(
expected_test_payment_balance
,
subscription_request
.
SubscriptionRequest_testPaymentBalance
())
subscription_request
.
SubscriptionRequest_testPaymentBalance
())
self
.
assertEquals
(
'stop_requested'
,
self
.
assertEquals
(
expected_slap_state_after_subscription_is_confirmed
,
subscription_request
.
getAggregateValue
().
getSlapState
())
subscription_request
.
getAggregateValue
().
getSlapState
())
def
checkSubscriptionDeploymentAndSimulationWithReversalTransaction
(
self
,
default_email_text
,
subscription_server
):
def
checkSubscriptionDeploymentAndSimulationWithReversalTransaction
(
self
,
default_email_text
,
subscription_server
):
...
@@ -882,10 +902,6 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -882,10 +902,6 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self
.
assertEqual
(
'start_requested'
,
self
.
assertEqual
(
'start_requested'
,
subscription_request
.
getAggregateValue
().
getSlapState
())
subscription_request
.
getAggregateValue
().
getSlapState
())
# It is requireds a second interaction so the instance is
# correctly started
self
.
assertEqual
(
"confirmed"
,
subscription_request
.
getSimulationState
())
# On the second loop that email is send and state is moved to started
# On the second loop that email is send and state is moved to started
self
.
stepCallSlaposSubscriptionRequestProcessConfirmedAlarm
()
self
.
stepCallSlaposSubscriptionRequestProcessConfirmedAlarm
()
self
.
tic
()
self
.
tic
()
...
@@ -907,9 +923,10 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -907,9 +923,10 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self
.
_checkSubscriptionDeploymentAndSimulation
(
self
.
_checkSubscriptionDeploymentAndSimulation
(
subscription_request_list
,
default_email_text
,
subscription_server
)
subscription_request_list
,
default_email_text
,
subscription_server
)
for
subscription_request
in
subscription_request_list
:
if
not
self
.
expected_free_reservation
:
self
.
checkAndPayFirstMonth
(
subscription_request
)
for
subscription_request
in
subscription_request_list
:
self
.
tic
()
self
.
checkAndPayFirstMonth
(
subscription_request
)
self
.
tic
()
self
.
stepCallSlaposSubscriptionRequestProcessConfirmedAlarm
()
self
.
stepCallSlaposSubscriptionRequestProcessConfirmedAlarm
()
self
.
tic
()
self
.
tic
()
...
@@ -921,10 +938,6 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
...
@@ -921,10 +938,6 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self
.
assertEqual
(
'start_requested'
,
self
.
assertEqual
(
'start_requested'
,
subscription_request
.
getAggregateValue
().
getSlapState
())
subscription_request
.
getAggregateValue
().
getSlapState
())
# It is requireds a second interaction so the instance is
# correctly started
self
.
assertEqual
(
"confirmed"
,
subscription_request
.
getSimulationState
())
# On the second loop that email is send and state is moved to started
# On the second loop that email is send and state is moved to started
self
.
stepCallSlaposSubscriptionRequestProcessConfirmedAlarm
()
self
.
stepCallSlaposSubscriptionRequestProcessConfirmedAlarm
()
self
.
tic
()
self
.
tic
()
...
...
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