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