From 7d544ec6dc316a53e938e461b17c17424bc679f3 Mon Sep 17 00:00:00 2001 From: Gabriel Monnerat <gabriel@tiolive.com> Date: Tue, 1 Mar 2011 23:30:04 +0000 Subject: [PATCH] refactor test to validate script with normal user in erp5 git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43871 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../TestTemplateItem/testUNGSecurity.py | 41 +++++++++++++++++-- bt5/erp5_web_ung_role/bt/revision | 2 +- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/bt5/erp5_web_ung_role/TestTemplateItem/testUNGSecurity.py b/bt5/erp5_web_ung_role/TestTemplateItem/testUNGSecurity.py index 5f181dedd6..7ec9983869 100644 --- a/bt5/erp5_web_ung_role/TestTemplateItem/testUNGSecurity.py +++ b/bt5/erp5_web_ung_role/TestTemplateItem/testUNGSecurity.py @@ -27,6 +27,8 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from zExceptions import Unauthorized +from DateTime import DateTime +import json class TestUNGSecurity(ERP5TypeTestCase): """""" @@ -125,7 +127,7 @@ class TestUNGSecurity(ERP5TypeTestCase): self.assertEquals(web_table.getFollowUpValue().getFirstName(), "Gabriel") def testBase_updateCalendarEventListWithERP5User(self): - """ """ + """ Test script Base_updateCalendarEventList with erp5 user""" person = self.portal.person_module.newContent(portal_type='Person', reference="ung_user") assignment = person.newContent(portal_type='Assignment') @@ -137,6 +139,39 @@ class TestUNGSecurity(ERP5TypeTestCase): self.portal.Base_updateCalendarEventList, ("list")) self.login("ung_user") - event_list = self.portal.Base_updateCalendarEventList("list") - self.assertEquals(event_list, []) + event_list = json.loads(self.portal.Base_updateCalendarEventList("list")) + self.assertEquals(event_list.get("events"), []) + event = self.portal.event_module.newContent(portal_type="Note") + event.setStartDate(DateTime()) + event.setStopDate(DateTime()+1) + self.stepTic() + event_dict = json.loads(self.portal.Base_updateCalendarEventList("list")) + event_list = event_dict.get("events") + self.assertEquals(event_list[0][-2], "Note") + form_dict = dict(CalendarStartTime=DateTime().strftime("%m/%d/%Y %H:%M"), + CalendarEndTime=DateTime().strftime("%m/%d/%Y %H:%M"), + CalendarTitle="One Sample", + portal_type="Web Message") + self.portal.REQUEST.form.update(form_dict) + self.portal.Base_updateCalendarEventList("add") + self.stepTic() + web_message = self.portal.portal_catalog.getResultValue(portal_type="Web Message") + self.assertEquals(web_message.getTitle(), "One Sample") + self.portal.REQUEST.form.clear() + form_dict = dict(CalendarStartTime=DateTime().strftime("%m/%d/%Y %H:%M"), + CalendarEndTime=DateTime().strftime("%m/%d/%Y %H:%M"), + title="Buy Coffee", + event_id=web_message.getId()) + self.portal.REQUEST.form.update(form_dict) + self.portal.Base_updateCalendarEventList("update") + self.stepTic() + self.assertEquals(web_message.getTitle(), "Buy Coffee") + self.portal.REQUEST.form.clear() + form_dict = dict(title=web_message.getTitle(), + id=web_message.getId()) + self.portal.REQUEST.form.update(form_dict) + self.portal.Base_updateCalendarEventList("remove") + self.stepTic() + web_message = self.portal.portal_catalog.getResultValue(portal_type="Web Message") + self.assertEquals(web_message, None) \ No newline at end of file diff --git a/bt5/erp5_web_ung_role/bt/revision b/bt5/erp5_web_ung_role/bt/revision index 3f10ffe7a4..8e2afd3427 100644 --- a/bt5/erp5_web_ung_role/bt/revision +++ b/bt5/erp5_web_ung_role/bt/revision @@ -1 +1 @@ -15 \ No newline at end of file +17 \ No newline at end of file -- 2.30.9