def testCalendar(self): """ Simple test for creating instances of calendar related kinds """ self.loadParcel("parcel:osaf.pim.calendar") def _verifyCalendarEvent(event): self.assertEqual(event.displayName, "simple headline") self.assertEqual(event.getItemDisplayName(), "simple headline") self.assertEqual(event.importance, 'fyi') self.assertEqual(event.getAttributeValue('importance'), 'fyi') self.assertEqual(event.transparency, "confirmed") self.assertEqual(event.getAttributeValue('transparency'), "confirmed") self.assertEqual(event.allDay, False) self.assertEqual(event.getAttributeValue('allDay'), False) self.assertEqual(event.anyTime, True) self.assertEqual(event.getAttributeValue('anyTime'), True) def _verifyCalendarItems(calendar, location, recurrence): self.assertEqual(calendar.displayName, "simple calendar") self.assertEqual(calendar.getAttributeValue('displayName'), "simple calendar") self.assertEqual(location.displayName, "simple location") self.assertEqual(location.getAttributeValue('displayName'), "simple location") # Check that the globals got created by the parcel calendarPath = Path('//parcels/osaf/pim/calendar') view = self.rep.view self.assertEqual(Calendar.CalendarEvent.getKind(view), view.find(Path(calendarPath, 'CalendarEvent'))) self.assertEqual(Calendar.Calendar.getKind(view), view.find(Path(calendarPath, 'Calendar'))) self.assertEqual(Calendar.Location.getKind(view), view.find(Path(calendarPath, 'Location'))) self.assertEqual(Calendar.RecurrencePattern.getKind(view), view.find(Path(calendarPath, 'RecurrencePattern'))) # Construct a sample item calendarEventItem = Calendar.CalendarEvent("calendarEventItem", view=view) calendarItem = Calendar.Calendar("calendarItem", view=view) locationItem = Calendar.Location("locationItem", view=view) recurrenceItem = Calendar.RecurrencePattern("recurrenceItem", view=view) # CalendarEvent properties calendarEventItem.displayName = "simple headline" calendarEventItem.importance = "fyi" _verifyCalendarEvent(calendarEventItem) calendarEventItem.location = locationItem # Calendar properties calendarItem.displayName = "simple calendar" locationItem.displayName = "simple location" _verifyCalendarItems(calendarItem, locationItem, recurrenceItem) # Check cloud membership - event + location items = calendarEventItem.getItemCloud('copying') self.assertEqual(len(items), 2) # Re-examine items self._reopenRepository() contentItemParent = self.rep.findPath("//userdata") calendarEventItem = contentItemParent.getItemChild("calendarEventItem") calendarItem = contentItemParent.getItemChild("calendarItem") locationItem = contentItemParent.getItemChild("locationItem") recurrenceItem = contentItemParent.getItemChild("recurrenceItem") _verifyCalendarEvent(calendarEventItem) _verifyCalendarItems(calendarItem, locationItem, recurrenceItem)
def testCalendar(self): """ Simple test for creating instances of calendar related kinds """ def getEventValue(event, attrName): try: attrName = getattr(type(event), attrName).name except AttributeError: pass return getattr(event.itsItem, attrName) def _verifyCalendarEvent(event): self.failUnless(stamping.has_stamp(event, Calendar.EventStamp)) self.assertEqual(event.summary, uw("simple headline")) self.assertEqual(event.itsItem.importance, 'fyi') self.assertEqual(getEventValue(event, 'importance'), 'fyi') self.assertEqual(event.transparency, "confirmed") self.assertEqual(getEventValue(event, 'transparency'), "confirmed") self.assertEqual(event.allDay, False) self.assertEqual(getEventValue(event, 'allDay'), False) self.assertEqual(event.anyTime, True) self.assertEqual(getEventValue(event, 'anyTime'), True) def _verifyCalendarItems(location, recurrence): self.assertEqual(location.displayName, uw("simple location")) # Check that the globals got created by the parcel calendarPath = Path('//parcels/osaf/pim/calendar') view = self.sandbox.itsView self.assertEqual(schema.itemFor(Calendar.EventStamp, view), view.find(Path(calendarPath, 'EventStamp'))) self.assertEqual(Calendar.Location.getKind(view), view.find(Path(calendarPath, 'Location'))) self.assertEqual(Calendar.RecurrencePattern.getKind(view), view.find(Path(calendarPath, 'RecurrencePattern'))) # Construct a sample item calendarEventItem = Calendar.CalendarEvent("calendarEventItem", itsParent=self.sandbox) locationItem = Calendar.Location("locationItem", itsParent=self.sandbox) recurrenceItem = Calendar.RecurrencePattern("recurrenceItem", itsParent=self.sandbox) # CalendarEvent properties calendarEventItem.summary = uw("simple headline") calendarEventItem.itsItem.importance = "fyi" _verifyCalendarEvent(calendarEventItem) calendarEventItem.location = locationItem # Calendar properties locationItem.displayName = uw("simple location") _verifyCalendarItems(locationItem, recurrenceItem) # Check cloud membership - event + location items = calendarEventItem.itsItem.getItemCloud('copying') self.assertEqual(len(items), 2) # Re-examine items self.reopenRepository() view = self.sandbox.itsView calendarEventItem = Calendar.EventStamp( self.sandbox.getItemChild("calendarEventItem")) locationItem = self.sandbox.getItemChild("locationItem") recurrenceItem = self.sandbox.getItemChild("recurrenceItem") _verifyCalendarEvent(calendarEventItem) _verifyCalendarItems(locationItem, recurrenceItem)