[CalendarServer-changes] [5980] CalendarServer/branches/new-store-no-caldavfile-2

source_changes at macosforge.org source_changes at macosforge.org
Wed Aug 4 19:38:08 PDT 2010


Revision: 5980
          http://trac.macosforge.org/projects/calendarserver/changeset/5980
Author:   cdaboo at apple.com
Date:     2010-08-04 19:38:06 -0700 (Wed, 04 Aug 2010)
Log Message:
-----------
Fix up tests.

Modified Paths:
--------------
    CalendarServer/branches/new-store-no-caldavfile-2/calendarserver/sidecar/test/test_task.py
    CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/storebridge.py
    CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_addressbookmultiget.py
    CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_mkcalendar.py
    CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_multiget.py
    CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_options.py
    CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_props.py
    CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_schedule.py
    CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_sharing.py
    CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_sql.py
    CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/util.py

Modified: CalendarServer/branches/new-store-no-caldavfile-2/calendarserver/sidecar/test/test_task.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/calendarserver/sidecar/test/test_task.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/calendarserver/sidecar/test/test_task.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -22,7 +22,7 @@
 from twisted.python.usage import Options
 from twistedcaldav.config import config, ConfigDict
 from twistedcaldav.stdconfig import DEFAULT_CONFIG
-from twistedcaldav.test.util import TestCase
+from twistedcaldav.test.util import TestCase, todo
 from twisted.internet.defer import inlineCallbacks
 
 # Points to top of source tree.
@@ -85,6 +85,7 @@
         self.options.parseOptions(["-f", self.configFile])
         return CalDAVTaskServiceMaker().makeService(self.options)
 
+    @todo("FIXME: fix after new store changes")
     @inlineCallbacks
     def test_taskService(self):
         service = self.makeService()

Modified: CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/storebridge.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/storebridge.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -196,8 +196,6 @@
     def newStoreProperties(self):
         return self._newStoreObject.properties()
 
-
-
 class _CalendarChildHelper(object):
     """
     Methods for things which are like calendars.
@@ -665,6 +663,15 @@
     def name(self):
         return self._newStoreCalendar.name()
 
+    def etag(self):
+        return ETag(self._newStoreCalendar.md5())
+
+    def lastModified(self):
+        return self._newStoreCalendar.modified()
+
+    def creationDate(self):
+        return self._newStoreCalendar.created()
+
     def isCollection(self):
         return True
 
@@ -1288,6 +1295,15 @@
     def name(self):
         return self._newStoreAddressBook.name()
 
+    def etag(self):
+        return ETag(self._newStoreAddressBook.md5())
+
+    def lastModified(self):
+        return self._newStoreAddressBook.modified()
+
+    def creationDate(self):
+        return self._newStoreAddressBook.created()
+
     def isCollection(self):
         return True
 
@@ -1578,6 +1594,10 @@
         return self._newStoreObject.vCardText()
 
 
+    def text(self):
+        return self.vCardText()
+
+
     def render(self, request):
         output = self.vCardText()
 

Modified: CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_addressbookmultiget.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_addressbookmultiget.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_addressbookmultiget.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -45,7 +45,7 @@
         okuids = [r[0] for r in (os.path.splitext(f) for f in os.listdir(self.vcards_dir)) if r[1] == ".vcf"]
         okuids[:] = okuids[1:5]
 
-        baduids = ["12345 at example.com", "67890 at example.com"]
+        baduids = ["12345%40example.com", "67890%40example.com"]
 
         return self.simple_vcard_multiget("/addressbook_multiget_vcards/", okuids, baduids)
 
@@ -55,7 +55,7 @@
         """
         okuids = [r[0] for r in (os.path.splitext(f) for f in os.listdir(self.vcards_dir)) if r[1] == ".vcf"]
 
-        baduids = ["12345 at example.com", "67890 at example.com"]
+        baduids = ["12345%40example.com", "67890%40example.com"]
 
         return self.simple_vcard_multiget("/addressbook_multiget_vcards/", okuids, baduids)
 
