Commit 1a0cc8f2 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_*: Update test to make assignment creation simpler

   Provide all common options as a method, so it is easy to understand security.
parent 66083493
...@@ -28,13 +28,8 @@ class TestSlapOSManualAccountingScenarioMixin(TestSlapOSVirtualMasterScenarioMix ...@@ -28,13 +28,8 @@ class TestSlapOSManualAccountingScenarioMixin(TestSlapOSVirtualMasterScenarioMix
self.login(sale_person.getUserId()) self.login(sale_person.getUserId())
assignment = accountant_person.newContent( assignment = self.addAccountingManagerAssignment(accountant_person)
portal_type='Assignment',
group='company',
function='accounting/manager'
)
self.assertEqual(assignment.checkConsistency(), []) self.assertEqual(assignment.checkConsistency(), [])
assignment.open()
self.tic() self.tic()
self.logout() self.logout()
......
...@@ -163,31 +163,35 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -163,31 +163,35 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
# Reset values set on script_ComputeNode_requestSoftwareReleaseChange # Reset values set on script_ComputeNode_requestSoftwareReleaseChange
self.portal.REQUEST.set(key, None) self.portal.REQUEST.set(key, None)
def addAccountingManagerAssignment(self, person): def _addAssignment(self, person, function, project=None):
person.newContent( assignment = person.newContent(
portal_type='Assignment', portal_type='Assignment',
function='accounting/manager' destination_project_value=project,
).open() function=function
)
assignment.open()
return assignment
def addAccountingManagerAssignment(self, person):
return self._addAssignment(person, 'accounting/manager')
def addAccountingAgentAssignment(self, person):
return self._addAssignment(person, 'accounting/agent')
def addSaleManagerAssignment(self, person): def addSaleManagerAssignment(self, person):
person.newContent( return self._addAssignment(person, 'sale/manager')
portal_type='Assignment',
function='sale/manager' def addSaleAgentAssignment(self, person):
).open() return self._addAssignment(person, 'sale/agent')
def addProjectProductionAgentAssignment(self, person, project):
return self._addAssignment(person, 'production/agent', project)
def addProjectProductionManagerAssignment(self, person, project): def addProjectProductionManagerAssignment(self, person, project):
person.newContent( return self._addAssignment(person, 'production/manager', project)
portal_type='Assignment',
destination_project_value=project,
function='production/manager'
).open()
def addProjectCustomerAssignment(self, person, project): def addProjectCustomerAssignment(self, person, project):
person.newContent( return self._addAssignment(person, 'customer', project)
portal_type='Assignment',
destination_project_value=project,
function='customer'
).open()
def addProject(self, organisation=None, currency=None, person=None, is_accountable=False): def addProject(self, organisation=None, currency=None, person=None, is_accountable=False):
assert organisation is None assert organisation is None
......
...@@ -244,7 +244,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -244,7 +244,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
# add to function category # add to function category
self.login() self.login()
person.newContent(portal_type='Assignment', function='accounting/manager').open() self.addAccountingManagerAssignment(person)
self.tic() self.tic()
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
...@@ -271,8 +271,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin): ...@@ -271,8 +271,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
# add project and function # add project and function
self.login() self.login()
project2 = self.addProject() project2 = self.addProject()
person.newContent(portal_type='Assignment', self.addProjectProductionManagerAssignment(person, project2)
destination_project_value=project2, function='production/manager').open()
self.tic() self.tic()
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
......
...@@ -2449,11 +2449,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2449,11 +2449,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
title=reference, title=reference,
reference=reference reference=reference
) )
person.newContent( self.addProjectCustomerAssignment(person, self.project)
portal_type='Assignment',
function='customer',
destination_project_value=self.project
).open()
person.newContent(portal_type='ERP5 Login', person.newContent(portal_type='ERP5 Login',
reference=reference, password=password).validate() reference=reference, password=password).validate()
......
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