Commit aaf412ae authored by Papa Tamsir Kane's avatar Papa Tamsir Kane

erp5_curation_request: App portal roles and live tests

parent 7b62715c
<type_roles>
<role id='Auditor; Author'>
<property id='title'>Default</property>
<multi_property id='category'>group/my_group</multi_property>
</role>
</type_roles>
\ No newline at end of file
<type_roles>
<role id='Assignor; Assignee; Associate; Auditor; Author'>
<property id='title'>Default</property>
<multi_property id='category'>group/my_group</multi_property>
</role>
</type_roles>
\ No newline at end of file
<type_roles>
<role id='Author; Auditor'>
<property id='title'>Default</property>
<multi_property id='category'>group/my_group</multi_property>
</role>
</type_roles>
\ No newline at end of file
<type_roles>
<role id='Assignor; Assignee; Associate; Auditor; Author'>
<property id='title'>Default</property>
<multi_property id='category'>group/my_group</multi_property>
</role>
</type_roles>
\ No newline at end of file
<type_roles>
</type_roles>
\ No newline at end of file
<type_roles>
<role id='Author; Auditor'>
<property id='title'>Default</property>
<multi_property id='category'>group/my_group</multi_property>
</role>
</type_roles>
\ No newline at end of file
<type_roles>
<role id='Assignor; Assignee; Associate; Auditor; Author'>
<property id='title'>Default</property>
<multi_property id='category'>group/my_group</multi_property>
</role>
</type_roles>
\ No newline at end of file
<type_roles>
<role id='Auditor; Author'>
<property id='title'>Default</property>
<multi_property id='category'>group/my_group</multi_property>
</role>
</type_roles>
\ No newline at end of file
<type_roles>
<role id='Assignor; Assignee; Associate; Auditor; Author'>
<property id='title'>Default</property>
<multi_property id='category'>group/my_group</multi_property>
</role>
</type_roles>
\ No newline at end of file
##############################################################################
#
# Copyright (c) 2002-2017 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestBookmarkUrl(SecurityTestCase, ERP5TypeTestCase):
"""
Test url module
"""
user_id_dict = {}
objects_to_delete = []
def getTitle(self):
return "testBookmarkUrl"
def getBusinessTemplateList(self):
"""
Tuple of Business Templates we need to install
"""
return ('erp5_base',)
def afterSetUp(self):
"""
This is ran before anything, used to set the environment
"""
# create test users if theydo not already exist
user_list = [
dict(reference='testuser1', password='testuser1', person_kw=dict(title='testuser1'),
assignment_kw=dict(group='my_group')),
dict(reference='testuser2', password='testuser2', person_kw=dict(title='testuser2'),
assignment_kw=dict(group='my_group')),
dict(reference='testuser3', password='testuser3', person_kw=dict(title='testuser3'),
assignment_kw={})
]
for user in user_list:
acl_user = self.portal.acl_users.searchUsers(login=user['reference'], exact_match =True)
if not acl_user:
created_user = self.createUser(user['reference'], user['password'], user['person_kw'])
self.user_id_dict[user['reference']] = created_user.Person_getUserId()
self.createUserAssignment(created_user, user['assignment_kw'])
else:
self.user_id_dict[user['reference']] = acl_user[0]['userid']
self.commit()
self.tic()
self.url_module = self.portal.getDefaultModule(portal_type='Url')
self.assertTrue(self.url_module is not None)
def beforeTearDown(self):
portal = self.portal
# delete objects creared by the tests
for path in self.objects_to_delete:
created_object = portal.unrestrictedTraverse(path, None)
if created_object is None:
continue
created_object_id = created_object.getId()
created_object_parent = created_object.getParentValue()
created_object_parent._delObject(created_object_id)
# Unindex deleted objects
self.tic()
def _newUrl(self, coordinate_text, title='', description=''):
return self.url_module.newContent(
portal_type='Url',
title=title,
coordinate_text=coordinate_text,
description=description,
)
def test_01_non_group_user_cannot_access_module(self):
self.failIfUserCanAccessDocument(self.user_id_dict['testuser3'], self.url_module)
self.failIfUserCanViewDocument(self.user_id_dict['testuser3'], self.url_module)
self.failIfUserCanAddDocument(self.user_id_dict['testuser3'], self.url_module)
def test_02_group_user_can_create_url(self):
self.assertUserCanAccessDocument(self.user_id_dict['testuser1'], self.url_module)
self.assertUserCanViewDocument(self.user_id_dict['testuser1'], self.url_module)
self.assertUserCanAddDocument(self.user_id_dict['testuser1'], self.url_module)
self.loginByUserName('testuser1')
url = self._newUrl(title='testurl1', coordinate_text='https://testurl1.com')
self.assertUserCanAccessDocument(self.user_id_dict['testuser1'], url)
self.assertUserCanViewDocument(self.user_id_dict['testuser1'], url)
self.assertUserCanAddDocument(self.user_id_dict['testuser1'], url)
def test_03_only_owner_can_access_url(self):
self.loginByUserName('testuser1')
url = self._newUrl(title='testurl1', coordinate_text='https://testurl1.com')
self.failIfUserCanAccessDocument(self.user_id_dict['testuser2'], url)
self.failIfUserCanViewDocument(self.user_id_dict['testuser2'], url)
def test_04_curation_request_is_created_for_draft_urls(self):
self.login()
url = self._newUrl(title='testurl1', coordinate_text='https://testurl1.com')
self.tic()
self.objects_to_delete.append(url.getPath())
alarm = self.portal.portal_alarms.create_curation_request_for_new_url
alarm.activeSense()
self.tic()
curation_request_lines = url.getAggregateRelatedValueList(portal_type='Curation Request Line')
self.assertEqual(len(curation_request_lines), 1)
curation_request = curation_request_lines[0].getParentValue()
self.objects_to_delete.append(curation_request.getPath())
for line in curation_request.contentValues(portal_type='Curation Request Line'):
aggregated = line.getAggregateValue()
if aggregated.getPortalType() == 'Curation Record':
self.objects_to_delete.append(aggregated.getPath())
break
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testBookmarkUrl</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testBookmarkUrl</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
##############################################################################
#
# Copyright (c) 2002-2017 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestCurationRequest(ERP5TypeTestCase):
"""
Test Curation Request
"""
objects_to_delete = []
def getTitle(self):
return "testCurationRequest"
def getBusinessTemplateList(self):
"""
Tuple of Business Templates we need to install
"""
return ('erp5_base',)
def afterSetUp(self):
self.curation_request_module = self.portal.getDefaultModule(portal_type='Curation Request')
self.assertTrue(self.curation_request_module is not None)
def beforeTearDown(self):
portal = self.portal
# delete objects creared by the tests
for path in self.objects_to_delete:
created_object = portal.unrestrictedTraverse(path, None)
if created_object is None:
continue
created_object_id = created_object.getId()
created_object_parent = created_object.getParentValue()
created_object_parent._delObject(created_object_id)
# Unindex deleted objects
self.tic()
def _new_curation_request(self, objects_to_delete, title='', business_process=None,):
if business_process is None:
business_process = self.portal.portal_catalog(portal_type = "Business Process", id="curation_request_business_process")[0]
cr = self.curation_request_module.newContent(
portal_type='Curation Request',
title=title,
#specialise = business_process
)
cr.setSpecialiseValue(business_process)
objects_to_delete.append(cr.getPath())
return cr
def _get_curation_request_lines_and_schedule_deletion(self, curation_request, objects_to_delete):
lines = curation_request.contentValues(portal_type='Curation Request Line')
objects_to_delete.extend([line.getAggregateValue().getPath() for line in lines])
return lines
def _get_decisions_and_schedule_deletion(self, curation_request, objects_to_delete):
decisions = curation_request.getCausalityRelatedValueList(portal_type='Decision')
objects_to_delete.extend([decision.getPath() for decision in decisions])
return decisions
def test_01_one_curation_record_is_created_for_new_curation_request(self):
self.login()
curation_request = self._new_curation_request(self.objects_to_delete, title='test cr 1')
lines = self._get_curation_request_lines_and_schedule_deletion(curation_request, self.objects_to_delete)
self.assertEqual(len(lines), 1)
self.assertEqual(lines[0].getAggregateValue().getPortalType(), 'Curation Record')
def test_02_create_decision_by_business_process(self):
self.login()
curation_request = self._new_curation_request(self.objects_to_delete, title='test cr 1')
self._get_curation_request_lines_and_schedule_deletion(curation_request, self.objects_to_delete)
curation_request.submit()
self.tic()
decisions = self._get_decisions_and_schedule_deletion(curation_request, self.objects_to_delete)
self.assertEqual(len(decisions), 1)
def _create_curation_request_awaiting_validation(self):
self.login()
curation_request = self._new_curation_request(self.objects_to_delete, title='test cr 1')
lines = self._get_curation_request_lines_and_schedule_deletion(curation_request, self.objects_to_delete)
self.assertEqual(len(lines), 1)
curated = lines[0].getAggregateValue()
curation_request.submit()
self.tic()
self._get_decisions_and_schedule_deletion(curation_request, self.objects_to_delete)
return (curation_request, curated)
def test_03_curation_request_lvalidation_publishes_curated_objects(self):
curation_request, curated = self._create_curation_request_awaiting_validation()
curation_request.validate()
self.assertEqual(curation_request.getSimulationState(), 'validated')
self.assertEqual(curated.getValidationState(), 'published')
def test_04_curation_request_invalidation_cancels_curated_objects(self):
curation_request, curated = self._create_curation_request_awaiting_validation()
curation_request.reject()
self.assertEqual(curation_request.getSimulationState(), 'rejected')
self.assertEqual(curated.getValidationState(), 'cancelled')
def _create_curation_request_awaiting_decision(self):
self.login()
curation_request = self._new_curation_request(self.objects_to_delete, title='test cr 1')
self._get_curation_request_lines_and_schedule_deletion(curation_request, self.objects_to_delete)
curation_request.submit()
self.tic()
decisions = self._get_decisions_and_schedule_deletion(curation_request, self.objects_to_delete)
self.assertEqual(len(decisions), 1)
decision = decisions[0]
return (curation_request, decision)
def test_05_decision_approval_validates_curation_request(self):
curation_request, decision = self._create_curation_request_awaiting_decision()
self.portal.portal_workflow.doActionFor(decision, 'approve_action')
self.tic()
self.assertEqual(curation_request.getSimulationState(), 'validated')
def test_06_decision_refusal_invalidates_curation_request(self):
curation_request, decision = self._create_curation_request_awaiting_decision()
self.portal.portal_workflow.doActionFor(decision, 'refuse_action')
self.tic()
self.assertEqual(curation_request.getSimulationState(), 'rejected')
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testCurationRequest</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testCurationRequest</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
erp5_core
erp5_base
\ No newline at end of file
Curation Record
Curation Record Module
Curation Request
Curation Request Module
Decision
Decision Line
Decision Module
Url
Url Module
\ No newline at end of file
test.erp5.testCurationRequest
test.erp5.testBookmarkUrl
\ No newline at end of file
erp5_web_bookmark
erp5_curation_request
\ No newline at end of file
erp5_curation_request_test
\ No newline at end of file
0.1
\ No newline at end of file
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