Commit 69c6cf99 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test: wip accounting scenario

parent 7254fc9a
......@@ -91,9 +91,7 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
return instance_node
class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
def test_virtual_master_without_accounting_scenario(self):
def bootstrapVirtualMasterTest(self):
self.web_site = self.portal.web_site_module.slapos_master_panel
# some preparation
preference = self.portal.portal_preferences.slapos_default_system_preference
......@@ -158,10 +156,54 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
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,
source_payment_value=seller_bank_account,
price_currency_value=currency,
payment_condition_payment_mode='test-%s' % self.generateNewId()
)
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()
sale_supply = self.portal.sale_supply_module.newContent(
portal_type="Sale Supply",
price_currency_value=currency
)
# XXX Put price in sale supply module
sale_supply.newContent(
portal_type="Sale Supply Line",
base_price=42,
resource="service_module/slapos_virtual_master_subscription"
)
sale_supply.validate()
return currency, seller_organisation, seller_bank_account
class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
def test_virtual_master_without_accounting_scenario(self):
currency, seller_organisation, seller_bank_account = self.bootstrapVirtualMasterTest()
# Create Trade Condition to create Project
sale_trade_condition = self.portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference='free_for_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,
source_payment_value=seller_bank_account,
destination_section_value=seller_organisation,
price_currency_value=currency,
payment_condition_payment_mode='test-%s' % self.generateNewId()
......@@ -314,9 +356,36 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
def test_virtual_master_with_accounting_scenario(self):
currency, _, _ = self.bootstrapVirtualMasterTest()
self.logout()
# lets join as slapos administrator, which will own few compute_nodes
owner_reference = 'owner-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, owner_reference)
self.login()
owner_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=owner_reference).getParentValue()
#owner_person.setCareerSubordinationValue(seller_organisation)
"""
# first slapos administrator assignment can only be created by
# the erp5 manager
self.addProjectProductionManagerAssignment(owner_person, project)"""
self.tic()
# hooray, now it is time to create compute_nodes
self.logout()
self.login(owner_person.getUserId())
# create a default project
project = self.addProject(is_accountable=True)
self.web_site = self.portal.web_site_module.slapos_master_panel
project_relative_url = self.addProject(person=owner_person)
self.logout()
self.login()
project = self.portal.restrictedTraverse(project_relative_url)
preference = self.portal.portal_preferences.slapos_default_system_preference
preference.edit(
......@@ -336,8 +405,9 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
sale_supply = self.portal.sale_supply_module.newContent(
portal_type="Sale Supply",
destination_project_value=project,
price_currency_value=project.getSpecialiseValue().getPriceCurrencyValue()
title="price for %s" % software_product.getRelativeUrl(),
source_project_value=project,
price_currency_value=currency
)
# XXX Put price in sale supply module
sale_supply.newContent(
......@@ -347,6 +417,20 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
)
sale_supply.validate()
sale_supply = self.portal.sale_supply_module.newContent(
portal_type="Sale Supply",
title="price for compute node",
destination_project_value=project,
price_currency_value=currency
)
# XXX Put price in sale supply module
sale_supply.newContent(
portal_type="Sale Supply Line",
base_price=99,
resource="service_module/slapos_compute_node_subscription"
)
sale_supply.validate()
# some preparation
self.logout()
......
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