Commit 04867d52 authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5:

* test: define currency on the organisation
* test: scenario for money deposit
* test: typo
* test: apply tax amount only if the resource is taxable
* allow shadow user to view Organisation
* test: reduce number of alarm calls
parent 57e27fdc
......@@ -8,6 +8,9 @@
<item>Auditor</item>
<item>Author</item>
</role>
<role id='R-SHADOW-PERSON'>
<item>Auditor</item>
</role>
</local_roles>
<local_role_group_ids>
<local_role_group_id id='function'>
......@@ -16,5 +19,8 @@
<principal id='F-SALE*'>Auditor</principal>
<principal id='F-SALE*'>Author</principal>
</local_role_group_id>
<local_role_group_id id='shadow'>
<principal id='R-SHADOW-PERSON'>Auditor</principal>
</local_role_group_id>
</local_role_group_ids>
</local_roles_item>
\ No newline at end of file
......@@ -5,6 +5,12 @@
<multi_property id='category'>function/accounting*</multi_property>
<multi_property id='base_category'>function</multi_property>
</role>
<role id='Auditor'>
<property id='title'>Person Shadow</property>
<multi_property id='categories'>local_role_group/shadow</multi_property>
<multi_property id='category'>role/shadow/person</multi_property>
<multi_property id='base_category'>role</multi_property>
</role>
<role id='Author; Auditor'>
<property id='title'>Sale</property>
<multi_property id='categories'>local_role_group/function</multi_property>
......
......@@ -11,6 +11,12 @@
<multi_property id='category'>function/accounting/manager</multi_property>
<multi_property id='base_category'>function</multi_property>
</role>
<role id='Auditor'>
<property id='title'>Person Shadow</property>
<multi_property id='categories'>local_role_group/shadow</multi_property>
<multi_property id='category'>role/shadow/person</multi_property>
<multi_property id='base_category'>role</multi_property>
</role>
<role id='Assignee'>
<property id='title'>Sale Agent</property>
<multi_property id='categories'>local_role_group/function</multi_property>
......
......@@ -6,7 +6,6 @@
##############################################################################
from erp5.component.test.SlapOSTestCaseDefaultScenarioMixin import DefaultScenarioMixin
# from DateTime import DateTime
class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
......@@ -142,7 +141,9 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
seller_organisation = self.portal.organisation_module.newContent(
portal_type="Organisation",
title="test-seller-%s" % self.generateNewId()
title="test-seller-%s" % self.generateNewId(),
# required to generate accounting report
price_currency_value=currency
)
seller_bank_account = seller_organisation.newContent(
portal_type="Bank Account",
......@@ -169,8 +170,8 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
trade_phase="slapos/tax",
price=0.2,
quantity=1.0,
membership_criterion_base_category=('price_currency',),
membership_criterion_category=('price_currency/%s' % currency.getRelativeUrl(),)
membership_criterion_base_category=('price_currency', 'base_contribution'),
membership_criterion_category=('price_currency/%s' % currency.getRelativeUrl(), 'base_contribution/base_amount/invoicing/taxable')
)
sale_trade_condition.validate()
......@@ -206,6 +207,17 @@ class TestSlapOSVirtualMasterScenarioMixin(DefaultScenarioMixin):
return currency, seller_organisation, seller_bank_account, sale_person
def checkERP5StateBeforeExit(self):
self.logout()
self.stepCallAlarmList()
self.tic()
self.login()
self.stepcheckERP5Consistency()
# after accept, an email is send containing the reset link
last_message = self.portal.MailHost._last_message
assert last_message is None, last_message
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]
......@@ -330,12 +342,6 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
self.tic()
# XXX Do this for every scenario tests
self.logout()
for _ in range(3):
self.stepCallAlarmList()
self.tic()
self.login()
# Ensure no unexpected object has been created
# 3 allocation supply, line, cell
......@@ -353,11 +359,46 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# 3 subscription request
self.assertRelatedObjectCount(project, 28)
self.stepcheckERP5Consistency()
self.checkERP5StateBeforeExit()
# after accept, an email is send containing the reset link
last_message = self.portal.MailHost._last_message
assert last_message is None, last_message
def test_deposit_with_accounting_scenario(self):
currency, _, _, _ = self.bootstrapVirtualMasterTest(is_virtual_master_accountable=True)
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()
self.tic()
# hooray
self.logout()
self.login(owner_person.getUserId())
# XXX XXX do reservation payment for a huge amount, to check if other services are ok
total_price = 1234
# Action to submit project subscription
def wrapWithShadow(person, *arg):
return person.Person_addDepositPayment(*arg)
payment_transaction = owner_person.Person_restrictMethodAsShadowUser(
shadow_document=owner_person,
callable_object=wrapWithShadow,
argument_list=[owner_person, total_price, currency.getRelativeUrl(), 1])
self.tic()
self.logout()
self.login()
payment_transaction.PaymentTransaction_acceptDepositPayment()
self.tic()
assert payment_transaction.receivable.getGroupingReference(None) is not None
self.checkERP5StateBeforeExit()
def test_virtual_master_with_accounting_scenario(self):
......@@ -489,12 +530,6 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
public_server_software, public_instance_type,
public_server, project.getReference())
# XXX Do this for every scenario tests
self.logout()
for _ in range(2):
self.stepCallAlarmList()
self.tic()
self.login()
public_person = self.portal.portal_catalog.getResultValue(
portal_type='ERP5 Login', reference=public_reference).getParentValue()
......@@ -519,14 +554,6 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
self.tic()
# XXX Do this for every scenario tests
# XXX Do this for every scenario tests
self.logout()
for _ in range(10):
self.stepCallAlarmList()
self.tic()
self.login()
# Check stock
inventory_list = self.portal.portal_simulation.getCurrentInventoryList(**{
'group_by_section': False,
......@@ -571,11 +598,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# 3 subscription requests
self.assertRelatedObjectCount(project, 50)
self.stepcheckERP5Consistency()
# after accept, an email is send containing the reset link
last_message = self.portal.MailHost._last_message
assert last_message is None, last_message
self.checkERP5StateBeforeExit()
def test_virtual_master_slave_without_accounting_scenario(self):
......@@ -709,11 +732,6 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
self.tic()
# XXX Do this for every scenario tests
self.logout()
self.stepCallAlarmList()
self.tic()
self.login()
# Ensure no unexpected object has been created
# 6 allocation supply/line/cell
......@@ -730,11 +748,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# 4 subscription request
self.assertRelatedObjectCount(project, 37)
self.stepcheckERP5Consistency()
# after accept, an email is send containing the reset link
last_message = self.portal.MailHost._last_message
assert last_message is None, last_message
self.checkERP5StateBeforeExit()
def test_virtual_master_slave_on_same_tree_without_accounting_scenario(self):
......@@ -849,11 +863,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# 3 subscription request
self.assertRelatedObjectCount(project, 23)
self.stepcheckERP5Consistency()
# after accept, an email is send containing the reset link
last_message = self.portal.MailHost._last_message
assert last_message is None, last_message
self.checkERP5StateBeforeExit()
def test_virtual_master_on_remote_tree_without_accounting_scenario(self):
......@@ -1078,12 +1088,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# 2 subscription requests
self.assertRelatedObjectCount(project, 22)
self.stepcheckERP5Consistency()
# after accept, an email is send containing the reset link
last_message = self.portal.MailHost._last_message
assert last_message is None, last_message
self.checkERP5StateBeforeExit()
def test_virtual_master_slave_instance_on_remote_tree_without_accounting_scenario(self):
......@@ -1328,11 +1333,7 @@ class TestSlapOSVirtualMasterScenario(TestSlapOSVirtualMasterScenarioMixin):
# 2 subscription requests
self.assertRelatedObjectCount(project, 22)
self.stepcheckERP5Consistency()
# after accept, an email is send containing the reset link
last_message = self.portal.MailHost._last_message
assert last_message is None, last_message
self.checkERP5StateBeforeExit()
def test_open_order_with_service_scenario(self):
......
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