Commit 5fcf7ef6 authored by Rafael Monnerat's avatar Rafael Monnerat

erp5_credential: Test create assignment w/o start/stop date

parent 5c7db280
...@@ -263,6 +263,18 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -263,6 +263,18 @@ class TestERP5Credential(ERP5TypeTestCase):
self.tic() self.tic()
self.logout() self.logout()
def stepSetCredentialAssignmentDurationProperty(self, sequence=None):
if sequence is None:
sequence = {}
assignment_duration = sequence.get("assignment_duration",
20)
self.login()
preference = self._getPreference()
preference.edit(preferred_credential_assignment_duration=assignment_duration)
self._enablePreference()
self.tic()
self.logout()
def stepSetOrganisationCredentialUpdateAutomaticApprovalPreferences(self, def stepSetOrganisationCredentialUpdateAutomaticApprovalPreferences(self,
sequence=None, sequence_list=None, **kw): sequence=None, sequence_list=None, **kw):
self.login() self.login()
...@@ -310,6 +322,27 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -310,6 +322,27 @@ class TestERP5Credential(ERP5TypeTestCase):
assignment = assignment_list[0] assignment = assignment_list[0]
self.assertEqual(assignment.getFunction(), assignment_function) self.assertEqual(assignment.getFunction(), assignment_function)
self.assertEqual(assignment.getRole(), assignment_role) self.assertEqual(assignment.getRole(), assignment_role)
def stepCheckAssignmentWithoutStopDate(self, sequence):
reference = sequence["reference"]
person = self.portal.acl_users.getUser(reference).getUserValue()
assignment_list = person.objectValues(portal_type="Assignment")
self.assertEqual(len(assignment_list), 1)
assignment = assignment_list[0]
self.assertEqual(assignment.getStartDate(), None)
self.assertEqual(assignment.getStopDate(), None)
def stepCheckAssignmentWithStopDate(self, sequence):
reference = sequence["reference"]
person = self.portal.acl_users.getUser(reference).getUserValue()
assignment_list = person.objectValues(portal_type="Assignment")
self.assertEqual(len(assignment_list), 1)
assignment = assignment_list[0]
self.assertNotEqual(assignment.getStartDate(), None)
self.assertTrue(assignment.getStartDate() < DateTime())
assignment_duration = sequence['assignment_duration']
self.assertTrue(assignment.getStopDate() < DateTime()+assignment_duration)
self.assertTrue(assignment.getStopDate() > DateTime()+assignment_duration-1)
def getUserFolder(self): def getUserFolder(self):
"""Returns the acl_users. """ """Returns the acl_users. """
...@@ -1096,6 +1129,36 @@ class TestERP5Credential(ERP5TypeTestCase): ...@@ -1096,6 +1129,36 @@ class TestERP5Credential(ERP5TypeTestCase):
assignment_role="client") assignment_role="client")
self.stepCheckAssignmentAfterActiveLogin(sequence) self.stepCheckAssignmentAfterActiveLogin(sequence)
def testAssignmentCreationUsingSystemPreferenceDurationProperty(self):
"""
Check that the category list are used correctly to create a new
assignment
"""
sequence = dict(automatic_call=False)
self.stepSetCredentialRequestAutomaticApprovalPreferences(sequence)
self.stepSetCredentialAssignmentPropertyList()
self.stepSetCredentialAssignmentDurationProperty(
dict(assignment_duration=0))
self._createCredentialRequest()
sequence = dict(reference="barney",
assignment_function="member",
assignment_role="internal")
self.stepCheckAssignmentAfterActiveLogin(sequence)
self.stepCheckAssignmentWithoutStopDate(sequence)
category_list = ["role/client", "function/agent"]
self.stepSetCredentialAssignmentPropertyList(
dict(category_list=category_list))
assignment_duration = 20
self.stepSetCredentialAssignmentDurationProperty(
dict(assignment_duration=assignment_duration))
self._createCredentialRequest(reference="credential_user")
sequence = dict(reference="credential_user",
assignment_function="agent",
assignment_role="client",
assignment_duration=assignment_duration)
self.stepCheckAssignmentAfterActiveLogin(sequence)
self.stepCheckAssignmentWithStopDate(sequence)
def testERP5Site_activeLogin(self): def testERP5Site_activeLogin(self):
""" """
Test if the script WebSection_activeLogin will create one user Test if the script WebSection_activeLogin will create one user
......
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