Commit 48a6f8f8 authored by Papa Tamsir Kane's avatar Papa Tamsir Kane

erp5_web_bookmark: rename test class and add test for alarm

parent 16079faa
...@@ -26,15 +26,17 @@ ...@@ -26,15 +26,17 @@
############################################################################## ##############################################################################
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestUrl(SecurityTestCase): class TestBookmarkUrl(SecurityTestCase, ERP5TypeTestCase):
""" """
Test url_module Test url module
""" """
user_id_dict = {} user_id_dict = {}
objects_to_delete = []
def getTitle(self): def getTitle(self):
return "testUrl" return "testBookmarkUrl"
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
""" """
...@@ -70,12 +72,24 @@ class TestUrl(SecurityTestCase): ...@@ -70,12 +72,24 @@ class TestUrl(SecurityTestCase):
self.url_module = self.portal.getDefaultModule(portal_type='Url') self.url_module = self.portal.getDefaultModule(portal_type='Url')
self.assertTrue(self.url_module is not None) self.assertTrue(self.url_module is not None)
def _newUrl(self, reference, url_string, title='', description=''): 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( return self.url_module.newContent(
portal_type='Url', portal_type='Url',
reference=reference,
title=title, title=title,
url_string=url_string, coordinate_text=coordinate_text,
description=description, description=description,
) )
...@@ -88,17 +102,37 @@ class TestUrl(SecurityTestCase): ...@@ -88,17 +102,37 @@ class TestUrl(SecurityTestCase):
self.assertUserCanAccessDocument(self.user_id_dict['testuser1'], self.url_module) self.assertUserCanAccessDocument(self.user_id_dict['testuser1'], self.url_module)
self.assertUserCanViewDocument(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.assertUserCanAddDocument(self.user_id_dict['testuser1'], self.url_module)
self.loginByUserName('testuser1') self.loginByUserName('testuser1')
url = self._newUrl(reference='url1', url_string='testurl1.com') url = self._newUrl(title='testurl1', coordinate_text='https://testurl1.com')
self.assertUserCanAccessDocument(self.user_id_dict['testuser1'], url) self.assertUserCanAccessDocument(self.user_id_dict['testuser1'], url)
self.assertUserCanViewDocument(self.user_id_dict['testuser1'], url) self.assertUserCanViewDocument(self.user_id_dict['testuser1'], url)
# self.assertUserCanAddDocument(self.user_id_dict['testuser1'], url) self.assertUserCanAddDocument(self.user_id_dict['testuser1'], url)
def test_03_only_owner_can_access_url(self): def test_03_only_owner_can_access_url(self):
self.loginByUserName('testuser1') self.loginByUserName('testuser1')
url = self._newUrl(reference='url1', url_string='testurl1.com') url = self._newUrl(title='testurl1', coordinate_text='https://testurl1.com')
self.failIfUserCanAccessDocument(self.user_id_dict['testuser2'], url) self.failIfUserCanAccessDocument(self.user_id_dict['testuser2'], url)
self.failIfUserCanViewDocument(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
...@@ -6,9 +6,15 @@ ...@@ -6,9 +6,15 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testUrl</string> </value> <value> <string>testBookmarkUrl</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -18,7 +24,7 @@ ...@@ -18,7 +24,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.testUrl</string> </value> <value> <string>test.erp5.testBookmarkUrl</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
...@@ -49,13 +55,28 @@ ...@@ -49,13 +55,28 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <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> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -68,7 +89,7 @@ ...@@ -68,7 +89,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -77,7 +98,7 @@ ...@@ -77,7 +98,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="3" aka="AAAAAAAAAAM="> <record id="4" aka="AAAAAAAAAAQ=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle> </pickle>
......
test.erp5.testUrl test.erp5.testBookmarkUrl
\ No newline at end of file \ 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