[CalendarServer-changes] [6118] CalendarServer/trunk/txcaldav/calendarstore

source_changes at macosforge.org source_changes at macosforge.org
Wed Aug 18 15:08:40 PDT 2010


Revision: 6118
          http://trac.macosforge.org/projects/calendarserver/changeset/6118
Author:   glyph at apple.com
Date:     2010-08-18 15:08:39 -0700 (Wed, 18 Aug 2010)
Log Message:
-----------
add uniqueness constraint to notification schema; add created & modified columns; add modified() method to notification object; add notification and notification home cleanup to tests.

Modified Paths:
--------------
    CalendarServer/trunk/txcaldav/calendarstore/postgres.py
    CalendarServer/trunk/txcaldav/calendarstore/postgres_schema_v1.sql
    CalendarServer/trunk/txcaldav/calendarstore/test/common.py
    CalendarServer/trunk/txcaldav/calendarstore/test/test_postgres.py

Modified: CalendarServer/trunk/txcaldav/calendarstore/postgres.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/postgres.py	2010-08-18 22:07:35 UTC (rev 6117)
+++ CalendarServer/trunk/txcaldav/calendarstore/postgres.py	2010-08-18 22:08:39 UTC (rev 6118)
@@ -1817,20 +1817,26 @@
 
 
     def md5(self):
-        return None
+        return hashlib.md5(self.xmldata()).hexdigest()
 
 
     def modified(self):
-        return None
+        modified = self._txn.execSQL(
+            "select extract(EPOCH from MODIFIED) from NOTIFICATION where "
+            "RESOURCE_ID = %s", [self._resourceID]
+        )[0][0]
+        return int(modified)
 
 
     def created(self):
         return None
 
+
     def size(self):
         return len(self.xmldata())
 
 
+
 class PostgresLegacyNotificationsEmulator(object):
     def __init__(self, notificationsCollection):
         self._collection = notificationsCollection

Modified: CalendarServer/trunk/txcaldav/calendarstore/postgres_schema_v1.sql
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/postgres_schema_v1.sql	2010-08-18 22:07:35 UTC (rev 6117)
+++ CalendarServer/trunk/txcaldav/calendarstore/postgres_schema_v1.sql	2010-08-18 22:08:39 UTC (rev 6118)
@@ -55,7 +55,11 @@
   NOTIFICATION_HOME_RESOURCE_ID integer      not null references NOTIFICATION_HOME,
   NOTIFICATION_UID              varchar(255) not null,
   XML_TYPE                      varchar      not null,
-  XML_DATA                      varchar      not null
+  XML_DATA                      varchar      not null,
+  CREATED                       timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+  MODIFIED                      timestamp default timezone('UTC', CURRENT_TIMESTAMP),
+
+  unique(NOTIFICATION_UID, NOTIFICATION_HOME_RESOURCE_ID)
 );
 
 

Modified: CalendarServer/trunk/txcaldav/calendarstore/test/common.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/test/common.py	2010-08-18 22:07:35 UTC (rev 6117)
+++ CalendarServer/trunk/txcaldav/calendarstore/test/common.py	2010-08-18 22:08:39 UTC (rev 6118)
@@ -304,16 +304,36 @@
         """
         self.assertProvides(ICalendarObject, self.calendarObjectUnderTest())
 
-    def test_notificationObjectProvides(self):
+
+    def notificationUnderTest(self):
         txn = self.transactionUnderTest()
         notifications = txn.notificationsWithUID("home1")
         inviteNotification = InviteNotification()
         notifications.writeNotificationObject("abc", inviteNotification,
             inviteNotification.toxml())
         notificationObject = notifications.notificationObjectWithUID("abc")
+        return notificationObject
+
+
+
+    def test_notificationObjectProvides(self):
+        """
+        The objects retrieved from the notification home (the object returned
+        from L{notificationsWithUID}) provide L{INotificationObject}.
+        """
+        notificationObject = self.notificationUnderTest()
         self.assertProvides(INotificationObject, notificationObject)
 
 
+    def test_notificationObjectModified(self):
+        """
+        The objects retrieved from the notification home have a C{modified}
+        method which returns the timestamp of their last modification.
+        """
+        notification = self.notificationUnderTest()
+        self.assertIsInstance(notification.modified(), int)
+
+
     def test_notifierID(self):
         home = self.homeUnderTest()
         self.assertEquals(home.notifierID(), "home1")

Modified: CalendarServer/trunk/txcaldav/calendarstore/test/test_postgres.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/test/test_postgres.py	2010-08-18 22:07:35 UTC (rev 6117)
+++ CalendarServer/trunk/txcaldav/calendarstore/test/test_postgres.py	2010-08-18 22:08:39 UTC (rev 6118)
@@ -23,8 +23,7 @@
 
 from txcaldav.calendarstore.test.common import CommonTests as CalendarCommonTests
 from txcarddav.addressbookstore.test.common import CommonTests as AddressBookCommonTests
-from txdav.common.icommondatastore import (
-    NoSuchHomeChildError, HomeChildNameAlreadyExistsError)
+from txdav.common.icommondatastore import NoSuchHomeChildError
 
 from twisted.trial import unittest
 from txdav.datastore.subpostgres import (PostgresService,
@@ -137,7 +136,9 @@
                   'CALENDAR',
                   'ADDRESSBOOK',
                   'CALENDAR_HOME',
-                  'ADDRESSBOOK_HOME']
+                  'ADDRESSBOOK_HOME',
+                  'NOTIFICATION',
+                  'NOTIFICATION_HOME']
         for table in tables:
             try:
                 cursor.execute("delete from "+table)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100818/655f2a9e/attachment.html>


More information about the calendarserver-changes mailing list