Commit c30e558f authored by Romain Courteaud's avatar Romain Courteaud

slapos_erp5: test Sale Trade Condition local roles

parent 2f2bad3a
......@@ -1414,7 +1414,6 @@ class TestOpenSaleOrder(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(delivery, 'F-SALE*', ['Auditor'])
self.assertRoles(delivery, 'F-ACCOUNTING*', ['Auditor'])
def test_OpenSaleOrder_user(self):
reference = 'TESTPERSON-%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person',
......@@ -1452,3 +1451,109 @@ class TestOpenSaleOrder(TestSlapOSGroupRoleSecurityMixin):
self.assertRoles(delivery, 'F-SALE*', ['Auditor'])
self.assertRoles(delivery, 'F-ACCOUNTING*', ['Auditor'])
class TestSaleTradeConditionModule(TestSlapOSGroupRoleSecurityMixin):
def test_SaleTradeConditionModule(self):
module = self.portal.sale_trade_condition_module
self.assertSecurityGroup(module,
['F-SALE*', 'F-ACCOUNTING*', 'F-CUSTOMER',
'R-SHADOW-PERSON', module.Base_getOwnerId()], False)
self.assertRoles(module, 'F-SALE*', ['Auditor', 'Author'])
self.assertRoles(module, 'F-ACCOUNTING*', ['Auditor'])
self.assertRoles(module, 'F-CUSTOMER', ['Auditor'])
self.assertRoles(module, 'R-SHADOW-PERSON', ['Auditor'])
self.assertRoles(module, module.Base_getOwnerId(), ['Owner'])
class TestSaleTradeCondition(TestSlapOSGroupRoleSecurityMixin):
def test_SaleTradeCondition_default(self):
delivery = self.portal.sale_trade_condition_module.newContent(
portal_type='Sale Trade Condition')
self.assertSecurityGroup(delivery,
['F-SALEAGT', 'F-SALEMAN', 'F-ACCOUNTING*', 'R-SHADOW-PERSON',
self.user_id], False)
self.assertRoles(delivery, self.user_id, ['Owner'])
self.assertRoles(delivery, 'F-SALEAGT', ['Assignee'])
self.assertRoles(delivery, 'F-SALEMAN', ['Assignor'])
self.assertRoles(delivery, 'F-ACCOUNTING*', ['Auditor'])
self.assertRoles(delivery, 'R-SHADOW-PERSON', ['Auditor'])
def test_SaleTradeCondition_allUsers(self):
delivery = self.portal.sale_trade_condition_module.newContent(
portal_type='Sale Trade Condition')
delivery.validate()
self.assertSecurityGroup(delivery,
['F-SALEAGT', 'F-SALEMAN', 'F-ACCOUNTING*', 'R-SHADOW-PERSON',
'F-CUSTOMER', self.user_id], False)
self.assertRoles(delivery, self.user_id, ['Owner'])
self.assertRoles(delivery, 'F-SALEAGT', ['Assignee'])
self.assertRoles(delivery, 'F-SALEMAN', ['Assignor'])
self.assertRoles(delivery, 'F-ACCOUNTING*', ['Auditor'])
self.assertRoles(delivery, 'F-CUSTOMER', ['Auditor'])
self.assertRoles(delivery, 'R-SHADOW-PERSON', ['Auditor'])
delivery.invalidate()
self.assertSecurityGroup(delivery,
['F-SALEAGT', 'F-SALEMAN', 'F-ACCOUNTING*', 'R-SHADOW-PERSON',
self.user_id], False)
self.assertRoles(delivery, self.user_id, ['Owner'])
self.assertRoles(delivery, 'F-SALEAGT', ['Assignee'])
self.assertRoles(delivery, 'F-SALEMAN', ['Assignor'])
self.assertRoles(delivery, 'F-ACCOUNTING*', ['Auditor'])
self.assertRoles(delivery, 'R-SHADOW-PERSON', ['Auditor'])
def test_SaleTradeCondition_singleUser(self):
reference = 'TESTPERSON-%s' % self.generateNewId()
person = self.portal.person_module.newContent(portal_type='Person',
reference=reference)
delivery = self.portal.sale_trade_condition_module.newContent(
portal_type='Sale Trade Condition')
delivery.validate()
delivery.edit(destination_value=person)
self.assertSecurityGroup(delivery,
['F-SALEAGT', 'F-SALEMAN', 'F-ACCOUNTING*', 'R-SHADOW-PERSON',
self.user_id, person.getUserId()], False)
self.assertRoles(delivery, self.user_id, ['Owner'])
self.assertRoles(delivery, 'F-SALEAGT', ['Assignee'])
self.assertRoles(delivery, 'F-SALEMAN', ['Assignor'])
self.assertRoles(delivery, 'F-ACCOUNTING*', ['Auditor'])
self.assertRoles(delivery, person.getUserId(), ['Auditor'])
self.assertRoles(delivery, 'R-SHADOW-PERSON', ['Auditor'])
delivery.invalidate()
self.assertSecurityGroup(delivery,
['F-SALEAGT', 'F-SALEMAN', 'F-ACCOUNTING*', 'R-SHADOW-PERSON',
self.user_id], False)
self.assertRoles(delivery, self.user_id, ['Owner'])
self.assertRoles(delivery, 'F-SALEAGT', ['Assignee'])
self.assertRoles(delivery, 'F-SALEMAN', ['Assignor'])
self.assertRoles(delivery, 'F-ACCOUNTING*', ['Auditor'])
self.assertRoles(delivery, 'R-SHADOW-PERSON', ['Auditor'])
def test_SaleTradeCondition_project(self):
project = self.portal.project_module.newContent(portal_type='Project')
delivery = self.portal.sale_trade_condition_module.newContent(
portal_type='Sale Trade Condition')
delivery.validate()
delivery.edit(destination_project_value=project)
self.assertSecurityGroup(delivery,
['F-SALEAGT', 'F-SALEMAN', 'F-ACCOUNTING*', 'R-SHADOW-PERSON',
self.user_id, project.getReference()], False)
self.assertRoles(delivery, self.user_id, ['Owner'])
self.assertRoles(delivery, 'F-SALEAGT', ['Assignee'])
self.assertRoles(delivery, 'F-SALEMAN', ['Assignor'])
self.assertRoles(delivery, 'F-ACCOUNTING*', ['Auditor'])
self.assertRoles(delivery, project.getReference(), ['Auditor'])
self.assertRoles(delivery, 'R-SHADOW-PERSON', ['Auditor'])
delivery.invalidate()
self.assertSecurityGroup(delivery,
['F-SALEAGT', 'F-SALEMAN', 'F-ACCOUNTING*', 'R-SHADOW-PERSON',
self.user_id], False)
self.assertRoles(delivery, self.user_id, ['Owner'])
self.assertRoles(delivery, 'F-SALEAGT', ['Assignee'])
self.assertRoles(delivery, 'F-SALEMAN', ['Assignor'])
self.assertRoles(delivery, 'F-ACCOUNTING*', ['Auditor'])
self.assertRoles(delivery, 'R-SHADOW-PERSON', ['Auditor'])
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