Commit 7b62715c authored by Papa Tamsir Kane's avatar Papa Tamsir Kane

erp5_bookmark_manager: Remove live test

parent 13d61093
##############################################################################
#
# 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>
test.erp5.testBookmarkUrl
\ 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