[CalendarServer-changes] [14144] CalendarServer/trunk/calendarserver/tools
source_changes at macosforge.org
source_changes at macosforge.org
Fri Nov 7 10:11:21 PST 2014
Revision: 14144
http://trac.calendarserver.org//changeset/14144
Author: sagen at apple.com
Date: 2014-11-07 10:11:21 -0800 (Fri, 07 Nov 2014)
Log Message:
-----------
Start testing import of scheduled events -- first just as the organizer
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/importer.py
CalendarServer/trunk/calendarserver/tools/test/test_importer.py
Modified: CalendarServer/trunk/calendarserver/tools/importer.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/importer.py 2014-11-07 17:17:31 UTC (rev 14143)
+++ CalendarServer/trunk/calendarserver/tools/importer.py 2014-11-07 18:11:21 UTC (rev 14144)
@@ -198,11 +198,13 @@
)
except UIDExistsError:
# That event is already in the home
- print(
- "Skipping since UID already exists: {uid}".format(
- uid=groupedComponent.propertyValue("UID")
- )
- )
+ try:
+ uid = list(groupedComponent.subcomponents())[0].propertyValue("UID")
+ except:
+ uid = "unknown"
+
+ print("Skipping since UID already exists: {}".format(uid))
+
except Exception, e:
print(
"Failed to import due to: {error}\n{comp}".format(
Modified: CalendarServer/trunk/calendarserver/tools/test/test_importer.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/test/test_importer.py 2014-11-07 17:17:31 UTC (rev 14143)
+++ CalendarServer/trunk/calendarserver/tools/test/test_importer.py 2014-11-07 18:11:21 UTC (rev 14144)
@@ -117,6 +117,32 @@
"""
+DATA_WITH_ORGANIZER = """BEGIN:VCALENDAR
+VERSION:2.0
+NAME:I'm the organizer
+COLOR:#0000FFFF
+SOURCE;VALUE=URI:http://example.com/calendars/__uids__/user01/calendar/
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:AB49C0C0-4238-41A4-8B43-F3E3DDF0E59C
+DTSTART;TZID=America/Los_Angeles:20141108T053000
+DTEND;TZID=America/Los_Angeles:20141108T070000
+ATTENDEE;CN=User 01;CUTYPE=INDIVIDUAL;ROLE=CHAIR:urn:x-uid:user01
+ATTENDEE;CN=User 02;CUTYPE=INDIVIDUAL:urn:x-uid:user02
+ATTENDEE;CN=User 03;CUTYPE=INDIVIDUAL:urn:x-uid:user03
+ATTENDEE;CN=Mercury Seven;CUTYPE=ROOM:urn:x-uid:mercury
+CREATED:20141107T172645Z
+DTSTAMP:20141107T172645Z
+LOCATION:Mercury
+ORGANIZER;CN=User 01:urn:x-uid:user01
+SEQUENCE:0
+SUMMARY:I'm the organizer
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+"""
+
+
class ImportTests(StoreTestCase):
"""
Tests for importing data to a live store.
@@ -141,8 +167,8 @@
yield importCollectionComponent(self.store, component)
txn = self.store.newTransaction()
- home = yield txn.calendarHomeWithUID(u"user01")
- collection = yield home.childWithName(u"calendar")
+ home = yield txn.calendarHomeWithUID("user01")
+ collection = yield home.childWithName("calendar")
# Verify properties have been set
collectionProperties = collection.properties()
@@ -168,8 +194,8 @@
yield importCollectionComponent(self.store, component)
txn = self.store.newTransaction()
- home = yield txn.calendarHomeWithUID(u"user01")
- collection = yield home.childWithName(u"calendar")
+ home = yield txn.calendarHomeWithUID("user01")
+ collection = yield home.childWithName("calendar")
# Verify properties have been changed
collectionProperties = collection.properties()
@@ -187,3 +213,47 @@
self.assertEquals(len(objects), 3)
yield txn.commit()
+
+
+ @inlineCallbacks
+ def test_ImportComponentOrganizer(self):
+
+ component = Component.allFromString(DATA_WITH_ORGANIZER)
+ yield importCollectionComponent(self.store, component)
+
+ txn = self.store.newTransaction()
+ home = yield txn.calendarHomeWithUID("user01")
+ collection = yield home.childWithName("calendar")
+
+ # Verify properties have been set
+ collectionProperties = collection.properties()
+ for element, value in (
+ (davxml.DisplayName, "I'm the organizer"),
+ (customxml.CalendarColor, "#0000FFFF"),
+ ):
+ self.assertEquals(
+ value,
+ collectionProperties[PropertyName.fromElement(element)]
+ )
+
+ # Verify the organizer's child objects
+ objects = yield collection.listObjectResources()
+ self.assertEquals(len(objects), 1)
+
+ # Verify the attendees' child objects
+ home = yield txn.calendarHomeWithUID("user02")
+ collection = yield home.childWithName("calendar")
+ objects = yield collection.listObjectResources()
+ self.assertEquals(len(objects), 1)
+
+ home = yield txn.calendarHomeWithUID("user03")
+ collection = yield home.childWithName("calendar")
+ objects = yield collection.listObjectResources()
+ self.assertEquals(len(objects), 1)
+
+ home = yield txn.calendarHomeWithUID("mercury")
+ collection = yield home.childWithName("calendar")
+ objects = yield collection.listObjectResources()
+ self.assertEquals(len(objects), 1)
+
+ yield txn.commit()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20141107/46fd8f19/attachment.html>
More information about the calendarserver-changes
mailing list