Commit b8353233 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request: Update tests for the support of Dual Organisations

   When you have different companies per Subscription Conditions
parent 7fe06ed7
# -*- coding:utf-8 -*-
##############################################################################
#
# Copyright (c) 2019 Nexedi SA and Contributors. All Rights Reserved.
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from erp5.component.test.testSlapOSSubscriptionChineseScenario import TestSlapOSSubscriptionChineseScenarioMixin
class testSlapOSSubscriptionDualOrganisationChineseScenario(TestSlapOSSubscriptionChineseScenarioMixin):
def afterSetUp(self):
TestSlapOSSubscriptionChineseScenarioMixin.afterSetUp(self)
fr_organisation, zh_organisation = self.redefineAccountingTemplatesonPreferencesWithDualOrganisation()
self.expected_source = zh_organisation.getRelativeUrl()
self.expected_source_section = zh_organisation.getRelativeUrl()
self.subscription_condition.edit(
source=self.expected_source,
source_section=self.expected_source_section
)
self.expected_case2_source = fr_organisation.getRelativeUrl()
self.expected_case2_source_section = fr_organisation.getRelativeUrl()
self.portal.portal_caches.clearAllCache()
self.tic()
def beforeTearDown(self):
TestSlapOSSubscriptionChineseScenarioMixin.beforeTearDown(self)
self.restoreAccountingTemplatesOnPreferences()
self.portal.portal_caches.clearAllCache()
self.tic()
def test_subscription_scenario_with_single_vm(self):
self._test_subscription_scenario(amount=1)
def test_subscription_with_3_vms_scenario(self):
self._test_subscription_scenario(amount=3)
def test_subscription_scenario_with_reversal_transaction(self):
self._test_subscription_scenario_with_reversal_transaction(amount=1)
def test_two_subscription_scenario(self):
self._test_two_subscription_scenario(amount=1)
def test_subscription_scenario_with_existing_user(self):
self._test_subscription_scenario_with_existing_user(amount=1, language="zh")
def test_subscription_scenario_with_existing_english_user(self):
# Messages are in chinese, when subscribed via chinese website. Even if the english language is
# english
self._test_subscription_scenario_with_existing_user(amount=1, language="en")
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSSubscriptionDualOrganisationChineseScenario</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testSlapOSSubscriptionDualOrganisationChineseScenario</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -54,29 +54,6 @@ class testSlapOSSubscriptionDualOrganisationScenario(TestSlapOSSubscriptionScena
self.portal.portal_caches.clearAllCache()
self.tic()
def test_subscription_scenario_with_single_vm(self):
self._test_subscription_scenario(amount=1)
def test_subscription_with_3_vms_scenario(self):
self._test_subscription_scenario(amount=3)
def test_subscription_scenario_with_reversal_transaction(self):
self._test_subscription_scenario_with_reversal_transaction(amount=1)
def test_two_subscription_scenario(self):
self._test_two_subscription_scenario(amount=1)
def test_subscription_scenario_with_existing_user(self):
self._test_subscription_scenario_with_existing_user(amount=1, language="zh")
def test_subscription_scenario_with_existing_english_user(self):
# Messages are in chinese, when subscribed via chinese website. Even if the english language is
# english
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,
default_email_text, language_list):
......@@ -96,12 +73,12 @@ class testSlapOSSubscriptionDualOrganisationScenario(TestSlapOSSubscriptionScena
self._requestSubscriptionViaChineseWebsite(**request_kw)
subscription_condition = self.subscription_condition_zh
expected_price_currency = "currency_module/CNY"
expected_source_section = self.expected_zh_source_section
expected_source_section = self.expected_zh_source_section
else:
self._requestSubscription(**request_kw)
subscription_condition = self.subscription_condition
expected_price_currency = "currency_module/EUR"
expected_source_section = self.expected_source_section
expected_source_section = self.expected_source_section
self.login()
# I'm not sure if this is realistic
......@@ -125,7 +102,8 @@ class testSlapOSSubscriptionDualOrganisationScenario(TestSlapOSSubscriptionScena
subscription_request.getSpecialiseValue(),
amount=amount)
self.tic()
all_subscription_requested_list.extend(subscription_request_list)
if subscription_request not in all_subscription_requested_list:
all_subscription_requested_list.append(subscription_request)
self.checkAndPaySubscriptionPayment(all_subscription_requested_list)
self.tic()
......@@ -181,9 +159,8 @@ class testSlapOSSubscriptionDualOrganisationScenario(TestSlapOSSubscriptionScena
return all_subscription_requested_list
def test_subscription_scenario_with_dual_organisation(self):
amount = 1
language = "en"
def _test_subscription_scenario_with_dual_organisation(self, language_list, amount=1, language="en"):
# Call as anonymous... check response?
default_email_text = "abc%s@nexedi.com" % self.new_id
name="ABC %s" % self.new_id
......@@ -195,15 +172,15 @@ class testSlapOSSubscriptionDualOrganisationScenario(TestSlapOSSubscriptionScena
self.subscription_server = self.createPublicServerForAdminUser()
self.login()
# Extra software from zh version
subscription_server_software = self.subscription_condition_zh.getUrlString()
self.supplySoftware(self.subscription_server, subscription_server_software)
self.tic()
self.logout()
subscription_request_list = self.requestAndCheckDualHostingSubscription(
amount, name, default_email_text, language_list=["en", "zh"])
amount, name, default_email_text, language_list=language_list)
self._checkSubscriptionDeploymentAndSimulation(
subscription_request_list, default_email_text,
......@@ -265,4 +242,22 @@ class testSlapOSSubscriptionDualOrganisationScenario(TestSlapOSSubscriptionScena
default_email_text,
subscription_request.getSpecialiseValue())
return default_email_text, name
\ No newline at end of file
return default_email_text, name
def test_subscription_scenario_with_dual_organisation_en(self):
self._test_subscription_scenario_with_dual_organisation(["en", "zh", "en"], amount=1, language="en")
def test_subscription_scenario_with_dual_organisation_zh(self):
self._test_subscription_scenario_with_dual_organisation(["en", "zh", "zh"], amount=1, language="zh")
def test_subscription_scenario_with_dual_organisation_en_2(self):
self._test_subscription_scenario_with_dual_organisation(["en", "zh"], amount=2, language="en")
def test_subscription_scenario_with_dual_organisation_zh_2(self):
self._test_subscription_scenario_with_dual_organisation(["en", "zh"], amount=2, language="zh")
def test_subscription_scenario_with_dual_organisation_en_only(self):
self._test_subscription_scenario_with_dual_organisation(["en", "en", "en"], amount=1, language="en")
def test_subscription_scenario_with_dual_organisation_zh_only(self):
self._test_subscription_scenario_with_dual_organisation(["zh", "zh", "zh"], amount=1, language="zh")
......@@ -387,9 +387,6 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
sale_transaction_invoice.SaleInvoiceTransaction_createReversalPayzenTransaction()
def checkSubscriptionRequestPayment(self, subscription_request, authAmount):
payment = self.portal.portal_catalog.getResultValue(
portal_type="Payment Transaction",
simulation_state="started")
if subscription_request.getSource() is not None:
self.assertNotEqual(subscription_request.getSourceSection(), None)
......@@ -402,6 +399,13 @@ return dict(vads_url_already_registered="%s/already_registered" % (payment_trans
#expected_source = self.expected_source
expected_source_section = self.expected_source_section
# Be accurate when select the payment
payment = self.portal.portal_catalog.getResultValue(
portal_type="Payment Transaction",
destination_section_uid=subscription_request.getDestinationSectionUid(),
source_section_uid=self.portal.restrictedTraverse(expected_source_section).getUid(),
simulation_state="started")
self.assertEqual(payment.getSourceSection(),
expected_source_section)
self.assertEqual(payment.getSourcePayment(),
......
......@@ -12,5 +12,4 @@ test.erp5.testSlapOSSubscriptionInvitationTokenChineseScenario
test.erp5.testSlapOSSubscriptionSecondMonthPaymentScenario
test.erp5.testSlapOSSubscriptionSecondMonthPaymentChineseScenario
test.erp5.testSlapOSSubscriptionDualOrganisationScenario
test.erp5.testSlapOSSubscriptionDualOrganisationChineseScenario
test.erp5.testSlapOSSubscriptionCancellationScenario
\ No newline at end of file
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