Commit 168d72f1 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request: Test invoice and concurrent requests

   It makes requests as non-subscription and for subscription cases, and assert if the invoice is correctly linked via simulation
parent 4f56b762
...@@ -56,6 +56,9 @@ class TestSlapOSSubscriptionChineseScenario(TestSlapOSSubscriptionChineseScenari ...@@ -56,6 +56,9 @@ class TestSlapOSSubscriptionChineseScenario(TestSlapOSSubscriptionChineseScenari
def test_subscription_scenario_with_existing_user(self): def test_subscription_scenario_with_existing_user(self):
self._test_subscription_scenario_with_existing_user(amount=1, language="zh") self._test_subscription_scenario_with_existing_user(amount=1, language="zh")
def test_subscription_scenario_with_existing_user_with_non_subscription_request(self):
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="en")
def test_subscription_scenario_with_existing_english_user(self): def test_subscription_scenario_with_existing_english_user(self):
# Messages are in chinese, when subscribed via chinese website. Even if the english language is # Messages are in chinese, when subscribed via chinese website. Even if the english language is
# english # english
......
...@@ -74,6 +74,8 @@ class testSlapOSSubscriptionDualOrganisationScenario(TestSlapOSSubscriptionScena ...@@ -74,6 +74,8 @@ class testSlapOSSubscriptionDualOrganisationScenario(TestSlapOSSubscriptionScena
# english # english
self._test_subscription_scenario_with_existing_user(amount=1, language="en") self._test_subscription_scenario_with_existing_user(amount=1, language="en")
def test_subscription_scenario_with_existing_user_with_non_subscription_request(self):
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="en")
def requestAndCheckDualHostingSubscription(self, amount, name, def requestAndCheckDualHostingSubscription(self, amount, name,
default_email_text, language_list): default_email_text, language_list):
......
...@@ -42,6 +42,10 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionC ...@@ -42,6 +42,10 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionC
self.cloud_invitation_token = self.makeCloudInvitationToken() self.cloud_invitation_token = self.makeCloudInvitationToken()
self._test_subscription_scenario_with_existing_user(amount=1, language="zh") self._test_subscription_scenario_with_existing_user(amount=1, language="zh")
def test_subscription_scenario_with_existing_user_with_non_subscription_request_with_empty_invitation(self):
self.cloud_invitation_token = self.makeCloudInvitationToken()
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="en")
def test_subscription_scenario_with_existing_english_user_and_empty_invitation(self): def test_subscription_scenario_with_existing_english_user_and_empty_invitation(self):
self.cloud_invitation_token = self.makeCloudInvitationToken() self.cloud_invitation_token = self.makeCloudInvitationToken()
self._test_subscription_scenario_with_existing_user(amount=1, language="en") self._test_subscription_scenario_with_existing_user(amount=1, language="en")
...@@ -98,4 +102,8 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionC ...@@ -98,4 +102,8 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionC
self._init_test_with_valid_invitation() self._init_test_with_valid_invitation()
self._test_subscription_scenario_with_existing_user(amount=1, language="en") self._test_subscription_scenario_with_existing_user(amount=1, language="en")
def test_subscription_scenario_with_existing_user_with_non_subscription_request_with_token(self):
self._init_test_with_valid_invitation()
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="en")
...@@ -42,6 +42,10 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionS ...@@ -42,6 +42,10 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionS
self.cloud_invitation_token = self.makeCloudInvitationToken() self.cloud_invitation_token = self.makeCloudInvitationToken()
self._test_subscription_scenario_with_existing_user(amount=1, language="zh") self._test_subscription_scenario_with_existing_user(amount=1, language="zh")
def test_subscription_scenario_with_existing_user_with_non_subscription_request_with_empty_invitation(self):
self.cloud_invitation_token = self.makeCloudInvitationToken()
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="en")
def test_subscription_scenario_with_existing_english_user_and_empty_invitation(self): def test_subscription_scenario_with_existing_english_user_and_empty_invitation(self):
self.cloud_invitation_token = self.makeCloudInvitationToken() self.cloud_invitation_token = self.makeCloudInvitationToken()
self._test_subscription_scenario_with_existing_user(amount=1, language="en") self._test_subscription_scenario_with_existing_user(amount=1, language="en")
...@@ -89,4 +93,6 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionS ...@@ -89,4 +93,6 @@ class testSlapOSSubscriptionCloudInvitationTokenScenario(TestSlapOSSubscriptionS
self._init_test_with_valid_invitation() self._init_test_with_valid_invitation()
self._test_subscription_scenario_with_existing_user(amount=1, language="en") self._test_subscription_scenario_with_existing_user(amount=1, language="en")
def test_subscription_scenario_with_existing_user_with_non_subscription_request_with_token(self):
self._init_test_with_valid_invitation()
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="en")
...@@ -61,6 +61,9 @@ class testSlapOSSubscriptionNewTemplateChineseScenario(TestSlapOSSubscriptionChi ...@@ -61,6 +61,9 @@ class testSlapOSSubscriptionNewTemplateChineseScenario(TestSlapOSSubscriptionChi
def test_subscription_scenario_with_existing_user(self): def test_subscription_scenario_with_existing_user(self):
self._test_subscription_scenario_with_existing_user(amount=1, language="zh") self._test_subscription_scenario_with_existing_user(amount=1, language="zh")
def test_subscription_scenario_with_existing_user_with_non_subscription_request(self):
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="zh")
def test_subscription_scenario_with_existing_english_user(self): def test_subscription_scenario_with_existing_english_user(self):
# Messages are in chinese, when subscribed via chinese website. Even if the english language is # Messages are in chinese, when subscribed via chinese website. Even if the english language is
# english # english
......
...@@ -61,6 +61,9 @@ class testSlapOSSubscriptionNewTemplateScenario(TestSlapOSSubscriptionScenarioMi ...@@ -61,6 +61,9 @@ class testSlapOSSubscriptionNewTemplateScenario(TestSlapOSSubscriptionScenarioMi
def test_subscription_scenario_with_existing_user(self): def test_subscription_scenario_with_existing_user(self):
self._test_subscription_scenario_with_existing_user(amount=1, language="zh") self._test_subscription_scenario_with_existing_user(amount=1, language="zh")
def test_subscription_scenario_with_existing_user_with_non_subscription_request(self):
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="zh")
def test_subscription_scenario_with_existing_english_user(self): def test_subscription_scenario_with_existing_english_user(self):
# Messages are in chinese, when subscribed via chinese website. Even if the english language is # Messages are in chinese, when subscribed via chinese website. Even if the english language is
# english # english
......
...@@ -52,6 +52,7 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin): ...@@ -52,6 +52,7 @@ class TestSlapOSSubscriptionScenarioMixin(DefaultScenarioMixin):
self.expected_source_section = self.expected_slapos_organisation self.expected_source_section = self.expected_slapos_organisation
self.cloud_invitation_token = None self.cloud_invitation_token = None
self.expected_free_reservation = 0 self.expected_free_reservation = 0
self.non_subscription_related_instance_amount = 0
self.skip_destroy_and_check = 0 self.skip_destroy_and_check = 0
self.login() self.login()
...@@ -412,6 +413,27 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -412,6 +413,27 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self.assertEqual(payment.getPriceCurrency(), self.assertEqual(payment.getPriceCurrency(),
subscription_request.getPriceCurrency()) subscription_request.getPriceCurrency())
# Check related invoice Data
invoice_list = payment.getCausalityValueList()
self.assertEqual(len(invoice_list), 1)
invoice = invoice_list[0]
delivery_list = invoice.getCausalityValueList()
# Invoices related to Subscription Request don't merge
self.assertEqual(len(delivery_list), 1)
sale_packing_list = delivery_list[0]
grouping_reference = sale_packing_list.getReference()
subscription_delivery_line_list = self.portal.portal_catalog(
portal_type="Sale Packing List Line",
grouping_reference=grouping_reference
)
self.assertEqual(len(subscription_delivery_line_list), 1)
# Check more :)
return payment return payment
def checkAndPayFirstMonth(self, subscription_request): def checkAndPayFirstMonth(self, subscription_request):
...@@ -909,7 +931,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -909,7 +931,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
round(subscriber.Entity_statSlapOSOutstandingAmount(at_date=DateTime()+20), 2), round(subscriber.Entity_statSlapOSOutstandingAmount(at_date=DateTime()+20), 2),
0.0) 0.0)
def checkBootstrapUser(self, subscription_request): def checkBootstrapUser(self, subscription_request):
person = subscription_request.getDestinationSectionValue(portal_type="Person") person = subscription_request.getDestinationSectionValue(portal_type="Person")
self.assertEqual(person.getDefaultEmailText(), self.assertEqual(person.getDefaultEmailText(),
...@@ -1101,8 +1122,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -1101,8 +1122,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self._dropPaymentTransaction_getVADSUrlDict() self._dropPaymentTransaction_getVADSUrlDict()
self.portal.portal_secure_payments.slapos_wechat_test.setWechatMode(original_mode) self.portal.portal_secure_payments.slapos_wechat_test.setWechatMode(original_mode)
def getAggregatedSalePackingList(self, subscription_request, specialise): def getAggregatedSalePackingList(self, subscription_request, specialise):
person_uid = subscription_request.getDestinationSectionValue().getUid() person_uid = subscription_request.getDestinationSectionValue().getUid()
specialise_uid = self.portal.restrictedTraverse(specialise).getUid() specialise_uid = self.portal.restrictedTraverse(specialise).getUid()
...@@ -1304,7 +1323,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -1304,7 +1323,9 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
self.checkAggregatedSalePackingList(subscription_request, sale_packing_list_list[0]) self.checkAggregatedSalePackingList(subscription_request, sale_packing_list_list[0])
expected_sale_packing_list_amount = len(subscription_request_list) * 1 expected_sale_packing_list_amount = len(subscription_request_list) +\
self.non_subscription_related_instance_amount
self.assertEqual(expected_sale_packing_list_amount, self.assertEqual(expected_sale_packing_list_amount,
len(self.getSubscriptionSalePackingList(subscription_request))) len(self.getSubscriptionSalePackingList(subscription_request)))
...@@ -1584,6 +1605,43 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -1584,6 +1605,43 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
return default_email_text, name return default_email_text, name
def _test_subscription_scenario_with_existing_user_with_non_subscription_request(self, amount=1, language=None):
# Call as anonymous... check response?
default_email_text = "abc%s@nexedi.com" % self.new_id
name="ABC %s" % self.new_id
self.login()
self.createNormalUser(default_email_text, name, language)
self.tic()
self.subscription_server = self.createPublicServerForAdminUser()
self.login(self.normal_user.getUserId())
self.personRequestInstanceNotReady(
software_release=self.subscription_condition.getUrlString(),
software_type="default",
partition_reference="_test_subscription_scenario_with_existing_user_extra_instance",
)
self.non_subscription_related_instance_amount = 1
self.login()
self.requestAndCheckHostingSubscription(
amount, name, default_email_text)
self.checkSubscriptionDeploymentAndSimulation(
default_email_text, self.subscription_server)
subscription_request = self.getSubscriptionRequest(
default_email_text, self.subscription_condition)
self.assertEqual(self.normal_user,
subscription_request.getDestinationSectionValue())
self.destroyAndCheckSubscription(
default_email_text, self.subscription_server
)
return default_email_text, name
def _test_two_subscription_scenario(self, amount=1, create_invitation=False, def _test_two_subscription_scenario(self, amount=1, create_invitation=False,
max_invoice_delay=0, max_invoice_credit_eur=0.0, max_invoice_credit_cny=0.0): max_invoice_delay=0, max_invoice_credit_eur=0.0, max_invoice_credit_cny=0.0):
...@@ -1704,7 +1762,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans ...@@ -1704,7 +1762,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
return default_email_text, name return default_email_text, name
def _test_subscription_scenario_with_reversal_transaction(self, amount=1): def _test_subscription_scenario_with_reversal_transaction(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"""
...@@ -1764,6 +1821,9 @@ class TestSlapOSSubscriptionScenario(TestSlapOSSubscriptionScenarioMixin): ...@@ -1764,6 +1821,9 @@ class TestSlapOSSubscriptionScenario(TestSlapOSSubscriptionScenarioMixin):
def test_subscription_scenario_with_existing_user(self): def test_subscription_scenario_with_existing_user(self):
self._test_subscription_scenario_with_existing_user(amount=1, language="en") self._test_subscription_scenario_with_existing_user(amount=1, language="en")
def test_subscription_scenario_with_existing_user_with_non_subscription_request(self):
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="en")
def test_subscription_scenario_with_existing_chinese_user(self): def test_subscription_scenario_with_existing_chinese_user(self):
# Messages are in english, when subscribed via english website. Even if the chinese language is # Messages are in english, when subscribed via english website. Even if the chinese language is
# defined at user level. # defined at user level.
......
...@@ -53,3 +53,9 @@ class testSlapOSSubscriptionSecondMonthPaymentScenario(TestSlapOSSubscriptionChi ...@@ -53,3 +53,9 @@ class testSlapOSSubscriptionSecondMonthPaymentScenario(TestSlapOSSubscriptionChi
self.skip_destroy_and_check = 1 self.skip_destroy_and_check = 1
default_email_text, _ = self._test_subscription_scenario_with_existing_user(amount=1, language="en") default_email_text, _ = self._test_subscription_scenario_with_existing_user(amount=1, language="en")
self._test_second_month_scenario(default_email_text) self._test_second_month_scenario(default_email_text)
def test_subscription_scenario_with_existing_user_with_non_subscription_request(self):
self.skip_destroy_and_check = 1
default_email_text, _ = \
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="zh")
self._test_second_month_scenario(default_email_text)
...@@ -53,3 +53,9 @@ class testSlapOSSubscriptionSecondMonthPaymentScenario(TestSlapOSSubscriptionSce ...@@ -53,3 +53,9 @@ class testSlapOSSubscriptionSecondMonthPaymentScenario(TestSlapOSSubscriptionSce
self.skip_destroy_and_check = 1 self.skip_destroy_and_check = 1
default_email_text, _ = self._test_subscription_scenario_with_existing_user(amount=1, language="en") default_email_text, _ = self._test_subscription_scenario_with_existing_user(amount=1, language="en")
self._test_second_month_scenario(default_email_text) self._test_second_month_scenario(default_email_text)
def test_subscription_scenario_with_existing_user_with_non_subscription_request(self):
self.skip_destroy_and_check = 1
default_email_text, _ = \
self._test_subscription_scenario_with_existing_user_with_non_subscription_request(amount=1, language="en")
self._test_second_month_scenario(default_email_text)
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