Commit 9e1d8d75 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: test: factorise accountable project creation

parent 4e52f051
......@@ -161,11 +161,56 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
function='customer'
).open()
def addProject(self):
def addProject(self, is_accountable=False):
project = self.portal.project_module.newContent(
portal_type='Project',
title='project-%s' % self.generateNewId()
)
if is_accountable:
currency = self.portal.currency_module.newContent(
portal_type="Currency",
reference="test-currency-%s" % self.generateNewId(),
short_title="tc%s" % self.generateNewId(),
base_unit_quantity=0.01
)
currency.validate()
seller_organisation = self.portal.organisation_module.newContent(
portal_type="Organisation",
title="test-seller-%s" % self.generateNewId()
)
seller_organisation.newContent(
portal_type="Bank Account",
title="test_bank_account_%s" % self.generateNewId()
)
seller_organisation.validate()
sale_trade_condition = self.portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference='seller_organisation_%s' % seller_organisation.getTitle(),
# XXX hardcoded
specialise="business_process_module/slapos_ultimate_business_process",
destination_project_value=project,
source_value=seller_organisation,
source_section_value=seller_organisation,
price_currency_value=currency
)
sale_trade_condition.newContent(
portal_type="Trade Model Line",
reference="VAT",
resource="service_module/slapos_tax",
base_application="base_amount/invoicing/taxable",
trade_phase="slapos/tax",
price=0.2,
quantity=1.0,
membership_criterion_base_category=('price_currency',),
membership_criterion_category=('price_currency/%s' % currency.getRelativeUrl(),)
)
sale_trade_condition.validate()
# XXX Is it a good idea to have a cross relation?
project.edit(specialise_value=sale_trade_condition)
project.validate()
return project
......
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