diff --git a/bt5/erp5_web_ung_theme/TestTemplateItem/testUNG.py b/bt5/erp5_web_ung_theme/TestTemplateItem/testUNG.py index 91ff79d2cba110bca2fb1010da8b534b7b2e5e6d..8a8cb2348006e5f97c8347a57f02adb1ed9ff63b 100644 --- a/bt5/erp5_web_ung_theme/TestTemplateItem/testUNG.py +++ b/bt5/erp5_web_ung_theme/TestTemplateItem/testUNG.py @@ -27,7 +27,9 @@ ############################################################################## from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase +from DateTime import DateTime import re +import json class TestUNG(ERP5TypeTestCase): @@ -170,7 +172,7 @@ class TestUNG(ERP5TypeTestCase): def testWebSection_getGadgetPathList(self): """Validate the gadget list""" - gadget_list = eval(self.portal.WebSection_getGadgetPathList()) + gadget_list = json.loads((self.portal.WebSection_getGadgetPathList())) for gadget in gadget_list: url = gadget.get("image_url").split("?")[0] url = url.replace("/default_image", "") @@ -230,3 +232,41 @@ class TestUNG(ERP5TypeTestCase): url = self.portal.WebSection_getDocumentUrl(**kw) pattern = "^http.*\/web_page_module\/[0-9]+\/WebPage_viewEditor\?editable_mode\:int\=1" self.assertNotEquals(re.search(pattern, url), None, url) + + def testBase_updateCalendarEventList(self): + """Test script used to manage events in UNG Calendar """ + event_dict = json.loads(self.portal.Base_updateCalendarEventList("list")) + self.assertEquals(event_dict.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) diff --git a/bt5/erp5_web_ung_theme/bt/revision b/bt5/erp5_web_ung_theme/bt/revision index a9d8b73e699feec67a98221332b994952c6c8ad8..ce83bd94b3310d442003750e2bf8e7f2e28da90a 100644 --- a/bt5/erp5_web_ung_theme/bt/revision +++ b/bt5/erp5_web_ung_theme/bt/revision @@ -1 +1 @@ -257 \ No newline at end of file +258 \ No newline at end of file