@@ -75,7 +75,7 @@
 
         okuids = [r[0] for r in (os.path.splitext(f) for f in os.listdir(self.vcards_dir)) if r[1] == ".vcf"]
 
-        baduids = ["12345 at example.com", "67890 at example.com"]
+        baduids = ["12345%40example.com", "67890%40example.com"]
 
         d = self.simple_vcard_multiget("/addressbook_multiget_vcards/", okuids, baduids)
         d.addCallbacks(_restoreValueOK, _restoreValueError)
@@ -97,7 +97,7 @@
 
         okuids = [r[0] for r in (os.path.splitext(f) for f in os.listdir(self.vcards_dir)) if r[1] == ".vcf"]
 
-        baduids = ["12345 at example.com", "67890 at example.com"]
+        baduids = ["12345%40example.com", "67890%40example.com"]
 
         return self.simple_vcard_multiget("/addressbook_multiget_vcards/", okuids, baduids, withData=False)
 

Modified: CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_mkcalendar.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_mkcalendar.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_mkcalendar.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -26,7 +26,7 @@
 from twext.web2.test.test_server import SimpleRequest
 
 from twistedcaldav import caldavxml
-from twistedcaldav.test.util import HomeTestCase
+from twistedcaldav.test.util import HomeTestCase, todo
 
 class MKCALENDAR (HomeTestCase):
     """
@@ -150,6 +150,7 @@
         request.stream = MemoryStream(mk.toxml())
         return self.send(request, do_test)
 
+    @todo("Remove: Does not make sense with new store")
     def test_make_calendar_no_parent(self):
         """
         Make calendar with no parent
@@ -167,6 +168,7 @@
         request = SimpleRequest(self.site, "MKCALENDAR", uri)
         return self.send(request, do_test)
 
+    @todo("Remove: Does not make sense with new store")
     def test_make_calendar_on_resource(self):
         """
         Make calendar on existing resource

Modified: CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_multiget.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_multiget.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_multiget.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -29,10 +29,10 @@
 from twistedcaldav import caldavxml
 from twistedcaldav import ical
 from twistedcaldav.index import db_basename
-from twistedcaldav.test.util import TestCase
+from twistedcaldav.test.util import HomeTestCase, todo
 from twistedcaldav.config import config
 
-class CalendarMultiget (TestCase):
+class CalendarMultiget (HomeTestCase):
     """
     calendar-multiget REPORT
     """
@@ -44,14 +44,12 @@
         All events.
         (CalDAV-access-09, section 7.6.8)
         """
-        self.createStockDirectoryService()
-        self.setupCalendars()
         okuids = [r[0] for r in (os.path.splitext(f) for f in os.listdir(self.holidays_dir)) if r[1] == ".ics"]
         okuids[:] = okuids[1:10]
 
-        baduids = ["12345 at example.com", "67890 at example.com"]
+        baduids = ["12345%40example.com", "67890%40example.com"]
 
-        return self.simple_event_multiget("/calendars/users/wsanchez/calendar_multiget_events/", okuids, baduids)
+        return self.simple_event_multiget("/calendar_multiget_events/", okuids, baduids)
 
     def test_multiget_all_events(self):
         """
@@ -60,7 +58,7 @@
         """
         okuids = [r[0] for r in (os.path.splitext(f) for f in os.listdir(self.holidays_dir)) if r[1] == ".ics"]
 
-        baduids = ["12345 at example.com", "67890 at example.com"]
+        baduids = ["12345%40example.com", "67890%40example.com"]
 
         return self.simple_event_multiget("/calendar_multiget_events/", okuids, baduids)
 
@@ -81,7 +79,7 @@
 
         okuids = [r[0] for r in (os.path.splitext(f) for f in os.listdir(self.holidays_dir)) if r[1] == ".ics"]
 
-        baduids = ["12345 at example.com", "67890 at example.com"]
+        baduids = ["12345%40example.com", "67890%40example.com"]
 
         d = self.simple_event_multiget("/calendar_multiget_events/", okuids, baduids)
         d.addCallbacks(_restoreValueOK, _restoreValueError)
