def testWriteICalendarUnicodeBug3338(self): event = Calendar.CalendarEvent(itsView = self.view) event.summary = u"unicode \u0633\u0644\u0627\u0645" event.startTime = datetime.datetime(2010, 1, 1, 10, tzinfo=self.view.tzinfo.default) event.endTime = datetime.datetime(2010, 1, 1, 11, tzinfo=self.view.tzinfo.default) event.rruleset = self._makeRecurrenceRuleSet() coll = ListCollection("testcollection", itsParent=self.sandbox) coll.displayName = "test" coll.add(event.itsItem) # the view needs to be committed for event to be seen by sync self.view.commit() filename = u"unicode_export.ics" def delFile(): try: os.remove(filename) except OSError: pass delFile() sharing.exportFile(self.view, os.path.join(".", filename), coll) cal = vobject.readComponents(file(filename, 'rb')).next() self.assertEqual(cal.vevent.summary.value, event.summary) # no modifications should be serialized self.assertEqual(len(cal.vevent_list), 1) delFile()
def startTest(self): appView = self.app_ns.itsView # make user collection, since only user # collections can be displayed as a calendar col = QAUITestAppLib.UITestItem("Collection", self.logger) #create an event to export self.logger.startAction('Create event to export') event = QAUITestAppLib.UITestItem("Event", self.logger) event_UUID = event.item.itsUUID #write some stuff in the event to make it unique event.SetAttr(displayName=uw("Original Event"), startDate="01/01/2001", startTime="12:00 AM", body=uw("This is the original event")) self.logger.addComment("Created Event to Export") #export the event path = os.path.join(Globals.chandlerDirectory, "tools/cats/DataFiles") filename = 'tempOverwriteTest.ics' fullpath = os.path.join(path, filename) if os.path.exists(fullpath): os.remove(fullpath) #Upcast path to unicode since Sharing requires a unicode path fullpath = unicode(fullpath, sys.getfilesystemencoding()) collection = pim.ListCollection(itsView=appView) # exporting all Events is VERY expensive, it doesn't seem like a good # way to test if events can be exported successfully. Instead, just # export one event. #for tmpEvent in Calendar.EventStamp.getCollection(appView): #collection.add(tmpEvent) collection.add(event.item) sharing.exportFile(appView, fullpath, collection) application = wx.GetApp() application.Yield(True) self.logger.addComment("Exported event") #change the event after exporting event.SetAttr(displayName=uw("Changed Event"), body=uw("This event has been changed")) self.logger.addComment("event changed after export") #import the original event sharing.importFile(appView, fullpath) application.Yield(True) self.logger.addComment("Imported exported event") #check if changed attributes have reverted to original values #find imported event by UUID self.logger.startAction("Verify event overwritten") found = self.app_ns.view.findUUID(event_UUID) if found.body == uw('This is the original event') and \ found.displayName == uw('Original Event'): self.logger.endAction(True, "Event overwriten") else: self.logger.endAction(False, 'Event not overwriten')
def startTest(self): appView = self.app_ns.itsView # make user collection, since only user # collections can be displayed as a calendar col = QAUITestAppLib.UITestItem("Collection", self.logger) #create an event to export self.logger.startAction('Create event to export') event = QAUITestAppLib.UITestItem("Event", self.logger) event_UUID = event.item.itsUUID #write some stuff in the event to make it unique event.SetAttr(displayName=uw("Original Event"), startDate="01/01/2001", startTime="12:00 AM", body=uw("This is the original event")) self.logger.addComment("Created Event to Export") #export the event path = os.path.join(Globals.chandlerDirectory,"tools/cats/DataFiles") filename = 'tempOverwriteTest.ics' fullpath = os.path.join(path, filename) if os.path.exists(fullpath): os.remove(fullpath) #Upcast path to unicode since Sharing requires a unicode path fullpath = unicode(fullpath, sys.getfilesystemencoding()) collection = pim.ListCollection(itsView=appView) # exporting all Events is VERY expensive, it doesn't seem like a good # way to test if events can be exported successfully. Instead, just # export one event. #for tmpEvent in Calendar.EventStamp.getCollection(appView): #collection.add(tmpEvent) collection.add(event.item) sharing.exportFile(appView, fullpath, collection) application = wx.GetApp() application.Yield(True) self.logger.addComment("Exported event") #change the event after exporting event.SetAttr(displayName=uw("Changed Event"), body=uw("This event has been changed")) self.logger.addComment("event changed after export") #import the original event sharing.importFile(appView, fullpath) application.Yield(True) self.logger.addComment("Imported exported event") #check if changed attributes have reverted to original values #find imported event by UUID self.logger.startAction("Verify event overwritten") found = self.app_ns.view.findUUID(event_UUID) if found.body == uw('This is the original event') and \ found.displayName == uw('Original Event'): self.logger.endAction(True, "Event overwriten") else: self.logger.endAction(False, 'Event not overwriten')
def startTest(self): appView = self.app_ns.itsView today = strftime('%m/%d/%Y', localtime()) colName = "deleteThenImport" eventName = "eventToTest" #create a collection collection = QAUITestAppLib.UITestItem("Collection", self.logger) collection.SetDisplayName(colName) sb = self.app_ns.sidebar scripting.User.emulate_sidebarClick(sb, colName) #create an event ev = QAUITestAppLib.UITestItem('Event', self.logger) ev.SetAttr(displayName=eventName, startDate=today, startTime="12:00 PM") #create a path to export to reportDir = Globals.options.profileDir fullpath = os.path.join(reportDir, 'deleteThenImport.ics') if os.path.exists(fullpath): os.remove(fullpath) fullpath = unicode(fullpath, sys.getfilesystemencoding()) #export sharing.exportFile(appView, fullpath, collection.item) #delete collection scripting.User.emulate_sidebarClick(sb, colName) collection.DeleteCollection() #import event back in collection = sharing.importFile(appView, fullpath) self.app_ns.sidebarCollection.add(collection) scripting.User.idle() #verify ev.Check_ItemInCollection("Trash", expectedResult=False) ev.Check_ItemInCollection(colName, expectedResult=True)
def startTest(self): appView = self.app_ns.itsView path = os.path.join(Globals.chandlerDirectory,"tools/cats/DataFiles") filename = 'exportTest.ics' fullpath = os.path.join(path, filename) if os.path.exists(fullpath): os.remove(fullpath) #Upcast path to unicode since Sharing requires a unicode path fullpath = unicode(fullpath, sys.getfilesystemencoding()) self.logger.startAction("Export Test Calendar") collection = pim.ListCollection(itsView=appView) for event in Calendar.EventStamp.getCollection(appView): collection.add(event) try: sharing.exportFile(appView, fullpath, collection) self.logger.report(True, name="exportFile") except: self.logger.report(False, name="exportFile") self.logger.endAction(True)
def startTest(self): appView = self.app_ns.itsView today = strftime('%m/%d/%Y',localtime()) colName = "deleteThenImport" eventName = "eventToTest" #create a collection collection = QAUITestAppLib.UITestItem("Collection", self.logger) collection.SetDisplayName(colName) sb=self.app_ns.sidebar scripting.User.emulate_sidebarClick(sb,colName) #create an event ev=QAUITestAppLib.UITestItem('Event', self.logger) ev.SetAttr(displayName=eventName, startDate=today, startTime="12:00 PM") #create a path to export to reportDir = Globals.options.profileDir fullpath = os.path.join(reportDir,'deleteThenImport.ics') if os.path.exists(fullpath): os.remove(fullpath) fullpath = unicode(fullpath, sys.getfilesystemencoding()) #export sharing.exportFile(appView, fullpath, collection.item) #delete collection scripting.User.emulate_sidebarClick(sb,colName) collection.DeleteCollection() #import event back in collection = sharing.importFile(appView, fullpath) self.app_ns.sidebarCollection.add(collection) scripting.User.idle() #verify ev.Check_ItemInCollection("Trash", expectedResult=False) ev.Check_ItemInCollection(colName, expectedResult=True)
def testWriteICalendarUnicodeBug3338(self): event = Calendar.CalendarEvent(itsView=self.view) event.summary = u"unicode \u0633\u0644\u0627\u0645" event.startTime = datetime.datetime(2010, 1, 1, 10, tzinfo=self.view.tzinfo.default) event.endTime = datetime.datetime(2010, 1, 1, 11, tzinfo=self.view.tzinfo.default) event.rruleset = self._makeRecurrenceRuleSet() coll = ListCollection("testcollection", itsParent=self.sandbox) coll.displayName = "test" coll.add(event.itsItem) # the view needs to be committed for event to be seen by sync self.view.commit() filename = u"unicode_export.ics" def delFile(): try: os.remove(filename) except OSError: pass delFile() sharing.exportFile(self.view, os.path.join(".", filename), coll) cal = vobject.readComponents(file(filename, 'rb')).next() self.assertEqual(cal.vevent.summary.value, event.summary) # no modifications should be serialized self.assertEqual(len(cal.vevent_list), 1) delFile()
def runTest(self): self.setUp() inFile = self.getTestResourcePath('stateless.ics') dir = os.path.dirname(inFile) outFile = os.path.join(dir, 'tmp_stateless.ics') # Both status and reminders filters active filters = [ 'cid:[email protected]', 'cid:[email protected]', ] coll = sharing.importFile(self.views[0], inFile, filters=filters) for item in coll: uuidStr = item.icalUID self.assertEquals(item.displayName, items[uuidStr][0]) self.assert_(not item.reminders) event = pim.EventStamp(item) self.assertEquals(event.transparency, 'confirmed') # reminders filters active filters = [ 'cid:[email protected]', ] coll = sharing.importFile(self.views[0], inFile, filters=filters) for item in coll: uuidStr = item.icalUID self.assertEquals(item.displayName, items[uuidStr][0]) self.assert_(not item.reminders) event = pim.EventStamp(item) self.assertEquals(event.transparency, items[uuidStr][1]) # No filters active coll = sharing.importFile(self.views[0], inFile) for item in coll: uuidStr = item.icalUID self.assertEquals(item.displayName, items[uuidStr][0]) if items[uuidStr][2] is None: self.assert_(not item.reminders) else: self.assertEquals(list(item.reminders)[0].delta, items[uuidStr][2]) event = pim.EventStamp(item) self.assertEquals(event.transparency, items[uuidStr][1]) if os.path.exists(outFile): os.remove(outFile) try: # Export using reminders filter filters = ['cid:[email protected]'] sharing.exportFile(self.views[0], outFile, coll, filters=filters) # Import using no filters; verify reminders not set on items coll = sharing.importFile(self.views[1], outFile) for item in coll: uuidStr = item.icalUID self.assertEquals(item.displayName, items[uuidStr][0]) self.assert_(not item.reminders) event = pim.EventStamp(item) self.assertEquals(event.transparency, items[uuidStr][1]) finally: if os.path.exists(outFile): os.remove(outFile)