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):
......
...@@ -51,6 +51,11 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -51,6 +51,11 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self.createNotificationMessage("subscription_request-confirmation-with-password") self.createNotificationMessage("subscription_request-confirmation-with-password")
self.createNotificationMessage("subscription_request-confirmation-without-password", self.createNotificationMessage("subscription_request-confirmation-without-password",
text_content='${name} ${login_name}') text_content='${name} ${login_name}')
self.createNotificationMessage("subscription_request-instance-is-ready",
text_content='${name} ${subscription_title} ${hosting_subscription_relative_url}')
self.createNotificationMessage("subscription_request-payment-is-ready",
text_content='${name} ${subscription_title} ${payment_relative_relative_url}')
self.cleanUpSubscriptionRequest() self.cleanUpSubscriptionRequest()
self.tic() self.tic()
...@@ -185,6 +190,21 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -185,6 +190,21 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
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,
notification_message="subscription_request-payment-is-ready"):
self.checkSubscriptionRequest(subscription_request, email, subscription_condition, slave=slave)
payment = subscription_request.SubscriptionRequest_verifyPaymentBalanceIsReady()
self.assertNotEqual(payment, None)
self.assertEqual(payment.getSimulationState(), 'started')
self.assertEqual(subscription_request.getSimulationState(), "confirmed")
self.checkEmailPaymentNotification(subscription_request, notification_message)
def checkStartedSubscriptionRequest(self, subscription_request, email, subscription_condition, slave=0,
notification_message="subscription_request-instance-is-ready"):
self.checkSubscriptionRequest(subscription_request, email, subscription_condition, slave=slave)
self.assertEqual(subscription_request.getSimulationState(), "started")
self.checkEmailInstanceNotification(subscription_request, notification_message)
def _getRelatedPaymentValue(self, subscription_request): def _getRelatedPaymentValue(self, subscription_request):
invoice = subscription_request.getCausalityValue(portal_type="Sale Invoice Transaction") invoice = subscription_request.getCausalityValue(portal_type="Sale Invoice Transaction")
return invoice.getCausalityRelatedValue(portal_type="Payment Transaction") return invoice.getCausalityRelatedValue(portal_type="Payment Transaction")
...@@ -206,8 +226,7 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -206,8 +226,7 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self.login() self.login()
sale_transaction_invoice.SaleInvoiceTransaction_createReversalPayzenTransaction() sale_transaction_invoice.SaleInvoiceTransaction_createReversalPayzenTransaction()
def checkAndPayFirstMonth(self, subscription_request):
def checkAndPayFirstTreeMonth(self, subscription_request):
self.login() self.login()
person = subscription_request.getDestinationSectionValue() person = subscription_request.getDestinationSectionValue()
...@@ -307,9 +326,11 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -307,9 +326,11 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
def checkEmailNotification(self, subscription_request, def checkEmailNotification(self, subscription_request,
notification_message="subscription_request-confirmation-with-password"): notification_message="subscription_request-confirmation-with-password"):
mail_message = subscription_request.getFollowUpRelatedValue( mail_message_list = [i for i in subscription_request.getFollowUpRelatedValueList(
portal_type="Mail Message") portal_type="Mail Message") if notification_message in i.getTitle()]
self.assertEqual(len(mail_message_list), 1)
mail_message = mail_message_list[0]
self.assertEqual( self.assertEqual(
"TestSubscriptionSkins Notification Message %s" % notification_message, "TestSubscriptionSkins Notification Message %s" % notification_message,
mail_message.getTitle()) mail_message.getTitle())
...@@ -318,6 +339,40 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -318,6 +339,40 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self.assertTrue(subscription_request.getDestinationSectionTitle() in \ self.assertTrue(subscription_request.getDestinationSectionTitle() in \
mail_message.getTextContent()) mail_message.getTextContent())
def checkEmailPaymentNotification(self, subscription_request,
notification_message="subscription_request-payment-is-ready"):
mail_message_list = [i for i in subscription_request.getFollowUpRelatedValueList(
portal_type="Mail Message") if notification_message in i.getTitle()]
self.assertEqual(len(mail_message_list), 1)
mail_message = mail_message_list[0]
self.assertEqual(
"TestSubscriptionSkins Notification Message %s" % notification_message,
mail_message.getTitle())
payment = subscription_request.SubscriptionRequest_verifyPaymentBalanceIsReady()
self.assertEqual(payment.getSimulationState(), 'started')
self.assertTrue(payment.getRelativeUrl() in \
mail_message.getTextContent())
self.assertTrue(subscription_request.getDestinationSectionTitle() in \
mail_message.getTextContent())
def checkEmailInstanceNotification(self, subscription_request,
notification_message="subscription_request-instance-is-ready"):
mail_message_list = [i for i in subscription_request.getFollowUpRelatedValueList(
portal_type="Mail Message") if notification_message in i.getTitle()]
self.assertEqual(len(mail_message_list), 1)
mail_message = mail_message_list[0]
self.assertEqual(
"TestSubscriptionSkins Notification Message %s" % notification_message,
mail_message.getTitle())
hosting_subscription = subscription_request.getAggregateValue()
self.assertEqual(hosting_subscription.getSlapState(), 'start_requested')
self.assertTrue(hosting_subscription.getRelativeUrl() in \
mail_message.getTextContent())
self.assertTrue(subscription_request.getDestinationSectionTitle() in \
mail_message.getTextContent())
def checkRelatedInstance(self, subscription_request): def checkRelatedInstance(self, subscription_request):
instance = self._checkRelatedInstance(subscription_request) instance = self._checkRelatedInstance(subscription_request)
self.assertEqual(instance.getAggregate(), None) self.assertEqual(instance.getAggregate(), None)
...@@ -471,14 +526,16 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -471,14 +526,16 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
return subscription_request return subscription_request
def checkSubscriptionDeploymentAndSimulation(self, default_email_text, subscription_server): def _checkSubscriptionDeploymentAndSimulation(self, subscription_request_list,
default_email_text, subscription_server):
subscription_request_list = self.getSubscriptionRequestList(
default_email_text, self.subscription_condition)
for subscription_request in subscription_request_list: for subscription_request in subscription_request_list:
# Check if instance was requested # Check if instance was requested
self.checkRelatedInstance(subscription_request) self.checkRelatedInstance(subscription_request)
self.simulateSlapgridCP(subscription_server)
self.tic()
self.stepCallSlaposAllocateInstanceAlarm() self.stepCallSlaposAllocateInstanceAlarm()
self.tic() self.tic()
...@@ -489,7 +546,7 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -489,7 +546,7 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
for subscription_request in subscription_request_list: for subscription_request in subscription_request_list:
# Re-check, as instance shouldn't be allocated until # Re-check, as instance shouldn't be allocated until
# the confirmation of the new Payment. # the confirmation of the new Payment.
self.checkRelatedInstance(subscription_request) self.checkAllocationOnRelatedInstance(subscription_request)
# generate simulation for open order # generate simulation for open order
self.stepCallUpdateOpenOrderSimulationAlarm() self.stepCallUpdateOpenOrderSimulationAlarm()
...@@ -606,10 +663,6 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -606,10 +663,6 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self.stepCallSlaposCrmCreateRegularisationRequestAlarm() self.stepCallSlaposCrmCreateRegularisationRequestAlarm()
self.tic() self.tic()
for subscription_request in subscription_request_list:
self.checkAndPayFirstTreeMonth(subscription_request)
self.tic()
# After the payment re-call the Alarm in order to confirm the subscription # After the payment re-call the Alarm in order to confirm the subscription
# Request. # Request.
self.stepCallSlaposSubscriptionRequestProcessOrderedAlarm() self.stepCallSlaposSubscriptionRequestProcessOrderedAlarm()
...@@ -620,191 +673,113 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -620,191 +673,113 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self.tic() self.tic()
for subscription_request in subscription_request_list: for subscription_request in subscription_request_list:
# Check if instance was already allocated, in this case, it shouldn't # Instances should be allocated
# until the allocation alarm kicks in.
self.checkRelatedInstance(subscription_request)
# Now really allocate the instance
self.stepCallSlaposAllocateInstanceAlarm()
self.tic()
# now instantiate it on computer and set some nice connection dict
self.simulateSlapgridCP(subscription_server)
self.tic()
for subscription_request in subscription_request_list:
# Re-check, now it should be allocated.
self.checkAllocationOnRelatedInstance(subscription_request) self.checkAllocationOnRelatedInstance(subscription_request)
def checkSubscriptionDeploymentAndSimulationWithReversalTransaction( # Check if instance is on confirmed state
self, default_email_text, subscription_server):
subscription_request_list = self.getSubscriptionRequestList(
default_email_text, self.subscription_condition)
for subscription_request in subscription_request_list:
# Check if instance was requested
self.checkRelatedInstance(subscription_request)
self.stepCallSlaposAllocateInstanceAlarm()
self.tic()
# now instantiate it on computer and set some nice connection dict
self.simulateSlapgridCP(subscription_server)
self.tic()
for subscription_request in subscription_request_list: for subscription_request in subscription_request_list:
# Re-check, as instance shouldn't be allocated until self.checkConfirmedSubscriptionRequest(subscription_request,
# the confirmation of the new Payment. default_email_text, self.subscription_condition)
self.checkRelatedInstance(subscription_request)
# check the Open Sale Order coverage
#self.stepCallSlaposRequestUpdateHostingSubscriptionOpenSaleOrderAlarm()
#self.tic()
# generate simulation for open order
self.stepCallUpdateOpenOrderSimulationAlarm()
self.tic()
# build subscription packing list
self.stepCallSlaposTriggerBuildAlarm()
self.tic()
# stabilise build deliveries and expand them # Assert that First month isn't payed
self.stepCallSlaposManageBuildingCalculatingDeliveryAlarm() self.assertFalse(
self.tic() subscription_request.SubscriptionRequest_testPaymentBalance())
# build aggregated packing list self.assertEquals('start_requested',
self.stepCallSlaposTriggerAggregatedDeliveryOrderBuilderAlarm() subscription_request.getAggregateValue().getSlapState())
self.tic()
# stabilise aggregated deliveries and expand them # The alarms might be called multiple times for move each step
self.stepCallSlaposManageBuildingCalculatingDeliveryAlarm() self.stepCallSlaposSubscriptionRequestProcessConfirmedAlarm()
self.tic() self.tic()
# check if Packing list is generated with the right trade condition
preference_tool = self.portal.portal_preferences
specialise_subscription_uid = preference_tool.getPreferredAggregatedSubscriptionSaleTradeCondition()
specialise_uid = preference_tool.getPreferredAggregatedSaleTradeCondition()
for subscription_request in subscription_request_list: for subscription_request in subscription_request_list:
sale_packing_list_list = self.getAggregatedSalePackingList( self.assertFalse(
subscription_request, specialise_subscription_uid) subscription_request.SubscriptionRequest_testPaymentBalance())
self.assertEqual(1, len(sale_packing_list_list))
self.checkAggregatedSalePackingList(subscription_request, sale_packing_list_list[0]) self.assertEquals('stop_requested',
subscription_request.getAggregateValue().getSlapState())
expected_sale_packing_list_amount = len(subscription_request_list) * 1 def checkSubscriptionDeploymentAndSimulationWithReversalTransaction(self, default_email_text, subscription_server):
self.assertEqual(expected_sale_packing_list_amount,
len(self.getSubscriptionSalePackingList(subscription_request)))
self.assertEqual(0, len(self.getAggregatedSalePackingList( subscription_request_list = self.getSubscriptionRequestList(
subscription_request, specialise_uid))) default_email_text, self.subscription_condition)
# Call this alarm shouldn't affect the delivery self._checkSubscriptionDeploymentAndSimulation(
self.stepCallSlaposStartConfirmedAggregatedSalePackingListAlarm( subscription_request_list, default_email_text, subscription_server)
accounting_date=DateTime('2222/01/01'))
self.tic()
# Make payments and reinvoke alarm
for subscription_request in subscription_request_list: for subscription_request in subscription_request_list:
self.assertEqual(1, len(self.getAggregatedSalePackingList( self.createReversalInvoiceAndCancelPayment(subscription_request)
subscription_request, specialise_subscription_uid))) self.tic()
# Call this alarm shouldn't affect the delivery self.stepCallSlaposSubscriptionRequestProcessConfirmedAlarm()
self.stepCallSlaposStartConfirmedAggregatedSubscriptionSalePackingListAlarm()
self.tic() self.tic()
for subscription_request in subscription_request_list: for subscription_request in subscription_request_list:
self.assertEqual(0, len(self.getAggregatedSalePackingList( self.assertTrue(
subscription_request, specialise_uid))) subscription_request.SubscriptionRequest_testPaymentBalance())
# stabilise aggregated deliveries and expand them self.assertEqual('start_requested',
self.stepCallSlaposManageBuildingCalculatingDeliveryAlarm() subscription_request.getAggregateValue().getSlapState())
self.tic()
# deliver aggregated deliveries # It is requireds a second interaction so the instance is
self.stepCallSlaposDeliverStartedAggregatedSalePackingListAlarm() # correctly started
self.tic() self.assertEqual("confirmed", subscription_request.getSimulationState())
# stabilise aggregated deliveries and expand them # On the second loop that email is send and state is moved to started
self.stepCallSlaposManageBuildingCalculatingDeliveryAlarm() self.stepCallSlaposSubscriptionRequestProcessConfirmedAlarm()
self.tic() self.tic()
# build aggregated invoices for subscription_request in subscription_request_list:
self.stepCallSlaposTriggerBuildAlarm() self.assertTrue(
self.tic() subscription_request.SubscriptionRequest_testPaymentBalance())
# stabilise aggregated invoices and expand them self.assertEquals('start_requested',
self.stepCallSlaposManageBuildingCalculatingDeliveryAlarm() subscription_request.getAggregateValue().getSlapState())
self.tic()
# update invoices with their tax & discount self.checkStartedSubscriptionRequest(subscription_request,
self.stepCallSlaposTriggerBuildAlarm() default_email_text, self.subscription_condition)
self.tic()
self.stepCallSlaposManageBuildingCalculatingDeliveryAlarm()
self.tic()
# update invoices with their tax & discount transaction lines
self.stepCallSlaposTriggerBuildAlarm()
self.tic()
self.stepCallSlaposManageBuildingCalculatingDeliveryAlarm()
self.tic()
# stop the invoices and solve them again
self.stepCallSlaposStopConfirmedAggregatedSaleInvoiceTransactionAlarm()
self.tic()
self.stepCallSlaposManageBuildingCalculatingDeliveryAlarm()
self.tic()
builder = self.portal.portal_orders.slapos_payment_transaction_builder def checkSubscriptionDeploymentAndSimulation(self, default_email_text, subscription_server):
for _ in range(500): subscription_request_list = self.getSubscriptionRequestList(
# build the aggregated payment default_email_text, self.subscription_condition)
self.stepCallSlaposTriggerPaymentTransactionOrderBuilderAlarm()
self.tic()
# If there is something unbuild recall alarm.
if not len(builder.OrderBuilder_generateUnrelatedInvoiceList()):
break
# start the payzen payment self._checkSubscriptionDeploymentAndSimulation(
self.stepCallSlaposPayzenUpdateConfirmedPaymentAlarm() subscription_request_list, default_email_text, subscription_server)
self.tic()
# stabilise the payment deliveries and expand them for subscription_request in subscription_request_list:
self.stepCallSlaposManageBuildingCalculatingDeliveryAlarm() self.checkAndPayFirstMonth(subscription_request)
self.tic() self.tic()
# trigger the CRM interaction self.stepCallSlaposSubscriptionRequestProcessConfirmedAlarm()
self.stepCallSlaposCrmCreateRegularisationRequestAlarm()
self.tic() self.tic()
for subscription_request in subscription_request_list: for subscription_request in subscription_request_list:
self.createReversalInvoiceAndCancelPayment(subscription_request) self.assertTrue(
self.tic() subscription_request.SubscriptionRequest_testPaymentBalance())
# After the payment re-call the Alarm in order to confirm the subscription self.assertEqual('start_requested',
# Request. subscription_request.getAggregateValue().getSlapState())
self.stepCallSlaposSubscriptionRequestProcessOrderedAlarm()
self.tic()
# The alarms might be called multiple times for move each step # It is requireds a second interaction so the instance is
self.stepCallSlaposSubscriptionRequestProcessOrderedAlarm() # correctly started
self.assertEqual("confirmed", subscription_request.getSimulationState())
# On the second loop that email is send and state is moved to started
self.stepCallSlaposSubscriptionRequestProcessConfirmedAlarm()
self.tic() self.tic()
for subscription_request in subscription_request_list: for subscription_request in subscription_request_list:
# Check if instance was already allocated, in this case, it shouldn't self.assertTrue(
# until the allocation alarm kicks in. subscription_request.SubscriptionRequest_testPaymentBalance())
self.checkRelatedInstance(subscription_request)
# Now really allocate the instance self.assertEquals('start_requested',
self.stepCallSlaposAllocateInstanceAlarm() subscription_request.getAggregateValue().getSlapState())
self.tic()
# now instantiate it on computer and set some nice connection dict self.checkStartedSubscriptionRequest(subscription_request,
self.simulateSlapgridCP(subscription_server) default_email_text, self.subscription_condition)
self.tic()
for subscription_request in subscription_request_list:
# Re-check, now it should be allocated.
self.checkAllocationOnRelatedInstance(subscription_request)
def _test_subscription_scenario(self, amount=1): def _test_subscription_scenario(self, amount=1):
...@@ -815,11 +790,15 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -815,11 +790,15 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
# Call as anonymous... check response? # Call as anonymous... check response?
default_email_text = "abc%s@nexedi.com" % self.new_id default_email_text = "abc%s@nexedi.com" % self.new_id
name="ABC %s" % self.new_id name="ABC %s" % self.new_id
self.requestAndCheckHostingSubscription(amount, name, default_email_text)
self.requestAndCheckHostingSubscription(
amount, name, default_email_text)
self.checkSubscriptionDeploymentAndSimulation( self.checkSubscriptionDeploymentAndSimulation(
default_email_text, subscription_server) default_email_text, subscription_server)
def _test_two_subscription_scenario(self, amount=1): def _test_two_subscription_scenario(self, amount=1):
""" The admin creates an computer, user can request instances on it""" """ The admin creates an computer, user can request instances on it"""
...@@ -828,10 +807,46 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -828,10 +807,46 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
# Call as anonymous... check response? # Call as anonymous... check response?
default_email_text = "abc%s@nexedi.com" % self.new_id default_email_text = "abc%s@nexedi.com" % self.new_id
name="ABC %s" % self.new_id name="ABC %s" % self.new_id
self.requestAndCheckHostingSubscription(amount, name, default_email_text)
self.logout() self.logout()
self._requestSubscription(
subscription_reference=self.subscription_condition.getReference(),
amount=amount,
name=name,
default_email_text=default_email_text,
REQUEST=self.portal.REQUEST)
self.login()
# I'm not sure if this is realistic
self.tic()
first_subscription_request = self.getSubscriptionRequest(
default_email_text, self.subscription_condition)
self.checkDraftSubscriptionRequest(first_subscription_request,
default_email_text, self.subscription_condition, amount=amount)
# Check Payment and pay it.
self.checkAndPaySubscriptionPayment(first_subscription_request)
self.tic()
# Call alarm to check payment and invoice and move foward to planned.
self.stepCallSlaposSubscriptionRequestProcessDraftAlarm()
self.tic()
self.checkPlannedSubscriptionRequest(first_subscription_request,
default_email_text, self.subscription_condition)
# Call alarm to mark subscription request as ordered, bootstrap the user
# and check if email is sent, once done move to ordered state.
self.stepCallSlaposSubscriptionRequestProcessPlannedAlarm()
self.tic()
self.checkOrderedSubscriptionRequest(first_subscription_request,
default_email_text, self.subscription_condition)
self.logout()
# Request a second one, without require confirmation and verifing the second subscription request # Request a second one, without require confirmation and verifing the second subscription request
self._requestSubscription( self._requestSubscription(
subscription_reference=self.subscription_condition.getReference(), subscription_reference=self.subscription_condition.getReference(),
...@@ -898,7 +913,7 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -898,7 +913,7 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
class TestSlapOSSubscriptionScenario(TestSlapOSSubscriptionScenarioMixin): class TestSlapOSSubscriptionScenario(TestSlapOSSubscriptionScenarioMixin):
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_scenario_with_reversal_transaction(self): def test_subscription_scenario_with_reversal_transaction(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