Commit a7346372 authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: test: create Trade Condition when Project is accountable

parent 9f783dd9
......@@ -176,6 +176,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
def addProject(self, organisation=None, currency=None, person=None, is_accountable=False):
assert organisation is None
if person is None:
assert not is_accountable
project = self.portal.project_module.newContent(
portal_type='Project',
title='project-%s' % self.generateNewId()
......@@ -669,7 +670,9 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
is_accountable=False, base_price=None, has_organisation=False):
if allocation_state not in ('impossible', 'possible', 'allocated'):
raise ValueError('Not supported allocation_state: %s' % allocation_state)
project = self.addProject(is_accountable=is_accountable)
project = self.addProject(
#is_accountable=is_accountable
)
person = self.makePerson(project)
if has_organisation:
organisation = self.portal.organisation_module.newContent(
......@@ -682,18 +685,38 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
release_variation = software_product.contentValues(portal_type='Software Product Release Variation')[0]
type_variation = software_product.contentValues(portal_type='Software Product Type Variation')[0]
if is_accountable and (base_price is not None):
sale_supply = self.portal.sale_supply_module.newContent(
portal_type="Sale Supply",
destination_project_value=project,
price_currency=project.Project_getAccountingCurrency()
if is_accountable:
currency = self.portal.currency_module.newContent(
portal_type="Currency",
title="test %s" % self.generateNewId()
)
currency.validate()
seller_organisation = self.portal.organisation_module.newContent(
portal_type="Organisation",
title="seller-%s" % self.generateNewId()
)
sale_supply.newContent(
portal_type="Sale Supply Line",
base_price=base_price,
resource_value=software_product
seller_organisation.validate()
sale_trade_condition = self.portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
trade_condition_type="instance_tree",
source_section_value=seller_organisation,
source_project_value=project,
price_currency_value=currency,
specialise="business_process_module/slapos_ultimate_business_process"
)
sale_supply.validate()
sale_trade_condition.validate()
if (base_price is not None):
sale_supply = self.portal.sale_supply_module.newContent(
portal_type="Sale Supply",
destination_project_value=project,
price_currency_value=currency
)
sale_supply.newContent(
portal_type="Sale Supply Line",
base_price=base_price,
resource_value=software_product
)
sale_supply.validate()
self.tic()
partition = None
......
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