@@ -104,10 +102,11 @@
 
         okuids = [r[0] for r in (os.path.splitext(f) for f in os.listdir(self.holidays_dir)) if r[1] == ".ics"]
 
-        baduids = ["12345 at example.com", "67890 at example.com"]
+        baduids = ["12345%40example.com", "67890%40example.com"]
 
         return self.simple_event_multiget("/calendar_multiget_events/", okuids, baduids, withData=False)
 
+    @todo("Remove: Does not work with new store")
     @inlineCallbacks
     def test_multiget_one_broken_event(self):
         """
@@ -157,7 +156,9 @@
 BEGIN:VEVENT
 UID:bad
 DTSTART;VALUE=DATE:20020214
-DTEND;VALUE=DATE:20020""".replace("\n", "\r\n"))
+DTEND;VALUE=DATE:20020
+END:VCALENDAR
+""".replace("\n", "\r\n"))
         f.close
 
         okuids = ["good", ]

Modified: CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_options.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_options.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_options.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -74,7 +74,7 @@
 
             allow = response.headers.getHeader("allow")
             if not allow: self.fail("no Allow header: %s" % (response.headers,))
-            self.assertIn("MKCALENDAR", allow, "no MKCALENDAR support")
+            self.assertNotIn("MKCALENDAR", allow, "no MKCALENDAR support")
 
         request = SimpleRequest(self.site, "OPTIONS", "/")
 

Modified: CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_props.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_props.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_props.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -128,7 +128,6 @@
 
             query = davxml.PropertyFind(
                         davxml.PropertyContainer(
-                            davxml.GETETag(),
                             caldavxml.SupportedCalendarData(),
                             caldavxml.SupportedCalendarComponentSet(),
                             davxml.SupportedReportSet(),

Modified: CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_schedule.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_schedule.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_schedule.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -73,7 +73,6 @@
 
         query = davxml.PropertyFind(
                     davxml.PropertyContainer(
-                        davxml.GETETag(),
                         caldavxml.CalendarFreeBusySet(),
                     ),
                 )

Modified: CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_sharing.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_sharing.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_sharing.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -23,17 +23,26 @@
 from twisted.internet.defer import inlineCallbacks, returnValue, succeed
 from twistedcaldav import customxml
 from twistedcaldav.config import config
-from twistedcaldav.test.util import HomeTestCase
+from twistedcaldav.test.util import HomeTestCase, norequest
+from twistedcaldav.resource import CalDAVResource
 
 
 class SharingTests(HomeTestCase):
 
     class FakePrincipal(object):
         
+        class FakeRecord(object):
+            
+            def __init__(self, name, cuaddr):
+                self.fullName = name
+                self.guid = name
+                self.calendarUserAddresses = set((cuaddr,))
+
         def __init__(self, cuaddr):
             self.path = "/principals/__uids__/%s" % (cuaddr[7:].split('@')[0],)
             self.homepath = "/calendars/__uids__/%s" % (cuaddr[7:].split('@')[0],)
             self.displayname = cuaddr[7:].split('@')[0].upper()
+            self.record = self.FakeRecord(cuaddr[7:].split('@')[0], cuaddr)
 
         def calendarHome(self, request):
             class FakeHome(object):
@@ -49,21 +58,22 @@
 
     @inlineCallbacks
     def setUp(self):
+        yield super(SharingTests, self).setUp()
+
         self.patch(config.Sharing, "Enabled", True)
         self.patch(config.Sharing.Calendars, "Enabled", True)
 
-        yield super(SharingTests, self).setUp()
-
         self.resource = (
-            yield self.site.resource.locateChild(self.request, ["calendar"])
+            yield self.site.resource.locateChild(norequest(), ["calendar"])
         )[0]
+        self.site.resource.putChild("calendar", self.resource)
 
-        self.resource.validUserIDForShare = self._fakeValidUserID
-        self.resource.validUserIDWithCommonNameForShare = self._fakeValidUserID
-        self.resource.sendInvite = lambda record, request: succeed(True)
-        self.resource.removeInvite = lambda record, request: succeed(True)
+        CalDAVResource.validUserIDForShare = self._fakeValidUserID
+        CalDAVResource.validUserIDWithCommonNameForShare = self._fakeValidUserID
+        CalDAVResource.sendInvite = lambda self, record, request: succeed(True)
+        CalDAVResource.removeInvite = lambda self, record, request: succeed(True)
 
-        self.resource.principalForCalendarUserAddress = lambda cuaddr: SharingTests.FakePrincipal(cuaddr)
+        CalDAVResource.principalForCalendarUserAddress = lambda self, cuaddr: SharingTests.FakePrincipal(cuaddr)
 
 
     def _fakeValidUserID(self, userid, *args):
@@ -219,7 +229,7 @@
         
         isShared = (yield self.resource.isShared(None))
         self.assertTrue(isShared)
-        isVShared = (yield self.resource.isVirtualShare(None))
+        isVShared = (yield self.resource.isVirtualShare())
         self.assertFalse(isVShared)
 
     @inlineCallbacks

Modified: CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_sql.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_sql.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/test_sql.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -173,19 +173,6 @@
         self.assertFalse(hasattr(db, "_db_connection"))
         db._db_close()
         
-    def test_ignore_db_files(self):
-        """
-        Make sure database files are not listed as children.
-        """
-        colpath = self.site.resource.fp.path
-        fd = open(os.path.join(colpath, db_prefix + "sqlite"), "w")
-        fd.close()
-        fd = open(os.path.join(colpath, "test"), "w")
-        fd.close()
-        children = self.site.resource.listChildren()
-        self.assertTrue("test" in children)
-        self.assertFalse(db_prefix + "sqlite" in children)
-
     def test_duplicate_create(self):
         dbname = self.mktemp()
         

Modified: CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/util.py	2010-08-04 20:17:36 UTC (rev 5979)
+++ CalendarServer/branches/new-store-no-caldavfile-2/twistedcaldav/test/util.py	2010-08-05 02:38:06 UTC (rev 5980)
@@ -15,6 +15,7 @@
 ##
 
 from __future__ import with_statement
+from calendarserver.provision.root import RootResource
 
 __all__ = [
     "featureUnimplemented",
@@ -36,7 +37,6 @@
 from twext.python.filepath import CachingFilePath as FilePath, CachingFilePath
 import twext.web2.dav.test.util
 from twext.web2.dav import davxml
-from twext.web2.dav.static import DAVFile
 from twext.web2.http import HTTPError, StatusResponse
 
 from twistedcaldav import memcacher
@@ -68,7 +68,7 @@
 proxiesFile = dirTest.child("proxies.xml")
 
 class TestCase(twext.web2.dav.test.util.TestCase):
-    resource_class = DAVFile
+    resource_class = RootResource
 
     def createStockDirectoryService(self):
         """
@@ -332,8 +332,7 @@
         it a new transaction.
         """
         users = self.homeProvisioner.getChild("users")
-        self.request = norequest()
-        user, ignored = (yield users.locateChild(self.request, ["wsanchez"]))
+        user, ignored = (yield users.locateChild(norequest(), ["wsanchez"]))
 
         # Force the request to succeed regardless of the implementation of
         # accessControlList.
@@ -372,6 +371,7 @@
         super(AddressBookHomeTestCase, self).setUp()
 
         fp = FilePath(self.mktemp())
+        fp.createDirectory()
 
         self.createStockDirectoryService()
 
@@ -383,9 +383,10 @@
             _newStore
         )
         
-        def _defer(_):
+        def _defer(user):
             # Commit the transaction
             self.site.resource._associatedTransaction.commit()
+            self.docroot = user._newStoreHome._path.path
             
         return self._refreshRoot().addCallback(_defer)
 
@@ -407,6 +408,7 @@
         # Fix the site to point directly at the user's calendar home so that we
         # can focus on testing just that rather than hierarchy traversal..
         self.site.resource = user
+        returnValue(user)
 
 
     @inlineCallbacks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100804/03ce6c6b/attachment-0001.html>


More information about the calendarserver-changes mailing list