[Petter Reinholdtsen]
> Thank you.  Any idea how to trigger the bug.  It imported ok for me
> using import_file(), at least, so I guess there is some other part of
> the API that is failing.

I believe I found a way to detect the problem.  At least I have a test
that fail without the patch from Keith.  Attached.

-- 
Happy hacking
Petter Reinholdtsen
>From 422eb0817c8728dbea320bf2685ae972b75ea21d Mon Sep 17 00:00:00 2001
From: Petter Reinholdtsen <[email protected]>
Date: Mon, 25 Jan 2016 22:36:14 +0000
Subject: [PATCH] Test vcalendar item with slash in the UID field.

Detect if such item is properly handled by resource_from_path().

Signed-off-by: Petter Reinholdtsen <[email protected]>
---
 tests/data/from-tripsync.ics | 24 ++++++++++++++++++++++++
 tests/test_collection.py     | 12 ++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 tests/data/from-tripsync.ics

diff --git a/tests/data/from-tripsync.ics b/tests/data/from-tripsync.ics
new file mode 100644
index 0000000..3fafcfb
--- /dev/null
+++ b/tests/data/from-tripsync.ics
@@ -0,0 +1,24 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:PUBLISH
+PRODID:Trip Sync
+BEGIN:VEVENT
+UID:TripSync-1414170607.95971-air/1/1
+DTSTART:20160118T014000Z
+DTEND:20160118T040000Z
+CLASS:PUBLIC
+DESCRIPTION:Test calendar entry with slash in the UID
+DTSTAMP:20151025T001636Z
+PRIORITY:1
+SEQUENCE:0
+SUMMARY:Slash entry
+TRANSP:OPAQUE
+BEGIN:VALARM
+ACTION:DISPLAY
+DESCRIPTION:Reminder
+TRIGGER:-P1D
+END:VALARM
+END:VEVENT
+X-CALYPSO-NAME:TripSync-1414170607.95971-air/1/1
+X-LOTUS-CHARSET:UTF-8
+END:VCALENDAR
diff --git a/tests/test_collection.py b/tests/test_collection.py
index feda9a0..a3e3115 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -9,10 +9,12 @@ import unittest
 
 import calypso.config
 from calypso.webdav import Collection
+from calypso import paths
 
 
 class TestCollection(unittest.TestCase):
     test_vcard = "tests/data/import.vcard"
+    test_resource_with_slash = "tests/data/from-tripsync.ics"
 
     def setUp(self):
         self.tmpdir = tempfile.mkdtemp()
@@ -29,3 +31,13 @@ class TestCollection(unittest.TestCase):
         self.assertEqual(len(collection.items), 2)
         org = u'Universitetet i Tromsø'
         self.assertTrue(org == collection.items[0].object.org.value[0])
+
+    def test_uid_with_slash(self):
+        collection = Collection("/")
+        self.assertTrue(collection.import_file(self.test_resource_with_slash))
+        self.assertEqual(len(collection.items), 1)
+        veventuid = collection.items[0].object.vevent.uid.value
+        r = paths.resource_from_path(veventuid)
+        c = paths.collection_from_path(veventuid)
+        self.assertTrue(r == veventuid)
+        self.assertTrue("/" == c)
-- 
2.7.0.rc3

_______________________________________________
Calypso mailing list
[email protected]
http://keithp.com/mailman/listinfo/calypso

Reply via email to