Commit 77779e0e authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test: update virtual master with/without accounting

parent d67187fb
......@@ -91,7 +91,7 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
return instance_node
def bootstrapVirtualMasterTest(self):
def bootstrapVirtualMasterTest(self, is_virtual_master_accountable=True):
self.web_site = self.portal.web_site_module.slapos_master_panel
# some preparation
preference = self.portal.portal_preferences.slapos_default_system_preference
......@@ -146,19 +146,18 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
)
seller_bank_account = seller_organisation.newContent(
portal_type="Bank Account",
title="test_bank_account_%s" % self.generateNewId()
title="test_bank_account_%s" % self.generateNewId(),
price_currency_value=currency
)
seller_bank_account.validate()
seller_organisation.validate()
# Create Trade Condition to create Project
# Sale Trade Condition for Tax
sale_trade_condition = self.portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference='seller_organisation_%s' % seller_organisation.getTitle(),
reference="Tax/payment for: %s" % currency.getRelativeUrl(),
# XXX hardcoded
specialise="business_process_module/slapos_ultimate_business_process",
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()
)
......@@ -175,6 +174,23 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
)
sale_trade_condition.validate()
# Create Trade Condition to create Project
if is_virtual_master_accountable:
source_section_value = seller_organisation
title = "Payable Virtual Master (%s)" % seller_organisation.getTitle()
else:
source_section_value = None
title = "Free Virtual Master (%s)" % seller_organisation.getTitle()
sale_trade_condition = self.portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference=title,
specialise_value=sale_trade_condition,
source_value=seller_organisation,
source_section_value=source_section_value
)
sale_trade_condition.validate()
sale_supply = self.portal.sale_supply_module.newContent(
portal_type="Sale Supply",
price_currency_value=currency
......@@ -187,40 +203,19 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
)
sale_supply.validate()
return currency, seller_organisation, seller_bank_account
return currency, seller_organisation, seller_bank_account, sale_person
def assertRelatedObjectCount(self, document, count):
related_object_list = document.Base_getRelatedObjectList(**{'category.category_strict_membership': 1})
related_object_list = [x.getRelativeUrl() for x in related_object_list]
related_object_list.sort()
assert len(related_object_list) == count, '%i\n%s' % (len(related_object_list), '\n'.join(related_object_list))
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()
)
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_person = self.bootstrapVirtualMasterTest(is_virtual_master_accountable=False)
sale_trade_condition.validate()
self.tic()
self.logout()
......@@ -232,17 +227,13 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
owner_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=owner_reference).getParentValue()
owner_person.setCareerSubordinationValue(seller_organisation)
#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())
self.login(sale_person.getUserId())
# create a default project
project_relative_url = self.addProject(person=owner_person)
......@@ -259,6 +250,11 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
]
)
# first slapos administrator assignment can only be created by
# the erp5 manager
self.addProjectProductionManagerAssignment(owner_person, project)
self.tic()
self.logout()
self.login(owner_person.getUserId())
......@@ -335,18 +331,26 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# XXX Do this for every scenario tests
self.logout()
self.stepCallAlarmList()
self.tic()
for _ in range(3):
self.stepCallAlarmList()
self.tic()
self.login()
# Ensure no unexpected object has been created
# 3 (can reduce to 2) assignment, 1 instance tree, 1 compute node, 1 software installation
# 1 software instance
# 2 credential request
# 3 allocation supply, line, cell
# 1 compute node
# 1 credential request
# 1 instance tree
# 3 open sale order XXX * 2 why
# 2 assignment
# 3 simulation movement
# 3 sale packing list / line
# 2 sale trade condition ( a 3rd trade condition is not linked to the project)
# 1 software installation
# 1 software instance
# 1 software product
related_object_list = project.Base_getRelatedObjectList(**{'category.category_strict_membership': 1})
assert len(related_object_list) == 13, [x.getRelativeUrl() for x in related_object_list]
# 3 subscription request
self.assertRelatedObjectCount(project, 28)
self.stepcheckERP5Consistency()
......@@ -356,7 +360,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
def test_virtual_master_with_accounting_scenario(self):
currency, _, _ = self.bootstrapVirtualMasterTest()
currency, _, _, sale_person = self.bootstrapVirtualMasterTest()
self.logout()
# lets join as slapos administrator, which will own few compute_nodes
......@@ -377,10 +381,9 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# hooray, now it is time to create compute_nodes
self.logout()
self.login(owner_person.getUserId())
self.login(sale_person.getUserId())
# create a default project
project_relative_url = self.addProject(person=owner_person)
project_relative_url = self.addProject(is_accountable=True, person=owner_person)
self.logout()
......@@ -487,7 +490,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# XXX Do this for every scenario tests
self.logout()
for _ in range(20):
for _ in range(2):
self.stepCallAlarmList()
self.tic()
......@@ -518,7 +521,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# XXX Do this for every scenario tests
# XXX Do this for every scenario tests
self.logout()
for _ in range(20):
for _ in range(10):
self.stepCallAlarmList()
self.tic()
self.login()
......@@ -550,24 +553,22 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
self.login()
# Ensure no unexpected object has been created
# 3 (can reduce to 2) assignment, 1 instance tree, 1 compute node, 1 software installation
# 1 software instance
# 3 accounting transaction / line
# 3 allocation supply / line / cell
# 1 compute node
# 2 credential request
# 1 open order
# 1 hosting subscription
# 1 accounting transaction
# 1 packing list
# 7 simulation mvt
# 1 instance tree
# 6 open sale order / line
# 3 (can reduce to 2) assignment
# 16 simulation mvt
# 3 packing list / line
# 4 sale supply / line
# 2 sale trade condition
# 1 software installation
# 1 software instance
# 1 software product
# 1 sale trace condition
# 1 supply, 1 supply line
# 1 open order line / 1 cell
# 3 allocation supply / line / cell
related_object_list = project.Base_getRelatedObjectList(**{'category.category_strict_membership': 1})
assert len(related_object_list) == 29, '%s %s' % (len(related_object_list), [x.getRelativeUrl() for x in related_object_list])
# 3 subscription requests
self.assertRelatedObjectCount(project, 50)
self.stepcheckERP5Consistency()
......@@ -577,18 +578,9 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
def test_virtual_master_slave_without_accounting_scenario(self):
# create a default project
project = self.addProject()
self.web_site = self.portal.web_site_module.slapos_master_panel
_, _, _, sale_person = self.bootstrapVirtualMasterTest()
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.web_site = self.portal.web_site_module.slapos_master_panel
# some preparation
self.logout()
......@@ -601,7 +593,25 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
owner_person = self.portal.portal_catalog.getResultValue(
portal_type="ERP5 Login",
reference=owner_reference).getParentValue()
self.tic()
self.logout()
self.login(sale_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()
]
)
# first slapos administrator assignment can only be created by
# the erp5 manager
self.addProjectProductionManagerAssignment(owner_person, project)
......
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