Commit b9a3cda4 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test: use Subscription Request to bootstrap the project

parent 86275489
...@@ -94,22 +94,87 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin): ...@@ -94,22 +94,87 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
def test_virtual_master_without_accounting_scenario(self): def test_virtual_master_without_accounting_scenario(self):
# create a default project
project = self.addProject()
self.web_site = self.portal.web_site_module.slapos_master_panel self.web_site = self.portal.web_site_module.slapos_master_panel
# some preparation
preference = self.portal.portal_preferences.slapos_default_system_preference ################################################################
preference.edit( # lets join as slapos accountant, which will manages currencies
preferred_subscription_assignment_category_list=[ self.logout()
'function/customer', accountant_reference = 'accountant-%s' % self.generateNewId()
'role/client', self.joinSlapOS(self.web_site, accountant_reference)
'destination_project/%s' % project.getRelativeUrl() self.login()
] accountant_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=accountant_reference).getParentValue()
self.addAccountingManagerAssignment(accountant_person)
self.tic()
# hooray, now it is time to create accounting data
self.login(accountant_person.getUserId())
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()
# some preparation ################################################################
# lets join as slapos sales manager, which will manages trade condition
self.logout() self.logout()
sale_reference = 'sales-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, sale_reference)
self.login()
sale_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=sale_reference).getParentValue()
self.addSaleManagerAssignment(sale_person)
self.tic()
# hooray, now it is time to create sale data
self.login(sale_person.getUserId())
seller_organisation = self.portal.organisation_module.newContent(
portal_type="Organisation",
title="test-seller-%s" % self.generateNewId()
)
seller_bank_account = seller_organisation.newContent(
portal_type="Bank Account",
title="test_bank_account_%s" % self.generateNewId()
)
seller_organisation.validate()
# Create Trade Condition to create Project
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,
source_payment_value=seller_bank_account,
destination_section_value=seller_organisation,
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()
self.tic()
self.logout()
# lets join as slapos administrator, which will own few compute_nodes # lets join as slapos administrator, which will own few compute_nodes
owner_reference = 'owner-%s' % self.generateNewId() owner_reference = 'owner-%s' % self.generateNewId()
self.joinSlapOS(self.web_site, owner_reference) self.joinSlapOS(self.web_site, owner_reference)
...@@ -118,15 +183,35 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -118,15 +183,35 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
owner_person = self.portal.portal_catalog.getResultValue( owner_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login", portal_type="ERP5 Login",
reference=owner_reference).getParentValue() reference=owner_reference).getParentValue()
owner_person.setCareerSubordinationValue(seller_organisation)
"""
# first slapos administrator assignment can only be created by # first slapos administrator assignment can only be created by
# the erp5 manager # the erp5 manager
self.addProjectProductionManagerAssignment(owner_person, project) self.addProjectProductionManagerAssignment(owner_person, project)"""
self.tic() self.tic()
# hooray, now it is time to create compute_nodes # hooray, now it is time to create compute_nodes
self.login(owner_person.getUserId()) self.login(owner_person.getUserId())
# create a default project
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(
preferred_subscription_assignment_category_list=[
'function/customer',
'role/client',
'destination_project/%s' % project.getRelativeUrl()
]
)
self.logout()
self.login(owner_person.getUserId())
public_server_title = 'Public Server for %s' % owner_reference public_server_title = 'Public Server for %s' % owner_reference
public_server_id = self.requestComputeNode(public_server_title, project.getReference()) public_server_id = self.requestComputeNode(public_server_title, project.getReference())
public_server = self.portal.portal_catalog.getResultValue( public_server = self.portal.portal_catalog.getResultValue(
......
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