Commit e95da4ac authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request: Refactor Subscription Request workflow

  Modifies the Workflows meaning for Support Request Workflow

    Draft: Reservation isn't Payed, Person is created
    Planned: Reservation is Payed, User is going to be Notified
    Ordered: First month isn't payed, Hosting Subscription is created
             (started), user is notified about the payment to be done.

    Confirmed: Hosting Subscription is stopped until the payment
               is done. Once it done, instance is started and
               user is Notified.

    Started: User is available for this user.

    Stopped/Delivered aren't implemented.

  Nothing is implemented inside the workflow itself, alarms calls the
  scripts which changes the transitions once everything is ready to move
  foward.

  Allocation aoccur when if subscription request is in ordered state. We
  allocate earlier to reserve the space until the payment is done.
parent 549de9c2
...@@ -271,7 +271,7 @@ class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration( ...@@ -271,7 +271,7 @@ class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration(
reference = 'test_%s' % self.generateNewId() reference = 'test_%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person', person = self.portal.person_module.newContent(portal_type='Person',
title=reference, title=reference,
reference=reference, password=password) reference=reference)
person.newContent(portal_type='Assignment', role='member').open() person.newContent(portal_type='Assignment', role='member').open()
# Create second person # Create second person
...@@ -279,7 +279,7 @@ class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration( ...@@ -279,7 +279,7 @@ class TestSlapOSComputerConsumptionTioXMLFile_solveInvoicingGeneration(
reference = 'test_%s' % self.generateNewId() reference = 'test_%s' % self.generateNewId()
second_person = self.portal.person_module.newContent(portal_type='Person', second_person = self.portal.person_module.newContent(portal_type='Person',
title=reference, title=reference,
reference=reference, password=password) reference=reference)
second_person.newContent(portal_type='Assignment', role='member').open() second_person.newContent(portal_type='Assignment', role='member').open()
self.commit() self.commit()
......
...@@ -45,7 +45,10 @@ ...@@ -45,7 +45,10 @@
<item> <item>
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple/> <tuple>
<string>W:270, 4: Unused variable \'password\' (unused-variable)</string>
<string>W: 8, 0: Unused import transaction (unused-import)</string>
</tuple>
</value> </value>
</item> </item>
<item> <item>
...@@ -117,6 +120,7 @@ ...@@ -117,6 +120,7 @@
</item> </item>
</dictionary> </dictionary>
</list> </list>
<none/>
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
......
...@@ -33,8 +33,8 @@ def assignComputerPartition(software_instance, hosting_subscription): ...@@ -33,8 +33,8 @@ def assignComputerPartition(software_instance, hosting_subscription):
portal_type="Subscription Request") portal_type="Subscription Request")
if subscription_request is not None: if subscription_request is not None:
subscription_reference = subscription_request.getReference() subscription_reference = subscription_request.getReference()
if subscription_request.getSimulationState() not in ["confirmed", "started"]: if subscription_request.getSimulationState() not in ["ordered", "confirmed", "started"]:
raise Unauthorized("Related Subscription Requested isn't confirmed or started") raise Unauthorized("Related Subscription Requested isn't ordered, confirmed or started")
tag = None tag = None
try: try:
......
...@@ -4,7 +4,7 @@ portal = context.getPortalObject() ...@@ -4,7 +4,7 @@ portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type="Subscription Request", portal_type="Subscription Request",
simulation_state="confirmed", simulation_state="confirmed",
method_id="SubscriptionRequest_notifyInstanceIsReady", method_id="SubscriptionRequest_processConfirmed",
activity_kw={tag: tag} activity_kw={tag: tag}
) )
......
...@@ -4,7 +4,7 @@ portal = context.getPortalObject() ...@@ -4,7 +4,7 @@ portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type="Subscription Request", portal_type="Subscription Request",
simulation_state="draft", simulation_state="draft",
method_id="SubscriptionRequest_verifyPaymentTransaction", method_id="SubscriptionRequest_verifyReservationPaymentTransaction",
activity_kw={tag: tag} activity_kw={tag: tag}
) )
......
...@@ -4,7 +4,7 @@ portal = context.getPortalObject() ...@@ -4,7 +4,7 @@ portal = context.getPortalObject()
portal.portal_catalog.searchAndActivate( portal.portal_catalog.searchAndActivate(
portal_type="Subscription Request", portal_type="Subscription Request",
simulation_state="ordered", simulation_state="ordered",
method_id="SubscriptionRequest_checkPaymentBalance", method_id="SubscriptionRequest_processOrdered",
activity_kw={tag: tag} activity_kw={tag: tag}
) )
......
...@@ -48,4 +48,4 @@ portal.portal_notifications.sendMessage( ...@@ -48,4 +48,4 @@ portal.portal_notifications.sendMessage(
event_keyword_argument_dict={'follow_up':context.getRelativeUrl()}, event_keyword_argument_dict={'follow_up':context.getRelativeUrl()},
) )
context.start() return True
portal = context.getPortalObject()
if context.getSimulationState() != "ordered":
return
# Instance is ok, we should move foward
portal = context.getPortalObject()
sender = context.getSourceSectionValue(portal_type="Person")
recipient = context.getDestinationSectionValue(portal_type="Person")
# Get message from catalog
notification_reference = 'subscription_request-payment-is-ready'
# This implies the language to notify.
notification_message = portal.portal_notifications.getDocumentValue(
reference=notification_reference, language=recipient.getLanguage())
if notification_message is None:
raise ValueError, 'Unable to found Notification Message with reference "%s".' % notification_reference
# Set notification mapping
notification_mapping_dict = {
'name': recipient.getTitle(),
'subscription_title': context.getTitle(),
# Possible more actions goes here
'payment_relative_relative_url': payment.getRelativeUrl()}
# Preserve HTML else convert to text
if notification_message.getContentType() == "text/html":
mail_text = notification_message.asEntireHTML(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
else:
mail_text = notification_message.asText(
substitution_method_parameter_dict={'mapping_dict':notification_mapping_dict})
portal.portal_notifications.sendMessage(
sender=sender,
recipient=recipient,
subject=notification_message.getTitle(),
message=mail_text,
message_text_format=notification_message.getContentType(),
notifier_list=(portal.portal_preferences.getPreferredLoginAndPasswordNotifier(),),
store_as_event= portal.portal_preferences.isPreferredStoreEvents(),
event_keyword_argument_dict={'follow_up':context.getRelativeUrl()},
)
return True
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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>payment</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SubscriptionRequest_notifyPaymentIsReady</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
hosting_subscription = context.getAggregateValue()
if hosting_subscription is None:
# Probably we should raise here
return
request_kw = dict(
software_release=hosting_subscription.getUrlString(),
software_title=hosting_subscription.getTitle(),
software_type=hosting_subscription.getSourceReference(),
instance_xml=hosting_subscription.getTextContent(),
sla_xml=hosting_subscription.getSlaXml(),
shared=hosting_subscription.isRootSlave()
)
if not context.SubscriptionRequest_testPaymentBalance():
# Payment isn't paid by the user, so we stop the instance and wait
if hosting_subscription.getSlapState() == "start_requested":
person = hosting_subscription.getDefaultDestinationSectionValue()
person.requestSoftwareInstance(state='stopped', **request_kw)
return
if hosting_subscription.getSlapState() == "stop_requested":
person = hosting_subscription.getDefaultDestinationSectionValue()
person.requestSoftwareInstance(state='started', **request_kw)
# Return to because it is useless continue right the way.
return
if not context.SubscriptionRequest_verifyInstanceIsAllocated():
# Only continue if instance is ready
return
if context.SubscriptionRequest_notifyInstanceIsReady():
context.start()
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SubscriptionRequest_checkPaymentBalance</string> </value> <value> <string>SubscriptionRequest_processConfirmed</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
# If Hosting subscription is None, make the request
hosting_subscription = context.getAggregateValue() hosting_subscription = context.getAggregateValue()
# Don't request again if it is already requested. # Don't request again if it is already requested.
...@@ -9,22 +7,28 @@ if hosting_subscription is None: ...@@ -9,22 +7,28 @@ if hosting_subscription is None:
return return
if hosting_subscription is not None: if hosting_subscription is not None:
if hosting_subscription.getCausalityState() == "diverged": if hosting_subscription.getCausalityState() == "diverged":
# Call it as soon as possible # Call it as soon as possible
hosting_subscription.HostingSubscription_requestUpdateOpenSaleOrder() hosting_subscription.HostingSubscription_requestUpdateOpenSaleOrder()
instance = hosting_subscription.getPredecessorValue() instance = hosting_subscription.getPredecessorValue()
# This ensure that the user has a valid cloud contract. # This ensure that the user has a valid cloud contract.
# At this stage he already have a paied invoice for the reservation, # At this stage he already have a paied invoice for the reservation,
# so the cloud contact will be just created. # so the cloud contact will be just created.
instance.SoftwareInstance_requestValidationPayment() instance.SoftwareInstance_requestValidationPayment()
# create a Deduction for his fee # create a Deduction for his fee
context.SubscriptionRequest_generateReservationRefoundSalePackingList() context.SubscriptionRequest_generateReservationRefoundSalePackingList()
if context.SubscriptionRequest_testPaymentBalance(): first_period_payment = context.SubscriptionRequest_verifyPaymentBalanceIsReady()
if not first_period_payment:
# Payment isn't available for the user
return
if not context.SubscriptionRequest_verifyInstanceIsAllocated():
# Only continue if instance is ready
return
if context.SubscriptionRequest_notifyPaymentIsReady(payment=first_period_payment):
context.confirm() context.confirm()
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>SubscriptionRequest_verifyPaymentTransaction</string> </value> <value> <string>SubscriptionRequest_processOrdered</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
# Search by SPL for the first period payment = context.SubscriptionRequest_verifyPaymentBalanceIsReady()
portal = context.getPortalObject() if payment is not None and payment.getSimulationState() in ['stopped', 'deliveried']:
# Payment Transaction is payed
# This is normally one, but we navegate in case
for packing_list in portal.portal_catalog(
portal_type="Sale Packing List",
causality_uid=context.getUid(),
specialise_uid=portal.restrictedTraverse(
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()).getUid(),
):
for invoice in packing_list.getCausalityRelatedValueList(
portal_type="Sale Invoice Transaction"):
for payment in invoice.getCausalityRelatedValueList(
portal_type=["Payment Transaction", "Sale Invoice Transaction"]):
if payment.getSimulationState() in ["stopped", "delivered"]:
return True return True
# Payment Transaction ins't payed
return False return False
hosting_subscription = context.getAggregateValue()
portal = context.getPortalObject()
software_instance_list = portal.portal_catalog(
portal_type=["Software Instance", "Slave Instance"],
specialise_uid=hosting_subscription.getUid())
# Check if at least one software Instance is Allocated
for instance in software_instance_list:
if instance.getSlapState() != "start_requested":
# There is something wrong.
return False
computer_partition = instance.getAggregateValue()
if computer_partition is None:
return False
if instance.getPortalType() == "Software Instance" and \
instance.SoftwareInstance_hasReportedError():
return False
return True
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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_verifyInstanceIsAllocated</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# Search by SPL for the first period
portal = context.getPortalObject()
reservation_fee_invoice = context.getCausalityValue(
portal_type="Sale Invoice Transaction"
)
reservation_fee_total_price = reservation_fee_invoice.getTotalPrice()
subscription_request_total_price = context.getPrice() * context.getQuantity()
remaining_to_pay = subscription_request_total_price - reservation_fee_total_price
# This is normally one, but we navegate in case
for packing_list in portal.portal_catalog(
portal_type="Sale Packing List",
causality_uid=context.getUid(),
specialise_uid=portal.restrictedTraverse(
portal.portal_preferences.getPreferredAggregatedSubscriptionSaleTradeCondition()).getUid(),
):
for invoice in packing_list.getCausalityRelatedValueList(
portal_type="Sale Invoice Transaction"):
for payment in invoice.getCausalityRelatedValueList(
portal_type=["Payment Transaction", "Sale Invoice Transaction"]):
if payment.getSimulationState() in ["stopped", "delivered"]:
# Invoice is already paied so we just move foward
return payment
elif payment.getSimulationState() in ["started"]:
payment_total_price = payment.PaymentTransaction_getTotalPayablePrice()
if not(round(payment_total_price, 2) + round(remaining_to_pay, 2)):
# Payment contains the expected value
return payment
# Payment isn't ready
return
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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_verifyPaymentBalanceIsReady</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -32,6 +32,4 @@ if context.getSpecialise(portal_type="Subscription Condition") is not None: ...@@ -32,6 +32,4 @@ if context.getSpecialise(portal_type="Subscription Condition") is not None:
# Ensure Subscription is updated # Ensure Subscription is updated
context.SubscriptionRequest_applyCondition() context.SubscriptionRequest_applyCondition()
# Send notification to Our Mantainers via portal notifications
#
context.plan(comment="Payment is consider valid.") context.plan(comment="Payment is consider valid.")
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<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_verifyReservationPaymentTransaction</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -24,7 +24,7 @@ from erp5.component.test.SlapOSTestCaseMixin import \ ...@@ -24,7 +24,7 @@ from erp5.component.test.SlapOSTestCaseMixin import \
class TestSlapOSSubscriptionRequestProcessAlarm(SlapOSTestCaseMixin): class TestSlapOSSubscriptionRequestProcessAlarm(SlapOSTestCaseMixin):
def test_alarm_slapos_subscription_request_process_draft(self): def test_alarm_slapos_subscription_request_process_draft(self):
script_name = "SubscriptionRequest_verifyPaymentTransaction" script_name = "SubscriptionRequest_verifyReservationPaymentTransaction"
alarm = self.portal.portal_alarms.slapos_subscription_request_process_draft alarm = self.portal.portal_alarms.slapos_subscription_request_process_draft
subscription_request = self.portal.subscription_request_module.newContent( subscription_request = self.portal.subscription_request_module.newContent(
...@@ -51,7 +51,7 @@ class TestSlapOSSubscriptionRequestProcessAlarm(SlapOSTestCaseMixin): ...@@ -51,7 +51,7 @@ class TestSlapOSSubscriptionRequestProcessAlarm(SlapOSTestCaseMixin):
alarm, subscription_request, script_name) alarm, subscription_request, script_name)
def test_alarm_slapos_subscription_request_process_ordered(self): def test_alarm_slapos_subscription_request_process_ordered(self):
script_name = "SubscriptionRequest_checkPaymentBalance" script_name = "SubscriptionRequest_processOrdered"
alarm = self.portal.portal_alarms.slapos_subscription_request_process_ordered alarm = self.portal.portal_alarms.slapos_subscription_request_process_ordered
subscription_request = self.portal.subscription_request_module.newContent( subscription_request = self.portal.subscription_request_module.newContent(
...@@ -66,7 +66,7 @@ class TestSlapOSSubscriptionRequestProcessAlarm(SlapOSTestCaseMixin): ...@@ -66,7 +66,7 @@ class TestSlapOSSubscriptionRequestProcessAlarm(SlapOSTestCaseMixin):
alarm, subscription_request, script_name) alarm, subscription_request, script_name)
def test_alarm_slapos_subscription_request_process_confirmed(self): def test_alarm_slapos_subscription_request_process_confirmed(self):
script_name = "SubscriptionRequest_notifyInstanceIsReady" script_name = "SubscriptionRequest_processConfirmed"
alarm = self.portal.portal_alarms.slapos_subscription_request_process_confirmed alarm = self.portal.portal_alarms.slapos_subscription_request_process_confirmed
subscription_request = self.portal.subscription_request_module.newContent( subscription_request = self.portal.subscription_request_module.newContent(
......
...@@ -50,7 +50,7 @@ class TestSlapOSSubscriptionChineseScenario(TestSlapOSSubscriptionScenarioMixin) ...@@ -50,7 +50,7 @@ class TestSlapOSSubscriptionChineseScenario(TestSlapOSSubscriptionScenarioMixin)
self.subscription_condition.updateLocalRolesOnSecurityGroups() self.subscription_condition.updateLocalRolesOnSecurityGroups()
self.tic() self.tic()
def test_subscription_scenario(self): def test_subscription_scenario_with_single_vm(self):
self._test_subscription_scenario(amount=1) self._test_subscription_scenario(amount=1)
def test_subscription_with_3_vms_scenario(self): def test_subscription_with_3_vms_scenario(self):
......
...@@ -900,7 +900,7 @@ class TestSubscriptionRequest_notifyInstanceIsReady(TestSubscriptionSkinsMixin): ...@@ -900,7 +900,7 @@ class TestSubscriptionRequest_notifyInstanceIsReady(TestSubscriptionSkinsMixin):
event.getTextContent(),'%s %s %s' % (person.getTitle(), subscription_request.getTitle(), event.getTextContent(),'%s %s %s' % (person.getTitle(), subscription_request.getTitle(),
self.hosting_subscription.getRelativeUrl())) self.hosting_subscription.getRelativeUrl()))
class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixin): class TestSubscriptionRequest_verifyReservationPaymentTransaction(TestSubscriptionSkinsMixin):
def test_no_sale_invoice(self): def test_no_sale_invoice(self):
person = self.makePerson() person = self.makePerson()
...@@ -908,7 +908,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi ...@@ -908,7 +908,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi
quantity=1, destination_section_value=person) quantity=1, destination_section_value=person)
# Too early to cancel # Too early to cancel
self.assertEqual(subscription_request.SubscriptionRequest_verifyPaymentTransaction(), self.assertEqual(subscription_request.SubscriptionRequest_verifyReservationPaymentTransaction(),
None) None)
self.assertEqual(subscription_request.getSimulationState(), self.assertEqual(subscription_request.getSimulationState(),
"draft") "draft")
...@@ -921,7 +921,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi ...@@ -921,7 +921,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi
Base.getCreationDate = getCreationDate Base.getCreationDate = getCreationDate
try: try:
self.assertEqual(subscription_request.SubscriptionRequest_verifyPaymentTransaction(), self.assertEqual(subscription_request.SubscriptionRequest_verifyReservationPaymentTransaction(),
None) None)
finally: finally:
Base.getCreationDate = original_get_creation Base.getCreationDate = original_get_creation
...@@ -944,7 +944,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi ...@@ -944,7 +944,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi
payment_template = self.portal.restrictedTraverse("accounting_module/slapos_pre_payment_template") payment_template = self.portal.restrictedTraverse("accounting_module/slapos_pre_payment_template")
# Too early to cancel # Too early to cancel
self.assertEqual(subscription_request.SubscriptionRequest_verifyPaymentTransaction(), None) self.assertEqual(subscription_request.SubscriptionRequest_verifyReservationPaymentTransaction(), None)
self.assertEqual(subscription_request.getSimulationState(), "draft") self.assertEqual(subscription_request.getSimulationState(), "draft")
current_invoice = invoice_template.Base_createCloneDocument(batch_mode=1) current_invoice = invoice_template.Base_createCloneDocument(batch_mode=1)
...@@ -960,7 +960,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi ...@@ -960,7 +960,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi
current_payment.delete() current_payment.delete()
self.tic() self.tic()
self.assertEqual(subscription_request.SubscriptionRequest_verifyPaymentTransaction(), self.assertEqual(subscription_request.SubscriptionRequest_verifyReservationPaymentTransaction(),
None) None)
self.assertEqual(current_invoice.getSimulationState(), "cancelled") self.assertEqual(current_invoice.getSimulationState(), "cancelled")
...@@ -991,7 +991,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi ...@@ -991,7 +991,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi
payment_template = self.portal.restrictedTraverse("accounting_module/slapos_pre_payment_template") payment_template = self.portal.restrictedTraverse("accounting_module/slapos_pre_payment_template")
# Too early to cancel # Too early to cancel
self.assertEqual(subscription_request.SubscriptionRequest_verifyPaymentTransaction(), None) self.assertEqual(subscription_request.SubscriptionRequest_verifyReservationPaymentTransaction(), None)
self.assertEqual(subscription_request.getSimulationState(), "draft") self.assertEqual(subscription_request.getSimulationState(), "draft")
current_invoice = invoice_template.Base_createCloneDocument(batch_mode=1) current_invoice = invoice_template.Base_createCloneDocument(batch_mode=1)
...@@ -1008,14 +1008,14 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi ...@@ -1008,14 +1008,14 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi
current_payment.start() current_payment.start()
self.tic() self.tic()
self.assertEqual(subscription_request.SubscriptionRequest_verifyPaymentTransaction(), self.assertEqual(subscription_request.SubscriptionRequest_verifyReservationPaymentTransaction(),
None) None)
self.assertEqual(subscription_request.getSimulationState(), self.assertEqual(subscription_request.getSimulationState(),
"draft") "draft")
current_payment.stop() current_payment.stop()
self.assertEqual(subscription_request.SubscriptionRequest_verifyPaymentTransaction(), self.assertEqual(subscription_request.SubscriptionRequest_verifyReservationPaymentTransaction(),
None) None)
self.assertEqual(subscription_request.getSimulationState(), self.assertEqual(subscription_request.getSimulationState(),
"planned") "planned")
...@@ -1035,7 +1035,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi ...@@ -1035,7 +1035,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi
invoice_template = self.portal.restrictedTraverse(invoice_template_path) invoice_template = self.portal.restrictedTraverse(invoice_template_path)
# Too early to cancel # Too early to cancel
self.assertEqual(subscription_request.SubscriptionRequest_verifyPaymentTransaction(), self.assertEqual(subscription_request.SubscriptionRequest_verifyReservationPaymentTransaction(),
None) None)
self.assertEqual(subscription_request.getSimulationState(), self.assertEqual(subscription_request.getSimulationState(),
"draft") "draft")
...@@ -1048,7 +1048,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi ...@@ -1048,7 +1048,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi
elif state == "deleted": elif state == "deleted":
current_invoice.delete() current_invoice.delete()
self.assertEqual(subscription_request.SubscriptionRequest_verifyPaymentTransaction(), self.assertEqual(subscription_request.SubscriptionRequest_verifyReservationPaymentTransaction(),
None) None)
self.assertEqual(subscription_request.getSimulationState(), self.assertEqual(subscription_request.getSimulationState(),
"cancelled") "cancelled")
...@@ -1062,7 +1062,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi ...@@ -1062,7 +1062,7 @@ class TestSubscriptionRequest_verifyPaymentTransaction(TestSubscriptionSkinsMixi
def test_deleted_sale_invoice_state(self): def test_deleted_sale_invoice_state(self):
self._test_cancel_due_sale_invoice_state(state="deleted") self._test_cancel_due_sale_invoice_state(state="deleted")
class TestSubscriptionRequest_checkPaymentBalance(TestSubscriptionSkinsMixin): class TestSubscriptionRequest_processOrdered(TestSubscriptionSkinsMixin):
def test_no_sale_invoice(self): def test_no_sale_invoice(self):
person = self.makePerson() person = self.makePerson()
...@@ -1084,7 +1084,7 @@ class TestSubscriptionRequest_checkPaymentBalance(TestSubscriptionSkinsMixin): ...@@ -1084,7 +1084,7 @@ class TestSubscriptionRequest_checkPaymentBalance(TestSubscriptionSkinsMixin):
self.tic() self.tic()
self.assertEqual( self.assertEqual(
subscription_request.SubscriptionRequest_checkPaymentBalance(), None) subscription_request.SubscriptionRequest_processOrdered(), None)
self.tic() self.tic()
hosting_subscription = subscription_request.getAggregateValue(portal_type="Hosting Subscription") hosting_subscription = subscription_request.getAggregateValue(portal_type="Hosting Subscription")
...@@ -1143,7 +1143,7 @@ class TestSubscriptionRequest_checkPaymentBalance(TestSubscriptionSkinsMixin): ...@@ -1143,7 +1143,7 @@ class TestSubscriptionRequest_checkPaymentBalance(TestSubscriptionSkinsMixin):
self.tic() self.tic()
self.assertEqual( self.assertEqual(
subscription_request.SubscriptionRequest_checkPaymentBalance(), None) subscription_request.SubscriptionRequest_processOrdered(), None)
self.tic() self.tic()
hosting_subscription = subscription_request.getAggregateValue(portal_type="Hosting Subscription") hosting_subscription = subscription_request.getAggregateValue(portal_type="Hosting Subscription")
...@@ -1198,7 +1198,7 @@ class TestSubscriptionRequest_checkPaymentBalance(TestSubscriptionSkinsMixin): ...@@ -1198,7 +1198,7 @@ class TestSubscriptionRequest_checkPaymentBalance(TestSubscriptionSkinsMixin):
self.tic() self.tic()
self.assertEqual( self.assertEqual(
subscription_request.SubscriptionRequest_checkPaymentBalance(), None) subscription_request.SubscriptionRequest_processOrdered(), None)
self.tic() self.tic()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment