Commit ebb18874 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud:

* test: drop unused functions
* test: create a bank account source payment on the trade condition
parent 8237015b
......@@ -179,7 +179,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
portal_type="Organisation",
title="test-seller-%s" % self.generateNewId()
)
seller_organisation.newContent(
seller_bank_account = seller_organisation.newContent(
portal_type="Bank Account",
title="test_bank_account_%s" % self.generateNewId()
)
......@@ -193,6 +193,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
destination_project_value=project,
source_value=seller_organisation,
source_section_value=seller_organisation,
source_payment=seller_bank_account,
price_currency_value=currency
)
sale_trade_condition.newContent(
......@@ -214,42 +215,6 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
project.validate()
return project
def makeCustomOrganisation(self, new_id=None, index=True,
price_currency="currency_module/EUR"):
# Create a custom organisation same as slapos, for ensure we can have
# multiple organisations working on the site
if new_id is None:
new_id = self.generateNewId()
custom_organisation = self.portal.organisation_module.slapos.\
Base_createCloneDocument(batch_mode=1)
custom_organisation.edit(
title="organisation_live_test_%s" % new_id,
reference="organisation_live_test_%s" % new_id,
default_email_text="organisation_live_test_%s@example.org" % new_id,
)
custom_organisation.validate()
self.assertEqual(custom_organisation.getGroup(),
"company")
self.assertEqual("currency_module/EUR",
custom_organisation.getPriceCurrency())
custom_organisation.setPriceCurrency(price_currency)
self.assertNotEqual(getattr(custom_organisation, "bank_account", None), None)
if index:
custom_organisation.updateLocalRolesOnSecurityGroups()
custom_organisation.bank_account.updateLocalRolesOnSecurityGroups()
transaction.commit()
custom_organisation.immediateReindexObject()
return custom_organisation
def _addERP5Login(self, document, **kw):
if document.getPortalType() == "Person":
kw["password"] = document.Person_generatePassword()
......@@ -938,133 +903,6 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
'Visited by %s' % script_name,
content)
def restoreAccountingTemplatesOnPreferences(self):
self.login()
system_preference = self.portal.portal_preferences.slapos_default_system_preference
system_preference.edit(
preferred_aggregated_consumption_sale_trade_condition=\
'sale_trade_condition_module/slapos_aggregated_consumption_trade_condition',
preferred_aggregated_sale_trade_condition=\
'sale_trade_condition_module/slapos_aggregated_trade_condition_v3',
preferred_aggregated_subscription_sale_trade_condition=\
'sale_trade_condition_module/slapos_aggregated_subscription_trade_condition_v3',
preferred_default_pre_payment_template=\
'accounting_module/slapos_pre_payment_template',
preferred_instance_delivery_template=\
'sale_packing_list_module/slapos_accounting_instance_delivery_template',
preferred_default_pre_payment_subscription_invoice_template=\
'accounting_module/template_pre_payment_subscription_sale_invoice_transaction'
)
self.portal.sale_trade_condition_module.default_subscription_trade_condition.edit(
source_section='organisation_module/slapos',
source='organisation_module/slapos'
)
self.tic()
def redefineAccountingTemplatesonPreferences(self, price_currency="currency_module/EUR"):
# Define a new set of templates and change organisation on them, in this way tests should
# behave the same.
self.login()
organisation = self.makeCustomOrganisation(price_currency=price_currency)
accounting_module = self.portal.accounting_module
sale_packing_list_module = self.portal.sale_packing_list_module
preferred_default_pre_payment_template = \
accounting_module.slapos_pre_payment_template.Base_createCloneDocument(batch_mode=1)
preferred_default_pre_payment_template.edit(
source_section_value = organisation,
source_payment_value=organisation.bank_account
)
preferred_default_pre_payment_subscription_invoice_template = \
accounting_module.template_pre_payment_subscription_sale_invoice_transaction.Base_createCloneDocument(batch_mode=1)
preferred_default_pre_payment_subscription_invoice_template.edit(
source_section_value = organisation,
source_value=organisation
)
preferred_instance_delivery_template = \
sale_packing_list_module.slapos_accounting_instance_delivery_template.Base_createCloneDocument(batch_mode=1)
preferred_instance_delivery_template.edit(
source_section_value = organisation,
source_value=organisation
)
self.portal.sale_trade_condition_module.default_subscription_trade_condition.edit(
source_section_value=organisation,
source_value=organisation
)
system_preference = self.portal.portal_preferences.slapos_default_system_preference
system_preference.edit(
preferred_default_pre_payment_template=preferred_default_pre_payment_template.getRelativeUrl(),
preferred_default_pre_payment_subscription_invoice_template=\
preferred_default_pre_payment_subscription_invoice_template.getRelativeUrl(),
preferred_instance_delivery_template=\
preferred_instance_delivery_template.getRelativeUrl()
)
self.tic()
return organisation
def redefineAccountingTemplatesonPreferencesWithDualOrganisation(self):
# Define a new set of templates and change organisation on them, in this way tests should
# behave the same.
self.login()
fr_organisation = self.makeCustomOrganisation()
zh_organisation = self.makeCustomOrganisation(
price_currency="currency_module/CNY")
# Update Price currency for Chinese company
accounting_module = self.portal.accounting_module
sale_packing_list_module = self.portal.sale_packing_list_module
preferred_default_pre_payment_template = \
accounting_module.slapos_pre_payment_template.Base_createCloneDocument(batch_mode=1)
preferred_default_pre_payment_template.edit(
source_section_value = fr_organisation,
source_payment_value=fr_organisation.bank_account
)
preferred_default_pre_payment_subscription_invoice_template = \
accounting_module.template_pre_payment_subscription_sale_invoice_transaction.Base_createCloneDocument(batch_mode=1)
preferred_default_pre_payment_subscription_invoice_template.edit(
source_section_value=fr_organisation,
source_value=fr_organisation
)
preferred_instance_delivery_template = \
sale_packing_list_module.slapos_accounting_instance_delivery_template.Base_createCloneDocument(batch_mode=1)
preferred_instance_delivery_template.edit(
source_section_value=fr_organisation,
source_value=fr_organisation
)
self.portal.sale_trade_condition_module.default_subscription_trade_condition.edit(
source_section_value=fr_organisation,
source_value=fr_organisation
)
system_preference = self.portal.portal_preferences.slapos_default_system_preference
system_preference.edit(
preferred_default_pre_payment_template=preferred_default_pre_payment_template.getRelativeUrl(),
preferred_default_pre_payment_subscription_invoice_template=\
preferred_default_pre_payment_subscription_invoice_template.getRelativeUrl(),
preferred_instance_delivery_template=\
preferred_instance_delivery_template.getRelativeUrl()
)
self.tic()
return fr_organisation, zh_organisation
class SlapOSTestCaseMixinWithAbort(SlapOSTestCaseMixin):
abort_transaction = 1
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