Commit c60ec10b authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5:

* init preferences in test
* test: wip accounting scenario
* test:  slapos_subscription_request is installed again
parent 1dd6b765
......@@ -25,6 +25,7 @@ import difflib
slapos_folder_list = """slapos_abyss
slapos_base
slapos_contract
slapos_subscription_request
slapos_crm_monitoring
slapos_accounting
slapos_administration
......@@ -897,6 +898,7 @@ slapos_upgrader
slapos_abyss
slapos_base
slapos_contract
slapos_subscription_request
slapos_crm_monitoring
slapos_accounting
slapos_administration
......
......@@ -91,11 +91,16 @@ 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
preference.edit(
preferred_subscription_assignment_category_list=[
'function/customer',
'role/client',
]
)
################################################################
# lets join as slapos accountant, which will manages currencies
......@@ -151,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()
......@@ -240,6 +289,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
self.tic()
self.logout()
self.login()
self.checkServiceSubscriptionRequest(public_server)
# join as the another visitor and request software instance on public
......@@ -306,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(
......@@ -328,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(
......@@ -339,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