[CalendarServer-changes] [5214] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 24 21:38:16 PST 2010
Revision: 5214
http://trac.macosforge.org/projects/calendarserver/changeset/5214
Author: wsanchez at apple.com
Date: 2010-02-24 21:38:15 -0800 (Wed, 24 Feb 2010)
Log Message:
-----------
Nix normalizeStartEndDuration()
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/dateops.py
Removed Paths:
-------------
CalendarServer/trunk/twistedcaldav/test/test_dateops.py
Modified: CalendarServer/trunk/twistedcaldav/dateops.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/dateops.py 2010-02-25 05:37:52 UTC (rev 5213)
+++ CalendarServer/trunk/twistedcaldav/dateops.py 2010-02-25 05:38:15 UTC (rev 5214)
@@ -19,7 +19,6 @@
"""
__all__ = [
- "normalizeStartEndDuration",
"normalizeForIndex",
"floatoffset",
"compareDateTime",
@@ -33,17 +32,8 @@
import datetime
from vobject.icalendar import utc
-from twext.python.datetime import dateordatetime, timerange
+from twext.python.datetime import dateordatetime
-def normalizeStartEndDuration(dtstart, dtend=None, duration=None):
- def asUTC(dodt):
- if dodt is None:
- return None
- return dodt.asUTC().dateOrDatetime()
-
- tr = timerange(dtstart, dtend, duration)
- return asUTC(tr.start()), asUTC(tr.end())
-
def normalizeForIndex(dt):
"""
Normalize a L{datetime.date} or L{datetime.datetime} object for use in the Index.
Deleted: CalendarServer/trunk/twistedcaldav/test/test_dateops.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_dateops.py 2010-02-25 05:37:52 UTC (rev 5213)
+++ CalendarServer/trunk/twistedcaldav/test/test_dateops.py 2010-02-25 05:38:15 UTC (rev 5214)
@@ -1,155 +0,0 @@
-##
-# Copyright (c) 2008 Apple Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-
-
-import twistedcaldav.test.util
-from vobject.icalendar import utc, getTzid
-from twistedcaldav.dateops import normalizeStartEndDuration
-from twistedcaldav.timezones import TimezoneCache
-import datetime
-
-#TODO: add tests for all the methods in dateops
-
-class Tests_normalizeStartEndDuration (twistedcaldav.test.util.TestCase):
- """
- Test abstract SQL DB class
- """
-
- def setUp(self):
- super(Tests_normalizeStartEndDuration, self).setUp()
-
- TimezoneCache.create()
- TimezoneCache.activeCache.loadTimezone("America/New_York")
-
- def test_invalid(self):
-
- start = datetime.datetime(2008, 1, 1, 0, 0, 0, tzinfo=utc)
- end = datetime.datetime(2008, 1, 1, 1, 0, 0, tzinfo=utc)
- duration = end - start
-
- self.assertRaises(AssertionError, normalizeStartEndDuration, start, end, duration)
-
- def test_start_only_utc(self):
-
- start = datetime.datetime(2008, 1, 1, 0, 0, 0, tzinfo=utc)
-
- newstart, newend = normalizeStartEndDuration(start)
- self.assertEqual(newstart, start)
- self.assertTrue(newend is None)
-
- def test_start_only_float(self):
- start = datetime.datetime(2008, 1, 1, 0, 0, 0)
-
- newstart, newend = normalizeStartEndDuration(start)
- self.assertEqual(newstart, start)
- self.assertTrue(newend is None)
-
- def test_start_only_date(self):
- start = datetime.date(2008, 1, 1)
-
- newstart, newend = normalizeStartEndDuration(start)
- self.assertEqual(newstart, start)
- self.assertTrue(newend is None)
-
- def test_start_only_tzid(self):
-
- start = datetime.datetime(2008, 1, 1, 0, 0, 0, tzinfo=getTzid("America/New_York"))
- utcstart = datetime.datetime(2008, 1, 1, 5, 0, 0, tzinfo=utc)
-
- newstart, newend = normalizeStartEndDuration(start)
- self.assertEqual(newstart, utcstart)
- self.assertTrue(newend is None)
-
- def test_start_end_utc(self):
-
- start = datetime.datetime(2008, 1, 1, 0, 0, 0, tzinfo=utc)
- end = datetime.datetime(2008, 1, 1, 1, 0, 0, tzinfo=utc)
-
- newstart, newend = normalizeStartEndDuration(start, dtend=end)
- self.assertEqual(newstart, start)
- self.assertEqual(newend, end)
-
- def test_start_end_float(self):
-
- start = datetime.datetime(2008, 1, 1, 0, 0, 0)
- end = datetime.datetime(2008, 1, 1, 1, 0, 0)
-
- newstart, newend = normalizeStartEndDuration(start, dtend=end)
- self.assertEqual(newstart, start)
- self.assertEqual(newend, end)
-
- def test_start_end_date(self):
-
- start = datetime.date(2008, 1, 1)
- end = datetime.date(2008, 1, 2)
-
- newstart, newend = normalizeStartEndDuration(start, dtend=end)
- self.assertEqual(newstart, start)
- self.assertEqual(newend, end)
-
- def test_start_end_tzid(self):
-
- start = datetime.datetime(2008, 1, 1, 0, 0, 0, tzinfo=getTzid("America/New_York"))
- end = datetime.datetime(2008, 1, 1, 1, 0, 0, tzinfo=getTzid("America/New_York"))
- utcstart = datetime.datetime(2008, 1, 1, 5, 0, 0, tzinfo=utc)
- utcend = datetime.datetime(2008, 1, 1, 6, 0, 0, tzinfo=utc)
-
- newstart, newend = normalizeStartEndDuration(start, dtend=end)
- self.assertEqual(newstart, utcstart)
- self.assertEqual(newend, utcend)
-
- def test_start_duration_utc(self):
-
- start = datetime.datetime(2008, 1, 1, 0, 0, 0, tzinfo=utc)
- end = datetime.datetime(2008, 1, 1, 1, 0, 0, tzinfo=utc)
- duration = end - start
-
- newstart, newend = normalizeStartEndDuration(start, duration=duration)
- self.assertEqual(newstart, start)
- self.assertEqual(newend, end)
-
- def test_start_duration_float(self):
-
- start = datetime.datetime(2008, 1, 1, 0, 0, 0)
- end = datetime.datetime(2008, 1, 1, 1, 0, 0)
- duration = end - start
-
- newstart, newend = normalizeStartEndDuration(start, duration=duration)
- self.assertEqual(newstart, start)
- self.assertEqual(newend, end)
-
- def test_start_duration_date(self):
-
- start = datetime.date(2008, 1, 1)
- end = datetime.date(2008, 1, 2)
- duration = end - start
-
- newstart, newend = normalizeStartEndDuration(start, duration=duration)
- self.assertEqual(newstart, start)
- self.assertEqual(newend, end)
-
- def test_start_duration_tzid(self):
-
- start = datetime.datetime(2008, 1, 1, 0, 0, 0, tzinfo=getTzid("America/New_York"))
- end = datetime.datetime(2008, 1, 1, 1, 0, 0, tzinfo=getTzid("America/New_York"))
- utcstart = datetime.datetime(2008, 1, 1, 5, 0, 0, tzinfo=utc)
- utcend = datetime.datetime(2008, 1, 1, 6, 0, 0, tzinfo=utc)
- duration = end - start
-
- newstart, newend = normalizeStartEndDuration(start, duration=duration)
- self.assertEqual(newstart, utcstart)
- self.assertEqual(newend, utcend)
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100224/00ad6f7d/attachment-0001.html>
More information about the calendarserver-changes
mailing list