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
self.login(sale_person.getUserId())
assignment = accountant_person.newContent(
portal_type='Assignment',
group='company',
function='accounting/manager'
)
assignment = self.addAccountingManagerAssignment(accountant_person)
self.assertEqual(assignment.checkConsistency(), [])
assignment.open()
self.tic()
self.logout()
......
......@@ -163,31 +163,35 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
# Reset values set on script_ComputeNode_requestSoftwareReleaseChange
self.portal.REQUEST.set(key, None)
def addAccountingManagerAssignment(self, person):
person.newContent(
def _addAssignment(self, person, function, project=None):
assignment = person.newContent(
portal_type='Assignment',
function='accounting/manager'
).open()
destination_project_value=project,
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):
person.newContent(
portal_type='Assignment',
function='sale/manager'
).open()
return self._addAssignment(person, 'sale/manager')
def addSaleAgentAssignment(self, person):
return self._addAssignment(person, 'sale/agent')
def addProjectProductionAgentAssignment(self, person, project):
return self._addAssignment(person, 'production/agent', project)
def addProjectProductionManagerAssignment(self, person, project):
person.newContent(
portal_type='Assignment',
destination_project_value=project,
function='production/manager'
).open()
return self._addAssignment(person, 'production/manager', project)
def addProjectCustomerAssignment(self, person, project):
person.newContent(
portal_type='Assignment',
destination_project_value=project,
function='customer'
).open()
return self._addAssignment(person, 'customer', project)
def addProject(self, organisation=None, currency=None, person=None, is_accountable=False):
assert organisation is None
......@@ -223,7 +227,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
def _addERP5Login(self, document, **kw):
if document.getPortalType() != "Person":
raise ValueError("Only Person supports add ERP5 Login")
login = document.newContent(
portal_type="ERP5 Login",
reference=document.getReference(),
......
......@@ -190,7 +190,7 @@ class TestSlapOSSoftwareInstanceSecurity(TestSlapOSSecurityMixin):
class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
def test_active(self, login_portal_type="Certificate Login"):
def test_active(self, login_portal_type="Certificate Login"):
reference = self._generateRandomUniqueReference('Person')
user_id = self._generateRandomUniqueUserId('Person')
......@@ -244,7 +244,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
# add to function category
self.login()
person.newContent(portal_type='Assignment', function='accounting/manager').open()
self.addAccountingManagerAssignment(person)
self.tic()
self.portal.portal_caches.clearAllCache()
......@@ -271,8 +271,7 @@ class TestSlapOSPersonSecurity(TestSlapOSSecurityMixin):
# add project and function
self.login()
project2 = self.addProject()
person.newContent(portal_type='Assignment',
destination_project_value=project2, function='production/manager').open()
self.addProjectProductionManagerAssignment(person, project2)
self.tic()
self.portal.portal_caches.clearAllCache()
......
......@@ -2449,11 +2449,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
title=reference,
reference=reference
)
person.newContent(
portal_type='Assignment',
function='customer',
destination_project_value=self.project
).open()
self.addProjectCustomerAssignment(person, self.project)
person.newContent(portal_type='ERP5 Login',
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