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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
bddcaf92
Commit
bddcaf92
authored
May 12, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: drop SubscriptionRequest_processOrdered
parent
b204c4cd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
339 deletions
+0
-339
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_processOrdered.py
...ubscription_request/SubscriptionRequest_processOrdered.py
+0
-53
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_processOrdered.xml
...bscription_request/SubscriptionRequest_processOrdered.xml
+0
-62
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.py
...ortal_components/test.erp5.testSlapOSSubscriptionSkins.py
+0
-224
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_processOrdered.py
deleted
100644 → 0
View file @
b204c4cd
if
context
.
getSimulationState
()
!=
"ordered"
:
# Skip if the instance isn't ordered anymore
return
instance_tree
=
context
.
getAggregateValue
()
# Don't request again if it is already requested.
if
instance_tree
is
None
:
context
.
SubscriptionRequest_processRequest
()
# Don't perform everything on the same transaction
return
"Skipped (Instance Requested)"
if
instance_tree
is
not
None
:
if
instance_tree
.
getCausalityState
()
==
"diverged"
:
# Call it as soon as possible
subscription_condition
=
context
.
getSpecialiseValue
(
portal_type
=
'Subscription Condition'
)
trade_condition
=
subscription_condition
.
getSpecialiseValue
(
portal_type
=
'Sale Trade Condition'
)
if
trade_condition
is
None
:
return
'Skipped (No Trade Condition)'
instance_tree
.
InstanceTree_requestUpdateOpenSaleOrder
(
trade_condition
.
getRelativeUrl
())
instance
=
instance_tree
.
getSuccessorValue
()
# This ensure that the user has a valid cloud contract.
# At this stage he already have a paied invoice for the reservation,
# so the cloud contact will be just created.
instance
.
SoftwareInstance_requestValidationPayment
()
# create a Deduction for his fee
context
.
SubscriptionRequest_generateReservationRefoundSalePackingList
()
# Instance is already destroyed so move into stopped state diretly.
if
instance_tree
.
getValidationState
()
==
"archived"
:
comment
=
"Instance Tree is Destroyed and archived, Stop the Subscription Request"
context
.
confirm
(
comment
=
comment
)
context
.
start
(
comment
=
comment
)
context
.
stop
(
comment
=
comment
)
invoice
=
context
.
SubscriptionRequest_verifyPaymentBalanceIsReady
()
if
not
invoice
:
# Invoice isn't available for the user to Pay
return
"Skipped (Payment isn't ready)"
if
not
context
.
SubscriptionRequest_verifyInstanceIsAllocated
():
# Only continue if instance is ready
return
"Skipped (Instance isn't ready)"
# Link to be sent is the invoice one
if
context
.
SubscriptionRequest_notifyPaymentIsReady
(
invoice
):
context
.
confirm
(
comment
=
"Payment is ready for the user"
)
return
"Payment is ready for the user"
return
"Skipped (User isn't notified)"
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_processOrdered.xml
deleted
100644 → 0
View file @
b204c4cd
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SubscriptionRequest_processOrdered
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.py
View file @
bddcaf92
...
...
@@ -1091,230 +1091,6 @@ class TestSubscriptionRequest_verifyReservationPaymentTransaction(TestSubscripti
def
test_deleted_sale_invoice_state
(
self
):
self
.
_test_cancel_due_sale_invoice_state
(
state
=
"deleted"
)
class
TestSubscriptionRequest_processOrdered
(
TestSubscriptionSkinsMixin
):
def
test_no_sale_invoice
(
self
):
person
=
self
.
makePerson
()
subscription_condition
=
self
.
newSubscriptionCondition
(
url_string
=
"https://%s/software.cfg"
%
self
.
new_id
,
sla_xml
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="oi">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>"""
,
text_content
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="xx">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>"""
,
root_slave
=
False
,
source_reference
=
"test_for_test_123"
)
subscription_request
=
self
.
newSubscriptionRequest
(
quantity
=
1
,
destination_section_value
=
person
,
specialise_value
=
subscription_condition
)
self
.
tic
()
self
.
assertEqual
(
subscription_request
.
SubscriptionRequest_processOrdered
(),
None
)
subscription_request
.
plan
()
subscription_request
.
order
()
self
.
tic
()
self
.
assertEqual
(
subscription_request
.
SubscriptionRequest_processOrdered
(),
'Skipped (Instance Requested)'
)
self
.
tic
()
instance_tree
=
subscription_request
.
getAggregateValue
(
portal_type
=
"Instance Tree"
)
self
.
assertNotEqual
(
instance_tree
,
None
)
instance
=
instance_tree
.
getSuccessorValue
()
self
.
assertNotEqual
(
instance
,
None
)
self
.
assertEqual
(
'diverged'
,
instance_tree
.
getCausalityState
())
instance
=
instance_tree
.
getSuccessorValue
()
self
.
assertNotEqual
(
instance
,
None
)
self
.
assertEqual
(
subscription_request
.
SubscriptionRequest_processOrdered
(),
"Skipped (Payment isn't ready)"
)
self
.
tic
()
self
.
assertEqual
(
'solved'
,
instance_tree
.
getCausalityState
())
contract
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
[
"Cloud Contract"
],
default_destination_section_uid
=
person
.
getUid
(),
validation_state
=
[
'invalidated'
,
'validated'
],
)
self
.
assertNotEqual
(
contract
,
None
)
# here the Reservation fee invoice wasn't generated to the user
# don't get cloud contact approved
self
.
assertEqual
(
contract
.
getValidationState
(),
"invalidated"
)
# Check if refundable invoice wasn't generated as causality is None anyway...
invoice
=
subscription_request
.
getCausalityValue
(
portal_type
=
"Sale Invoice Transaction"
)
self
.
assertEqual
(
None
,
invoice
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"ordered"
)
@
simulate
(
'SubscriptionRequest_verifyPaymentBalanceIsReady'
,
'*args, **kwrgs'
,
'return None'
)
@
simulate
(
'InstanceTree_requestUpdateOpenSaleOrder'
,
'*args, **kwargs'
,
'context.converge()'
)
@
simulate
(
'SubscriptionRequest_verifyInstanceIsAllocated'
,
'*args, **kwargs'
,
'return True'
)
def
test_with_reservation_fee
(
self
):
person
=
self
.
makePerson
()
subscription_condition
=
self
.
newSubscriptionCondition
(
url_string
=
"https://%s/software.cfg"
%
self
.
new_id
,
sla_xml
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="oi">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>"""
,
text_content
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="xx">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>"""
,
root_slave
=
False
,
source_reference
=
"test_for_test_123"
,
specialise_value
=
self
.
newSaleTradeCondition
()
)
subscription_request
=
self
.
newSubscriptionRequest
(
quantity
=
1
,
destination_section_value
=
person
,
specialise_value
=
subscription_condition
)
self
.
tic
()
# The SubscriptionRequest_createRelatedSaleInvoiceTransaction is invoked up, as it proven on
# test TestSubscriptionRequest_requestPaymentTransaction, so let's keep it simple, and just reinvoke
current_payment
=
subscription_request
.
SubscriptionRequest_requestPaymentTransaction
(
"TAG"
)
self
.
assertNotEqual
(
current_payment
,
None
)
self
.
tic
()
self
.
assertEqual
(
subscription_request
.
SubscriptionRequest_processOrdered
(),
None
)
subscription_request
.
plan
()
subscription_request
.
order
()
self
.
tic
()
self
.
assertEqual
(
subscription_request
.
SubscriptionRequest_processOrdered
(),
'Skipped (Instance Requested)'
)
self
.
tic
()
instance_tree
=
subscription_request
.
getAggregateValue
(
portal_type
=
"Instance Tree"
)
self
.
assertNotEqual
(
instance_tree
,
None
)
self
.
assertEqual
(
'diverged'
,
instance_tree
.
getCausalityState
())
self
.
assertEqual
(
'start_requested'
,
instance_tree
.
getSlapState
())
instance
=
instance_tree
.
getSuccessorValue
()
self
.
assertNotEqual
(
instance
,
None
)
self
.
assertEqual
(
subscription_request
.
SubscriptionRequest_processOrdered
(),
"Skipped (Payment isn't ready)"
)
self
.
tic
()
self
.
assertEqual
(
'solved'
,
instance_tree
.
getCausalityState
())
contract
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
[
"Cloud Contract"
],
default_destination_section_uid
=
person
.
getUid
(),
validation_state
=
[
'invalidated'
,
'validated'
],
)
self
.
assertNotEqual
(
contract
,
None
)
# here the Reservation fee invoice wasn't generated to the user
# don't get cloud contact approved
self
.
assertEqual
(
contract
.
getValidationState
(),
"invalidated"
)
# Check if refundable invoice wasn't generated as causality is None anyway...
invoice
=
subscription_request
.
getCausalityValue
(
portal_type
=
"Sale Invoice Transaction"
)
self
.
assertNotEqual
(
None
,
invoice
)
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"ordered"
)
@
simulate
(
'SubscriptionRequest_verifyPaymentBalanceIsReady'
,
'*args, **kwrgs'
,
'return context.fake_payment'
)
@
simulate
(
'InstanceTree_requestUpdateOpenSaleOrder'
,
'*args, **kwargs'
,
'context.converge()'
)
@
simulate
(
'SubscriptionRequest_verifyInstanceIsAllocated'
,
'*args, **kwargs'
,
'return True'
)
def
test_confirmed
(
self
):
person
=
self
.
makePerson
()
subscription_condition
=
self
.
newSubscriptionCondition
(
url_string
=
"https://%s/software.cfg"
%
self
.
new_id
,
sla_xml
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="oi">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>"""
,
text_content
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="xx">couscous</parameter>
<parameter id="zz">yy</parameter>
</instance>"""
,
root_slave
=
False
,
source_reference
=
"test_for_test_123"
,
specialise_value
=
self
.
newSaleTradeCondition
()
)
subscription_request
=
self
.
newSubscriptionRequest
(
quantity
=
1
,
destination_section_value
=
person
,
specialise_value
=
subscription_condition
)
subscription_request
.
plan
()
subscription_request
.
order
()
self
.
createNotificationMessage
(
"subscription_request-payment-is-ready"
,
text_content
=
'${name} ${subscription_title} ${payment_relative_relative_url}'
)
fake_invoice
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
"Sale Invoice Transaction"
)
fake_payment
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
"Payment Transaction"
,
causality
=
fake_invoice
.
getRelativeUrl
())
# Set this to the mock script can return it
setattr
(
subscription_request
,
'fake_payment'
,
fake_payment
)
self
.
tic
()
self
.
assertEqual
(
subscription_request
.
SubscriptionRequest_processOrdered
(),
'Skipped (Instance Requested)'
)
self
.
tic
()
instance_tree
=
subscription_request
.
getAggregateValue
()
self
.
assertNotEqual
(
None
,
instance_tree
)
self
.
assertEqual
(
'diverged'
,
instance_tree
.
getCausalityState
())
self
.
assertEqual
(
subscription_request
.
SubscriptionRequest_processOrdered
(),
'Payment is ready for the user'
)
self
.
tic
()
self
.
assertEqual
(
'solved'
,
instance_tree
.
getCausalityState
())
self
.
assertEqual
(
subscription_request
.
getSimulationState
(),
"confirmed"
)
class
TestSubscriptionRequest_verifyInstanceIsAllocated
(
TestSubscriptionSkinsMixin
):
...
...
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