[CalendarServer-changes] [5037] CalendarServer/trunk/txcaldav/calendarstore
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 3 12:00:24 PST 2010
Revision: 5037
http://trac.macosforge.org/projects/calendarserver/changeset/5037
Author: wsanchez at apple.com
Date: 2010-02-03 12:00:23 -0800 (Wed, 03 Feb 2010)
Log Message:
-----------
More file store
Modified Paths:
--------------
CalendarServer/trunk/txcaldav/calendarstore/file.py
CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py
Modified: CalendarServer/trunk/txcaldav/calendarstore/file.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/file.py 2010-02-03 19:37:28 UTC (rev 5036)
+++ CalendarServer/trunk/txcaldav/calendarstore/file.py 2010-02-03 20:00:23 UTC (rev 5037)
@@ -39,6 +39,7 @@
from txcaldav.icalendarstore import ICalendarHome, ICalendar, ICalendarObject
from txcaldav.icalendarstore import CalendarNameNotAllowedError
+from txcaldav.icalendarstore import CalendarObjectNameNotAllowedError
from txcaldav.icalendarstore import CalendarAlreadyExistsError
from txcaldav.icalendarstore import CalendarObjectNameAlreadyExistsError
from txcaldav.icalendarstore import NotFoundError
@@ -180,6 +181,9 @@
raise NotImplementedError()
def createCalendarObjectWithName(self, name, component):
+ if name.startswith("."):
+ raise CalendarObjectNameNotAllowedError(name)
+
childPath = self.path.child(name)
if childPath.exists():
raise CalendarObjectNameAlreadyExistsError(name)
@@ -188,8 +192,15 @@
calendarObject.setComponent(component)
def removeCalendarObjectWithName(self, name):
- raise NotImplementedError()
+ if name.startswith("."):
+ raise NoSuchCalendarObjectError(name)
+ childPath = self.path.child(name)
+ if childPath.isfile():
+ childPath.remove()
+ else:
+ raise NoSuchCalendarObjectError(name)
+
def removeCalendarObjectWithUID(self, uid):
raise NotImplementedError()
Modified: CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py 2010-02-03 19:37:28 UTC (rev 5036)
+++ CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py 2010-02-03 20:00:23 UTC (rev 5037)
@@ -33,6 +33,7 @@
from txcaldav.icalendarstore import CalendarAlreadyExistsError
from txcaldav.icalendarstore import CalendarObjectNameAlreadyExistsError
from txcaldav.icalendarstore import NoSuchCalendarError
+from txcaldav.icalendarstore import NoSuchCalendarObjectError
from txcaldav.icalendarstore import InvalidCalendarComponentError
from txcaldav.calendarstore.file import CalendarStore, CalendarHome
@@ -288,8 +289,7 @@
for name in home1_calendarNames:
self.assertRaises(
CalendarAlreadyExistsError,
- self.home1.createCalendarWithName,
- name
+ self.home1.createCalendarWithName, name
)
def test_createCalendarWithName_dot(self):
@@ -299,8 +299,7 @@
"""
self.assertRaises(
CalendarNameNotAllowedError,
- self.home1.createCalendarWithName,
- ".foo"
+ self.home1.createCalendarWithName, ".foo"
)
def test_removeCalendarWithName_exists(self):
@@ -308,6 +307,7 @@
Remove an existing calendar.
"""
for name in home1_calendarNames:
+ assert self.home1.calendarWithName(name) is not None
self.home1.removeCalendarWithName(name)
self.assertEquals(self.home1.calendarWithName(name), None)
@@ -317,8 +317,7 @@
"""
self.assertRaises(
NoSuchCalendarError,
- self.home1.removeCalendarWithName,
- "xyzzy"
+ self.home1.removeCalendarWithName, "xyzzy"
)
def test_removeCalendarWithName_dot(self):
@@ -330,8 +329,7 @@
self.home1.path.child(name).createDirectory()
self.assertRaises(
NoSuchCalendarError,
- self.home1.removeCalendarWithName,
- name
+ self.home1.removeCalendarWithName, name
)
class CalendarTest(unittest.TestCase, PropertiesTestMixin):
@@ -451,9 +449,7 @@
Create a new calendar object.
"""
name = "4.ics"
-
assert self.calendar1.calendarObjectWithName(name) is None
-
component = iComponent.fromString(event4_text)
self.calendar1.createCalendarObjectWithName(name, component)
@@ -481,7 +477,6 @@
self.calendar1.createCalendarObjectWithName,
".foo", iComponent.fromString(event4_text)
)
- test_createCalendarObjectWithName_dot.todo = "Unimplemented"
def test_createCalendarObjectWithName_uidconflict(self):
"""
@@ -506,15 +501,22 @@
"""
Remove an existing calendar object.
"""
- raise NotImplementedError()
- test_removeCalendarObjectWithName_exists.todo = "Unimplemented"
+ for name in calendar1_objectNames:
+ assert self.calendar1.calendarObjectWithName(name) is not None
+ self.calendar1.removeCalendarObjectWithName(name)
+ self.assertEquals(
+ self.calendar1.calendarObjectWithName(name),
+ None
+ )
def test_removeCalendarObjectWithName_absent(self):
"""
Attempt to remove an non-existing calendar object should raise.
"""
- raise NotImplementedError()
- test_removeCalendarObjectWithName_absent.todo = "Unimplemented"
+ self.assertRaises(
+ NoSuchCalendarObjectError,
+ self.calendar1.removeCalendarObjectWithName, "xyzzy"
+ )
def test_removeCalendarObjectWithName_dot(self):
"""
@@ -522,8 +524,12 @@
implementation, so no calendar object names may start with
".".
"""
- raise NotImplementedError()
- test_removeCalendarObjectWithName_dot.todo = "Unimplemented"
+ name = ".foo"
+ self.calendar1.path.child(name).touch()
+ self.assertRaises(
+ NoSuchCalendarObjectError,
+ self.calendar1.removeCalendarObjectWithName, name
+ )
def test_removeCalendarObjectWithUID_exists(self):
"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100203/6aba0226/attachment-0001.html>
More information about the calendarserver-changes
mailing list