<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14530] CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14530">14530</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2015-03-09 10:01:19 -0700 (Mon, 09 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Adds a test for sharee removing an event</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserssagentrashcan5txdavcommondatastoretesttest_sqlpy">CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserssagentrashcan5txdavcommondatastoretesttest_trashpy">CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_trash.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserssagentrashcan5txdavcommondatastoretesttest_sqlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py (14529 => 14530)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py        2015-03-09 16:00:57 UTC (rev 14529)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_sql.py        2015-03-09 17:01:19 UTC (rev 14530)
</span><span class="lines">@@ -20,17 +20,12 @@
</span><span class="cx"> 
</span><span class="cx"> from uuid import UUID
</span><span class="cx"> 
</span><del>-from pycalendar.datetime import DateTime
</del><span class="cx"> from twext.enterprise.dal.syntax import Insert
</span><span class="cx"> from twext.enterprise.dal.syntax import Select
</span><del>-from twext.enterprise.jobqueue import JobItem
-from twisted.internet import reactor
</del><span class="cx"> from twisted.internet.defer import Deferred
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue, succeed
</span><span class="cx"> from twisted.internet.task import Clock
</span><span class="cx"> from twisted.trial.unittest import TestCase
</span><del>-from twistedcaldav.ical import Component
-from twistedcaldav.test.util import StoreTestCase
</del><span class="cx"> # from twistedcaldav.vcard import Component as VCard
</span><span class="cx"> from txdav.common.datastore.sql import (
</span><span class="cx">     log, CommonStoreTransactionMonitor,
</span><span class="lines">@@ -512,1825 +507,3 @@
</span><span class="cx">     def abort(self):
</span><span class="cx">         self.action = &quot;aborted&quot;
</span><span class="cx">         return succeed(None)
</span><del>-
-
-
-class CommonTrashTests(StoreTestCase):
-
-    def _homeForUser(self, txn, userName):
-        return txn.calendarHomeWithUID(userName, create=True)
-
-    @inlineCallbacks
-    def _collectionForUser(self, txn, userName, collectionName, create=False, onlyInTrash=False):
-        home = yield txn.calendarHomeWithUID(userName, create=True)
-        collection = yield home.childWithName(collectionName, onlyInTrash=onlyInTrash)
-        if collection is None:
-            if create:
-                collection = yield home.createCalendarWithName(collectionName)
-        returnValue(collection)
-
-
-    @inlineCallbacks
-    def _createResource(self, txn, userName, collectionName, resourceName, data):
-        collection = yield self._collectionForUser(txn, userName, collectionName)
-        resource = yield collection.createObjectResourceWithName(
-            resourceName, Component.allFromString(data)
-        )
-        returnValue(resource)
-
-
-    @inlineCallbacks
-    def _getResource(self, txn, userName, collectionName, resourceName):
-        collection = yield self._collectionForUser(txn, userName, collectionName)
-        if not resourceName:
-            # Get the first one
-            resourceNames = yield collection.listObjectResources()
-            if len(resourceNames) == 0:
-                returnValue(None)
-            resourceName = resourceNames[0]
-        resource = yield collection.calendarObjectWithName(resourceName)
-        returnValue(resource)
-
-
-    @inlineCallbacks
-    def _getResourceNames(self, txn, userName, collectionName):
-        collection = yield self._collectionForUser(txn, userName, collectionName)
-        resourceNames = yield collection.listObjectResources()
-        returnValue(resourceNames)
-
-
-    @inlineCallbacks
-    def _updateResource(self, txn, userName, collectionName, resourceName, data):
-        resource = yield self._getResource(txn, userName, collectionName, resourceName)
-        yield resource.setComponent(Component.fromString(data))
-        returnValue(resource)
-
-
-    @inlineCallbacks
-    def _getResourceData(self, txn, userName, collectionName, resourceName):
-        resource = yield self._getResource(txn, userName, collectionName, resourceName)
-        if resource is None:
-            returnValue(None)
-        component = yield resource.component()
-        returnValue(str(component).replace(&quot;\r\n &quot;, &quot;&quot;))
-
-
-    @inlineCallbacks
-    def test_trashUnscheduled(self):
-        &quot;&quot;&quot;
-        Verify the &quot;resource is entirely in the trash&quot; flag
-        &quot;&quot;&quot;
-
-        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
-DTSTART;TZID=America/Los_Angeles:20141108T093000
-DTEND;TZID=America/Los_Angeles:20141108T103000
-CREATED:20141106T192546Z
-DTSTAMP:20141106T192546Z
-RRULE:FREQ=DAILY
-SEQUENCE:0
-SUMMARY:repeating event
-TRANSP:OPAQUE
-END:VEVENT
-BEGIN:VEVENT
-UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
-RECURRENCE-ID;TZID=America/Los_Angeles:20141111T093000
-DTSTART;TZID=America/Los_Angeles:20141111T110000
-DTEND;TZID=America/Los_Angeles:20141111T120000
-CREATED:20141106T192546Z
-DTSTAMP:20141106T192546Z
-SEQUENCE:0
-SUMMARY:repeating event
-TRANSP:OPAQUE
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot;
-
-        txn = self.store.newTransaction()
-
-        #
-        # First, use a calendar object
-        #
-
-        home = yield txn.calendarHomeWithUID(&quot;user01&quot;, create=True)
-        collection = yield home.childWithName(&quot;calendar&quot;)
-        trash = yield home.childWithName(&quot;trash&quot;)
-
-        # No objects
-        objects = yield collection.listObjectResources()
-        self.assertEquals(len(objects), 0)
-
-        # Create an object
-        resource = yield collection.createObjectResourceWithName(
-            &quot;test.ics&quot;,
-            Component.allFromString(data1)
-        )
-
-        # One object in collection
-        objects = yield collection.listObjectResources()
-        self.assertEquals(len(objects), 1)
-
-        # No objects in trash
-        objects = yield trash.listObjectResources()
-        self.assertEquals(len(objects), 0)
-
-        # Verify it's not in the trash
-        self.assertFalse((yield resource.isInTrash()))
-        trashed = yield resource.whenTrashed()
-        self.assertTrue(trashed is None)
-
-        # Move object to trash
-        newName = yield resource.toTrash()
-
-        yield txn.commit()
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-
-        # Verify it's in the trash
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, newName)
-        self.assertTrue((yield resource.isInTrash()))
-        trashed = yield resource.whenTrashed()
-        self.assertFalse(trashed is None)
-
-        # No objects in collection
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        # One object in trash
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # Put back from trash
-        yield resource.fromTrash()
-
-        yield txn.commit()
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-
-        # Not in trash
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertTrue(resource is None)
-
-
-        # One object in collection
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 1)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;calendar&quot;, newName)
-        self.assertFalse((yield resource.isInTrash()))
-        trashed = yield resource.whenTrashed()
-        self.assertTrue(trashed is None)
-
-        # No objects in trash
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        yield txn.commit()
-
-
-        # Not implemented
-#         #
-#         # Now with addressbook
-#         #
-
-#         data2 = &quot;&quot;&quot;BEGIN:VCARD
-# VERSION:3.0
-# PRODID:-//Apple Inc.//iOS 6.0//EN
-# UID:41425f1b-b831-40f2-b0bb-e70ec0938afd
-# FN:Test User
-# N:User;Test;;;
-# REV:20120613T002007Z
-# TEL;type=CELL;type=VOICE;type=pref:(408) 555-1212
-# END:VCARD
-# &quot;&quot;&quot;
-
-#         print(&quot;ADDRESSBOOK TIME&quot;)
-
-#         home = yield txn.addressbookHomeWithUID(&quot;user01&quot;, create=True)
-#         collection = yield home.childWithName(&quot;addressbook&quot;)
-#         trash = yield home.childWithName(&quot;trash&quot;)
-
-#         # Create an object
-#         resource = yield collection.createObjectResourceWithName(
-#             &quot;test.vcf&quot;,
-#             VCard.fromString(data2)
-#         )
-
-#         # One object
-#         objects = yield collection.listObjectResources()
-#         self.assertEquals(len(objects), 1)
-
-#         # Verify it's not in the trash
-#         self.assertFalse((yield resource.isInTrash()))
-
-#         # Move object to trash
-#         yield resource.toTrash()
-
-#         # Verify it's in the trash
-#         self.assertTrue((yield resource.isInTrash()))
-
-#         # No objects
-#         objects = yield collection.listObjectResources()
-#         self.assertEquals(len(objects), 0)
-
-#         # One object in trash
-#         objects = yield trash.listObjectResources()
-#         print(&quot;OBJECT LIST&quot;, objects)
-#         self.assertEquals(len(objects), 1)
-
-#         # Put back from trash
-#         print(&quot;FETCHING FROM TRASH USING&quot;, objects[0])
-#         resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, objects[0])
-#         yield resource.fromTrash()
-
-#         # Not in trash
-#         self.assertFalse((yield resource.isInTrash()))
-
-#         # One object
-#         objects = yield collection.listObjectResources()
-#         self.assertEquals(len(objects), 1)
-
-#         yield txn.commit()
-
-
-
-
-    @inlineCallbacks
-    def test_trashScheduledFullyInFuture(self):
-
-        from twistedcaldav.stdconfig import config
-        self.patch(config, &quot;EnableTrashCollection&quot;, True)
-
-        # A month in the future
-        start = DateTime.getNowUTC()
-        start.setHHMMSS(0, 0, 0)
-        start.offsetMonth(1)
-        end = DateTime.getNowUTC()
-        end.setHHMMSS(1, 0, 0)
-        end.offsetMonth(1)
-        subs = {
-            &quot;start&quot;: start,
-            &quot;end&quot;: end,
-        }
-
-        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        # user01 invites user02
-        txn = self.store.newTransaction()
-        yield self._createResource(
-            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
-        )
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy has SCHEDULE-STATUS update
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
-
-        # user02 has an inbox item
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user02 accepts
-        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01 has an inbox item
-        txn = self.store.newTransaction()
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # user01's copy has SCHEDULE-STATUS update
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        # user01 trashes event
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        yield resource.remove()
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy is in the trash, still with user02 accepted
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertTrue((yield resource.isInTrash()))
-        trashed = yield resource.whenTrashed()
-        self.assertFalse(trashed is None)
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-        yield txn.commit()
-
-        # user02's copy is cancelled
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;METHOD:CANCEL&quot; in data)
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;STATUS:CANCELLED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        yield resource.remove()
-        data = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertEquals(data, None)
-        yield txn.commit()
-
-        # user01 restores event from the trash
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
-        yield resource.fromTrash()
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-
-        # user01's copy should be back on their calendar
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertFalse((yield resource.isInTrash()))
-        trashed = yield resource.whenTrashed()
-        self.assertTrue(trashed is None)
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=NEEDS-ACTION&quot; in data)
-
-        # user02's copy should be back on their calendar
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=NEEDS-ACTION&quot; in data)
-
-        yield txn.commit()
-
-
-
-    @inlineCallbacks
-    def test_trashScheduledFullyInFutureAttendeeTrashedThenOrganizerChanged(self):
-
-        from twistedcaldav.stdconfig import config
-        self.patch(config, &quot;EnableTrashCollection&quot;, True)
-
-        # A month in the future
-        start = DateTime.getNowUTC()
-        start.setHHMMSS(0, 0, 0)
-        start.offsetMonth(1)
-        end = DateTime.getNowUTC()
-        end.setHHMMSS(1, 0, 0)
-        end.offsetMonth(1)
-        subs = {
-            &quot;start&quot;: start,
-            &quot;end&quot;: end,
-        }
-
-        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-
-        start.offsetHours(1)
-        end.offsetHours(1)
-
-        data3 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=DECLINED:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        data4 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:CHANGED!
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=DECLINED:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-
-        # user01 invites user02
-        txn = self.store.newTransaction()
-        yield self._createResource(
-            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
-        )
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy has SCHEDULE-STATUS update
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
-
-        # user02 has an inbox item
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user02 accepts
-        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01 has an inbox item
-        txn = self.store.newTransaction()
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # user01's copy has SCHEDULE-STATUS update
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        # user02 trashes event
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's calendar copy shows user02 declined
-        txn = self.store.newTransaction()
-
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-
-        # user01's inbox copy also shows user02 declined
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-
-        # user02's copy is in the trash only, and still has ACCEPTED
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-
-        # result = yield txn.execSQL(&quot;select * from calendar_object&quot;, [])
-        # for row in result:
-        #     print(&quot;calendar object ROW&quot;, row)
-
-        # result = yield txn.execSQL(&quot;select * from calendar_metadata&quot;, [])
-        # for row in result:
-        #     print(&quot;calendar ROW&quot;, row)
-
-
-        yield txn.commit()
-
-        # user01 makes a change to event while user02's copy is in the trash
-        txn = self.store.newTransaction()
-
-        yield self._updateResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data3)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=NEEDS-ACTION&quot; in data)
-
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        # user02 trashes event again
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's calendar copy shows user02 declined
-        txn = self.store.newTransaction()
-
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-
-        # user01's inbox copy also shows user02 declined
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01 makes a SUMMARY change to event while user02's copy is in the trash
-        txn = self.store.newTransaction()
-
-        yield self._updateResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data4)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-
-        txn = self.store.newTransaction()
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        yield txn.commit()
-
-
-    @inlineCallbacks
-    def test_trashScheduledFullyInFutureAttendeeRemovedThenOrganizerChanged(self):
-
-        from twistedcaldav.stdconfig import config
-        self.patch(config, &quot;EnableTrashCollection&quot;, True)
-
-        # A month in the future
-        start = DateTime.getNowUTC()
-        start.setHHMMSS(0, 0, 0)
-        start.offsetMonth(1)
-        end = DateTime.getNowUTC()
-        end.setHHMMSS(1, 0, 0)
-        end.offsetMonth(1)
-        subs = {
-            &quot;start&quot;: start,
-            &quot;end&quot;: end,
-        }
-
-        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-
-        data3 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:CHANGED!
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=DECLINED:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-
-        start.offsetHours(1)
-        end.offsetHours(1)
-
-        data4 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:CHANGED!
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=DECLINED:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-
-        # user01 invites user02
-        txn = self.store.newTransaction()
-        yield self._createResource(
-            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
-        )
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy has SCHEDULE-STATUS update
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
-
-        # user02 has an inbox item
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user02 accepts
-        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01 has an inbox item
-        txn = self.store.newTransaction()
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # user01's copy has SCHEDULE-STATUS update
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        # user02 trashes event
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's calendar copy shows user02 declined
-        txn = self.store.newTransaction()
-
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-
-        # user01's inbox copy also shows user02 declined
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # user02's copy is in the trash only, and still has ACCEPTED
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-        yield txn.commit()
-
-
-        # user02 removes the event completely from the trash
-
-        txn = self.store.newTransaction()
-
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        yield resource.reallyRemove()
-
-        yield txn.commit()
-
-
-        # user01 makes a SUMMARY change to event (user02 does not get notified because they are fully declined)
-        txn = self.store.newTransaction()
-
-        yield self._updateResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data3)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        yield txn.commit()
-
-        # user01 makes a time change to event (user02 gets notified)
-        txn = self.store.newTransaction()
-
-        yield self._updateResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data4)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=NEEDS-ACTION&quot; in data)
-
-        yield txn.commit()
-
-
-
-    @inlineCallbacks
-    def test_trashScheduledFullyInFutureAttendeeTrashedThenPutBack(self):
-
-        from twistedcaldav.stdconfig import config
-        self.patch(config, &quot;EnableTrashCollection&quot;, True)
-
-        # A month in the future
-        start = DateTime.getNowUTC()
-        start.setHHMMSS(0, 0, 0)
-        start.offsetMonth(1)
-        end = DateTime.getNowUTC()
-        end.setHHMMSS(1, 0, 0)
-        end.offsetMonth(1)
-        subs = {
-            &quot;start&quot;: start,
-            &quot;end&quot;: end,
-        }
-
-        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-
-        # user01 invites user02
-        txn = self.store.newTransaction()
-        yield self._createResource(
-            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
-        )
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy has SCHEDULE-STATUS update
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
-
-        # user02 has an inbox item
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user02 accepts
-        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01 has an inbox item
-        txn = self.store.newTransaction()
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # user01's copy has SCHEDULE-STATUS update
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        # user02 trashes event
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's calendar copy shows user02 declined
-        txn = self.store.newTransaction()
-
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-
-        # user01's inbox copy also shows user02 declined
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # result = yield txn.execSQL(&quot;select * from calendar_object&quot;, [])
-        # for row in result:
-        #     print(&quot;ROW&quot;, row)
-
-        # user02's copy is in the trash only, and still has ACCEPTED
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-
-        yield txn.commit()
-
-        # user02 moves it from trash
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        yield resource.fromTrash()
-        yield txn.commit()
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's calendar copy shows user02 accepted
-        txn = self.store.newTransaction()
-
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-
-        # user01's inbox copy also shows user02 accepted
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # user02 has nothing in trash
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-
-        yield txn.commit()
-
-
-
-    @inlineCallbacks
-    def test_trashScheduledFullyInPast(self):
-
-        from twistedcaldav.stdconfig import config
-        self.patch(config, &quot;EnableTrashCollection&quot;, True)
-
-        # A month in the past
-        start = DateTime.getNowUTC()
-        start.setHHMMSS(0, 0, 0)
-        start.offsetMonth(-1)
-        end = DateTime.getNowUTC()
-        end.setHHMMSS(1, 0, 0)
-        end.offsetMonth(-1)
-        subs = {
-            &quot;start&quot;: start,
-            &quot;end&quot;: end,
-        }
-
-        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=TENTATIVE:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        # user01 invites user02
-        txn = self.store.newTransaction()
-        yield self._createResource(
-            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
-        )
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy has SCHEDULE-STATUS update
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
-
-        # user02 has an inbox item
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user02 accepts
-        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01 has an inbox item
-        txn = self.store.newTransaction()
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user01's copy has SCHEDULE-STATUS update
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
-        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        # user01 trashes event
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        yield resource.remove()
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy is in the trash, still with user02 partstat
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
-        yield txn.commit()
-
-        # user02's copy is cancelled
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;METHOD:CANCEL&quot; in data)
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;STATUS:CANCELLED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        yield resource.remove()
-        data = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertEquals(data, None)
-        yield txn.commit()
-
-        # user01 restores event from the trash
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
-        yield resource.fromTrash()
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-
-        # user01's copy should be back on their calendar
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
-
-        # user02's copy should be back on their calendar
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
-
-
-        yield txn.commit()
-
-
-    @inlineCallbacks
-    def test_trashScheduledFullyInPastAttendeeTrashedThenPutBack(self):
-
-        from twistedcaldav.stdconfig import config
-        self.patch(config, &quot;EnableTrashCollection&quot;, True)
-
-        # A month in the past
-        start = DateTime.getNowUTC()
-        start.setHHMMSS(0, 0, 0)
-        start.offsetMonth(-1)
-        end = DateTime.getNowUTC()
-        end.setHHMMSS(1, 0, 0)
-        end.offsetMonth(-1)
-        subs = {
-            &quot;start&quot;: start,
-            &quot;end&quot;: end,
-        }
-
-        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=TENTATIVE:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        # user01 invites user02
-        txn = self.store.newTransaction()
-        yield self._createResource(
-            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
-        )
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy has SCHEDULE-STATUS update
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
-
-        # user02 has an inbox item
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user02 accepts
-        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01 has an inbox item
-        txn = self.store.newTransaction()
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user01's copy has SCHEDULE-STATUS update
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
-        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
-
-        # clear the inbox items
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        # user02 trashes event
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        yield resource.remove()
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's calendar copy shows user02 declined
-        txn = self.store.newTransaction()
-
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-
-        # user01's inbox copy also shows user02 declined
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # user02's copy is in the trash only, and still has TENTATIVE
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
-
-        yield txn.commit()
-
-        # user02 moves it from trash
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        yield resource.fromTrash()
-        yield txn.commit()
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's calendar copy shows user02 tentative again
-        txn = self.store.newTransaction()
-
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
-
-        # user01's inbox copy also shows user02 tentative
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # user02 has nothing in trash
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
-
-        yield txn.commit()
-
-
-
-    @inlineCallbacks
-    def test_trashScheduledSpanningNow(self):
-
-        from twistedcaldav.stdconfig import config
-        self.patch(config, &quot;EnableTrashCollection&quot;, True)
-
-        # A month in the past
-        start = DateTime.getNowUTC()
-        start.setHHMMSS(0, 0, 0)
-        start.offsetMonth(-1)
-        end = DateTime.getNowUTC()
-        end.setHHMMSS(1, 0, 0)
-        end.offsetMonth(-1)
-        subs = {
-            &quot;start&quot;: start,
-            &quot;end&quot;: end,
-        }
-
-        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-RRULE:FREQ=WEEKLY;COUNT=20
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-RRULE:FREQ=WEEKLY;COUNT=20
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        # user01 invites user02
-        txn = self.store.newTransaction()
-        yield self._createResource(
-            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
-        )
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy has SCHEDULE-STATUS update
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
-
-        # user02 has an inbox item
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user02 accepts
-        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01 has an inbox item
-        txn = self.store.newTransaction()
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user01's copy has SCHEDULE-STATUS update
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        # user01 trashes event
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        yield resource.remove()
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy is in the trash, still with user02 accepted
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-        yield txn.commit()
-
-        # user02's copy is cancelled
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;METHOD:CANCEL&quot; in data)
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;STATUS:CANCELLED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        yield resource.remove()
-        data = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertEquals(data, None)
-        yield txn.commit()
-
-        # user01 restores event from the trash
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
-        trashedName = yield resource.fromTrash()
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-
-        # user01's trash should be empty
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;trash&quot;)
-        self.assertEquals(len(resourceNames), 0)
-
-        # user01 should have two .ics
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;calendar&quot;)
-        self.assertEquals(len(resourceNames), 2)
-        self.assertTrue(trashedName in resourceNames)
-        resourceNames.remove(trashedName)
-        newName = resourceNames[0]
-
-        # user01's test.ics -- verify it got split correctly, by making sure
-        # it's got a count other than 20 now
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, trashedName)
-        self.assertTrue(&quot;COUNT=&quot; in data)
-        self.assertFalse(&quot;COUNT=20&quot; in data)
-
-        # user01's new .ics -- verify it got split correctly
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, newName)
-        self.assertTrue(&quot;RRULE:FREQ=WEEKLY;UNTIL=&quot; in data)
-
-        # user02's copy should be back on their calendar, and not in trash
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEquals(len(resourceNames), 1)
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEquals(len(resourceNames), 0)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=NEEDS-ACTION&quot; in data)
-
-        yield txn.commit()
-
-
-    @inlineCallbacks
-    def test_trashScheduledSpanningNowAttendeeTrashedThenPutBack(self):
-
-        from twistedcaldav.stdconfig import config
-        self.patch(config, &quot;EnableTrashCollection&quot;, True)
-
-        # A month in the past
-        start = DateTime.getNowUTC()
-        start.setHHMMSS(0, 0, 0)
-        start.offsetMonth(-1)
-        end = DateTime.getNowUTC()
-        end.setHHMMSS(1, 0, 0)
-        end.offsetMonth(-1)
-        subs = {
-            &quot;start&quot;: start,
-            &quot;end&quot;: end,
-        }
-
-        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-RRULE:FREQ=WEEKLY;COUNT=20
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:12345-67890-attendee-reply
-DTSTART;TZID=America/Los_Angeles:%(start)s
-DTEND;TZID=America/Los_Angeles:%(end)s
-DTSTAMP:20150204T192546Z
-RRULE:FREQ=WEEKLY;COUNT=20
-SUMMARY:Scheduled
-ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
-ATTENDEE:mailto:user01@example.com
-ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot; % subs
-
-        # user01 invites user02
-        txn = self.store.newTransaction()
-        yield self._createResource(
-            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
-        )
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy has SCHEDULE-STATUS update
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
-
-        # user02 has an inbox item
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user02 accepts
-        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01 has an inbox item
-        txn = self.store.newTransaction()
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        # user01's copy has SCHEDULE-STATUS update
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        yield txn.commit()
-
-        # user02 trashes event
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        yield resource.remove()
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's copy shows user02 declined
-        txn = self.store.newTransaction()
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 1)
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 1)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # user02's copy is in the trash only, and still has ACCEPTED
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-
-        yield txn.commit()
-        # user02 moves it from trash
-        txn = self.store.newTransaction()
-        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
-        yield resource.fromTrash()
-        yield txn.commit()
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        # user01's calendar copy shows user02 accepted
-        txn = self.store.newTransaction()
-
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-
-        # user01's inbox copy also shows user02 accepted
-        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
-        yield resource.remove()
-
-        # user02 has nothing in trash
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
-        self.assertEqual(len(resourceNames), 1)
-
-        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
-        self.assertEqual(len(resourceNames), 0)
-
-        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
-        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
-
-        yield txn.commit()
-
-
-    @inlineCallbacks
-    def test_trashCalendar(self):
-
-        from twistedcaldav.stdconfig import config
-        self.patch(config, &quot;EnableTrashCollection&quot;, True)
-
-        txn = self.store.newTransaction()
-
-        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;, create=True)
-        isInTrash = collection.isInTrash()
-        self.assertFalse(isInTrash)
-        whenTrashed = collection.whenTrashed()
-        self.assertEquals(whenTrashed, None)
-
-        home = yield self._homeForUser(txn, &quot;user01&quot;)
-        names = yield home.listChildren()
-        self.assertTrue(&quot;test&quot; in names)
-        names = yield home.listChildren(onlyInTrash=True)
-        self.assertFalse(&quot;test&quot; in names)
-
-        yield collection.remove()
-        isInTrash = collection.isInTrash()
-        self.assertTrue(isInTrash)
-        whenTrashed = collection.whenTrashed()
-        self.assertNotEquals(whenTrashed, None)
-
-        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;)
-        self.assertEquals(collection, None)
-
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-
-        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;)
-        self.assertEquals(collection, None)
-        home = yield self._homeForUser(txn, &quot;user01&quot;)
-        names = yield home.listChildren(onlyInTrash=True)
-        trashedName = names[0]
-        collection = yield self._collectionForUser(txn, &quot;user01&quot;, trashedName, onlyInTrash=True)
-        self.assertNotEquals(collection, None)
-        home = yield self._homeForUser(txn, &quot;user01&quot;)
-        names = yield home.listChildren()
-        self.assertFalse(&quot;test&quot; in names)
-        names = yield home.listChildren(onlyInTrash=True)
-        self.assertTrue(trashedName in names)
-
-        yield collection.fromTrash()
-
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-        home = yield self._homeForUser(txn, &quot;user01&quot;)
-        names = yield home.listChildren()
-        self.assertTrue(trashedName in names)
-        names = yield home.listChildren(onlyInTrash=True)
-        self.assertFalse(&quot;test&quot; in names)
-        yield txn.commit()
-
-
-    @inlineCallbacks
-    def test_trashCalendarWithUnscheduled(self):
-
-        from twistedcaldav.stdconfig import config
-        self.patch(config, &quot;EnableTrashCollection&quot;, True)
-
-        txn = self.store.newTransaction()
-
-        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;, create=True)
-
-        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
-BEGIN:VEVENT
-UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
-DTSTART;TZID=America/Los_Angeles:20141108T093000
-DTEND;TZID=America/Los_Angeles:20141108T103000
-CREATED:20141106T192546Z
-DTSTAMP:20141106T192546Z
-RRULE:FREQ=DAILY
-SEQUENCE:0
-SUMMARY:repeating event
-TRANSP:OPAQUE
-END:VEVENT
-BEGIN:VEVENT
-UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
-RECURRENCE-ID;TZID=America/Los_Angeles:20141111T093000
-DTSTART;TZID=America/Los_Angeles:20141111T110000
-DTEND;TZID=America/Los_Angeles:20141111T120000
-CREATED:20141106T192546Z
-DTSTAMP:20141106T192546Z
-SEQUENCE:0
-SUMMARY:repeating event
-TRANSP:OPAQUE
-END:VEVENT
-END:VCALENDAR
-&quot;&quot;&quot;
-
-        # Create an object
-        resource = yield collection.createObjectResourceWithName(
-            &quot;test.ics&quot;,
-            Component.allFromString(data1)
-        )
-
-        # One object in collection
-        objects = yield collection.listObjectResources()
-        self.assertEquals(len(objects), 1)
-
-        # No objects in trash
-        trash = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;trash&quot;)
-        objects = yield trash.listObjectResources()
-        self.assertEquals(len(objects), 0)
-
-        # Verify it's not in the trash
-        self.assertFalse((yield resource.isInTrash()))
-        trashed = yield resource.whenTrashed()
-        self.assertTrue(trashed is None)
-
-        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;)
-        resources = yield trash.trashForCollection(collection._resourceID)
-        self.assertEquals(len(resources), 0)
-
-        yield txn.commit()
-
-        txn = self.store.newTransaction()
-        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;)
-        yield collection.remove()
-        yield txn.commit()
-
-        txn = self.store.newTransaction()
-        # One object in trash
-        trash = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;trash&quot;)
-        objects = yield trash.listObjectResources()
-        self.assertEquals(len(objects), 1)
-
-        resources = yield trash.trashForCollection(collection._resourceID)
-        self.assertEquals(len(resources), 1)
-
-        home = yield self._homeForUser(txn, &quot;user01&quot;)
-        names = yield home.listChildren(onlyInTrash=True)
-        trashedName = names[0]
-        collection = yield self._collectionForUser(txn, &quot;user01&quot;, trashedName, onlyInTrash=True)
-        yield collection.fromTrash()
-
-        yield txn.commit()
-
-        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
-
-        txn = self.store.newTransaction()
-        home = yield self._homeForUser(txn, &quot;user01&quot;)
-        names = yield home.listChildren()
-        self.assertTrue(trashedName in names)
-        names = yield home.listChildren(onlyInTrash=True)
-        self.assertFalse(trashedName in names)
-        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, trashedName)
-        self.assertEqual(len(resourceNames), 1)
-
-        yield txn.commit()
</del></span></pre></div>
<a id="CalendarServerbranchesuserssagentrashcan5txdavcommondatastoretesttest_trashpy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_trash.py (0 => 14530)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_trash.py                                (rev 0)
+++ CalendarServer/branches/users/sagen/trashcan-5/txdav/common/datastore/test/test_trash.py        2015-03-09 17:01:19 UTC (rev 14530)
</span><span class="lines">@@ -0,0 +1,1856 @@
</span><ins>+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+# 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 &quot;AS IS&quot; 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.
+##
+
+&quot;&quot;&quot;
+Trash-specific tests for L{txdav.common.datastore.sql}.
+&quot;&quot;&quot;
+
+from pycalendar.datetime import DateTime
+from twext.enterprise.jobqueue import JobItem
+from twisted.internet import reactor
+from twisted.internet.defer import inlineCallbacks, returnValue
+from twistedcaldav.ical import Component
+from twistedcaldav.test.util import StoreTestCase
+from txdav.common.datastore.sql_tables import _BIND_MODE_WRITE
+
+
+
+class TrashTests(StoreTestCase):
+
+
+    def _homeForUser(self, txn, userName):
+        return txn.calendarHomeWithUID(userName, create=True)
+
+    @inlineCallbacks
+    def _collectionForUser(self, txn, userName, collectionName, create=False, onlyInTrash=False):
+        home = yield txn.calendarHomeWithUID(userName, create=True)
+        collection = yield home.childWithName(collectionName, onlyInTrash=onlyInTrash)
+        if collection is None:
+            if create:
+                collection = yield home.createCalendarWithName(collectionName)
+        returnValue(collection)
+
+
+    @inlineCallbacks
+    def _createResource(self, txn, userName, collectionName, resourceName, data):
+        collection = yield self._collectionForUser(txn, userName, collectionName)
+        resource = yield collection.createObjectResourceWithName(
+            resourceName, Component.allFromString(data)
+        )
+        returnValue(resource)
+
+
+    @inlineCallbacks
+    def _getResource(self, txn, userName, collectionName, resourceName):
+        collection = yield self._collectionForUser(txn, userName, collectionName)
+        if not resourceName:
+            # Get the first one
+            resourceNames = yield collection.listObjectResources()
+            if len(resourceNames) == 0:
+                returnValue(None)
+            resourceName = resourceNames[0]
+        resource = yield collection.calendarObjectWithName(resourceName)
+        returnValue(resource)
+
+
+    @inlineCallbacks
+    def _getResourceNames(self, txn, userName, collectionName):
+        collection = yield self._collectionForUser(txn, userName, collectionName)
+        resourceNames = yield collection.listObjectResources()
+        returnValue(resourceNames)
+
+
+    @inlineCallbacks
+    def _updateResource(self, txn, userName, collectionName, resourceName, data):
+        resource = yield self._getResource(txn, userName, collectionName, resourceName)
+        yield resource.setComponent(Component.fromString(data))
+        returnValue(resource)
+
+
+    @inlineCallbacks
+    def _getResourceData(self, txn, userName, collectionName, resourceName):
+        resource = yield self._getResource(txn, userName, collectionName, resourceName)
+        if resource is None:
+            returnValue(None)
+        component = yield resource.component()
+        returnValue(str(component).replace(&quot;\r\n &quot;, &quot;&quot;))
+
+
+    @inlineCallbacks
+    def test_trashUnscheduled(self):
+        &quot;&quot;&quot;
+        Verify the &quot;resource is entirely in the trash&quot; flag
+        &quot;&quot;&quot;
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
+DTSTART;TZID=America/Los_Angeles:20141108T093000
+DTEND;TZID=America/Los_Angeles:20141108T103000
+CREATED:20141106T192546Z
+DTSTAMP:20141106T192546Z
+RRULE:FREQ=DAILY
+SEQUENCE:0
+SUMMARY:repeating event
+TRANSP:OPAQUE
+END:VEVENT
+BEGIN:VEVENT
+UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
+RECURRENCE-ID;TZID=America/Los_Angeles:20141111T093000
+DTSTART;TZID=America/Los_Angeles:20141111T110000
+DTEND;TZID=America/Los_Angeles:20141111T120000
+CREATED:20141106T192546Z
+DTSTAMP:20141106T192546Z
+SEQUENCE:0
+SUMMARY:repeating event
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+        txn = self.store.newTransaction()
+
+        #
+        # First, use a calendar object
+        #
+
+        home = yield txn.calendarHomeWithUID(&quot;user01&quot;, create=True)
+        collection = yield home.childWithName(&quot;calendar&quot;)
+        trash = yield home.childWithName(&quot;trash&quot;)
+
+        # No objects
+        objects = yield collection.listObjectResources()
+        self.assertEquals(len(objects), 0)
+
+        # Create an object
+        resource = yield collection.createObjectResourceWithName(
+            &quot;test.ics&quot;,
+            Component.allFromString(data1)
+        )
+
+        # One object in collection
+        objects = yield collection.listObjectResources()
+        self.assertEquals(len(objects), 1)
+
+        # No objects in trash
+        objects = yield trash.listObjectResources()
+        self.assertEquals(len(objects), 0)
+
+        # Verify it's not in the trash
+        self.assertFalse((yield resource.isInTrash()))
+        trashed = yield resource.whenTrashed()
+        self.assertTrue(trashed is None)
+
+        # Move object to trash
+        newName = yield resource.toTrash()
+
+        yield txn.commit()
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+
+        # Verify it's in the trash
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, newName)
+        self.assertTrue((yield resource.isInTrash()))
+        trashed = yield resource.whenTrashed()
+        self.assertFalse(trashed is None)
+
+        # No objects in collection
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        # One object in trash
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # Put back from trash
+        yield resource.fromTrash()
+
+        yield txn.commit()
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+
+        # Not in trash
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertTrue(resource is None)
+
+
+        # One object in collection
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 1)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;calendar&quot;, newName)
+        self.assertFalse((yield resource.isInTrash()))
+        trashed = yield resource.whenTrashed()
+        self.assertTrue(trashed is None)
+
+        # No objects in trash
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        yield txn.commit()
+
+
+
+    @inlineCallbacks
+    def test_trashScheduledFullyInFuture(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        # A month in the future
+        start = DateTime.getNowUTC()
+        start.setHHMMSS(0, 0, 0)
+        start.offsetMonth(1)
+        end = DateTime.getNowUTC()
+        end.setHHMMSS(1, 0, 0)
+        end.offsetMonth(1)
+        subs = {
+            &quot;start&quot;: start,
+            &quot;end&quot;: end,
+        }
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        # user01 invites user02
+        txn = self.store.newTransaction()
+        yield self._createResource(
+            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
+        )
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy has SCHEDULE-STATUS update
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
+
+        # user02 has an inbox item
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user02 accepts
+        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01 has an inbox item
+        txn = self.store.newTransaction()
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # user01's copy has SCHEDULE-STATUS update
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        # user01 trashes event
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        yield resource.remove()
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy is in the trash, still with user02 accepted
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertTrue((yield resource.isInTrash()))
+        trashed = yield resource.whenTrashed()
+        self.assertFalse(trashed is None)
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+        yield txn.commit()
+
+        # user02's copy is cancelled
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;METHOD:CANCEL&quot; in data)
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;STATUS:CANCELLED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        yield resource.remove()
+        data = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertEquals(data, None)
+        yield txn.commit()
+
+        # user01 restores event from the trash
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
+        yield resource.fromTrash()
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+
+        # user01's copy should be back on their calendar
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertFalse((yield resource.isInTrash()))
+        trashed = yield resource.whenTrashed()
+        self.assertTrue(trashed is None)
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=NEEDS-ACTION&quot; in data)
+
+        # user02's copy should be back on their calendar
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=NEEDS-ACTION&quot; in data)
+
+        yield txn.commit()
+
+
+
+    @inlineCallbacks
+    def test_trashScheduledFullyInFutureAttendeeTrashedThenOrganizerChanged(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        # A month in the future
+        start = DateTime.getNowUTC()
+        start.setHHMMSS(0, 0, 0)
+        start.offsetMonth(1)
+        end = DateTime.getNowUTC()
+        end.setHHMMSS(1, 0, 0)
+        end.offsetMonth(1)
+        subs = {
+            &quot;start&quot;: start,
+            &quot;end&quot;: end,
+        }
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+
+        start.offsetHours(1)
+        end.offsetHours(1)
+
+        data3 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        data4 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:CHANGED!
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+
+        # user01 invites user02
+        txn = self.store.newTransaction()
+        yield self._createResource(
+            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
+        )
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy has SCHEDULE-STATUS update
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
+
+        # user02 has an inbox item
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user02 accepts
+        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01 has an inbox item
+        txn = self.store.newTransaction()
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # user01's copy has SCHEDULE-STATUS update
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        # user02 trashes event
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's calendar copy shows user02 declined
+        txn = self.store.newTransaction()
+
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+
+        # user01's inbox copy also shows user02 declined
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+
+        # user02's copy is in the trash only, and still has ACCEPTED
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+
+        # result = yield txn.execSQL(&quot;select * from calendar_object&quot;, [])
+        # for row in result:
+        #     print(&quot;calendar object ROW&quot;, row)
+
+        # result = yield txn.execSQL(&quot;select * from calendar_metadata&quot;, [])
+        # for row in result:
+        #     print(&quot;calendar ROW&quot;, row)
+
+
+        yield txn.commit()
+
+        # user01 makes a change to event while user02's copy is in the trash
+        txn = self.store.newTransaction()
+
+        yield self._updateResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data3)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=NEEDS-ACTION&quot; in data)
+
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        # user02 trashes event again
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's calendar copy shows user02 declined
+        txn = self.store.newTransaction()
+
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+
+        # user01's inbox copy also shows user02 declined
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01 makes a SUMMARY change to event while user02's copy is in the trash
+        txn = self.store.newTransaction()
+
+        yield self._updateResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data4)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+
+        txn = self.store.newTransaction()
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        yield txn.commit()
+
+
+    @inlineCallbacks
+    def test_trashScheduledFullyInFutureAttendeeRemovedThenOrganizerChanged(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        # A month in the future
+        start = DateTime.getNowUTC()
+        start.setHHMMSS(0, 0, 0)
+        start.offsetMonth(1)
+        end = DateTime.getNowUTC()
+        end.setHHMMSS(1, 0, 0)
+        end.offsetMonth(1)
+        subs = {
+            &quot;start&quot;: start,
+            &quot;end&quot;: end,
+        }
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+
+        data3 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:CHANGED!
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+
+        start.offsetHours(1)
+        end.offsetHours(1)
+
+        data4 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:CHANGED!
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=DECLINED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+
+        # user01 invites user02
+        txn = self.store.newTransaction()
+        yield self._createResource(
+            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
+        )
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy has SCHEDULE-STATUS update
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
+
+        # user02 has an inbox item
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user02 accepts
+        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01 has an inbox item
+        txn = self.store.newTransaction()
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # user01's copy has SCHEDULE-STATUS update
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        # user02 trashes event
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's calendar copy shows user02 declined
+        txn = self.store.newTransaction()
+
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+
+        # user01's inbox copy also shows user02 declined
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # user02's copy is in the trash only, and still has ACCEPTED
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+        yield txn.commit()
+
+
+        # user02 removes the event completely from the trash
+
+        txn = self.store.newTransaction()
+
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        yield resource.reallyRemove()
+
+        yield txn.commit()
+
+
+        # user01 makes a SUMMARY change to event (user02 does not get notified because they are fully declined)
+        txn = self.store.newTransaction()
+
+        yield self._updateResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data3)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        yield txn.commit()
+
+        # user01 makes a time change to event (user02 gets notified)
+        txn = self.store.newTransaction()
+
+        yield self._updateResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data4)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=NEEDS-ACTION&quot; in data)
+
+        yield txn.commit()
+
+
+
+    @inlineCallbacks
+    def test_trashScheduledFullyInFutureAttendeeTrashedThenPutBack(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        # A month in the future
+        start = DateTime.getNowUTC()
+        start.setHHMMSS(0, 0, 0)
+        start.offsetMonth(1)
+        end = DateTime.getNowUTC()
+        end.setHHMMSS(1, 0, 0)
+        end.offsetMonth(1)
+        subs = {
+            &quot;start&quot;: start,
+            &quot;end&quot;: end,
+        }
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+
+        # user01 invites user02
+        txn = self.store.newTransaction()
+        yield self._createResource(
+            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
+        )
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy has SCHEDULE-STATUS update
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
+
+        # user02 has an inbox item
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user02 accepts
+        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01 has an inbox item
+        txn = self.store.newTransaction()
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # user01's copy has SCHEDULE-STATUS update
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        # user02 trashes event
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's calendar copy shows user02 declined
+        txn = self.store.newTransaction()
+
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+
+        # user01's inbox copy also shows user02 declined
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # result = yield txn.execSQL(&quot;select * from calendar_object&quot;, [])
+        # for row in result:
+        #     print(&quot;ROW&quot;, row)
+
+        # user02's copy is in the trash only, and still has ACCEPTED
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+
+        yield txn.commit()
+
+        # user02 moves it from trash
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        yield resource.fromTrash()
+        yield txn.commit()
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's calendar copy shows user02 accepted
+        txn = self.store.newTransaction()
+
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+
+        # user01's inbox copy also shows user02 accepted
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # user02 has nothing in trash
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+
+        yield txn.commit()
+
+
+
+    @inlineCallbacks
+    def test_trashScheduledFullyInPast(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        # A month in the past
+        start = DateTime.getNowUTC()
+        start.setHHMMSS(0, 0, 0)
+        start.offsetMonth(-1)
+        end = DateTime.getNowUTC()
+        end.setHHMMSS(1, 0, 0)
+        end.offsetMonth(-1)
+        subs = {
+            &quot;start&quot;: start,
+            &quot;end&quot;: end,
+        }
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=TENTATIVE:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        # user01 invites user02
+        txn = self.store.newTransaction()
+        yield self._createResource(
+            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
+        )
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy has SCHEDULE-STATUS update
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
+
+        # user02 has an inbox item
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user02 accepts
+        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01 has an inbox item
+        txn = self.store.newTransaction()
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user01's copy has SCHEDULE-STATUS update
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
+        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        # user01 trashes event
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        yield resource.remove()
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy is in the trash, still with user02 partstat
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
+        yield txn.commit()
+
+        # user02's copy is cancelled
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;METHOD:CANCEL&quot; in data)
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;STATUS:CANCELLED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        yield resource.remove()
+        data = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertEquals(data, None)
+        yield txn.commit()
+
+        # user01 restores event from the trash
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
+        yield resource.fromTrash()
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+
+        # user01's copy should be back on their calendar
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
+
+        # user02's copy should be back on their calendar
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
+
+
+        yield txn.commit()
+
+
+    @inlineCallbacks
+    def test_trashScheduledFullyInPastAttendeeTrashedThenPutBack(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        # A month in the past
+        start = DateTime.getNowUTC()
+        start.setHHMMSS(0, 0, 0)
+        start.offsetMonth(-1)
+        end = DateTime.getNowUTC()
+        end.setHHMMSS(1, 0, 0)
+        end.offsetMonth(-1)
+        subs = {
+            &quot;start&quot;: start,
+            &quot;end&quot;: end,
+        }
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=TENTATIVE:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        # user01 invites user02
+        txn = self.store.newTransaction()
+        yield self._createResource(
+            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
+        )
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy has SCHEDULE-STATUS update
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
+
+        # user02 has an inbox item
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user02 accepts
+        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01 has an inbox item
+        txn = self.store.newTransaction()
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user01's copy has SCHEDULE-STATUS update
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
+        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
+
+        # clear the inbox items
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        # user02 trashes event
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        yield resource.remove()
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's calendar copy shows user02 declined
+        txn = self.store.newTransaction()
+
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+
+        # user01's inbox copy also shows user02 declined
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # user02's copy is in the trash only, and still has TENTATIVE
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
+
+        yield txn.commit()
+
+        # user02 moves it from trash
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        yield resource.fromTrash()
+        yield txn.commit()
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's calendar copy shows user02 tentative again
+        txn = self.store.newTransaction()
+
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
+
+        # user01's inbox copy also shows user02 tentative
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # user02 has nothing in trash
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=TENTATIVE&quot; in data)
+
+        yield txn.commit()
+
+
+
+    @inlineCallbacks
+    def test_trashScheduledSpanningNow(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        # A month in the past
+        start = DateTime.getNowUTC()
+        start.setHHMMSS(0, 0, 0)
+        start.offsetMonth(-1)
+        end = DateTime.getNowUTC()
+        end.setHHMMSS(1, 0, 0)
+        end.offsetMonth(-1)
+        subs = {
+            &quot;start&quot;: start,
+            &quot;end&quot;: end,
+        }
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+RRULE:FREQ=WEEKLY;COUNT=20
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+RRULE:FREQ=WEEKLY;COUNT=20
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        # user01 invites user02
+        txn = self.store.newTransaction()
+        yield self._createResource(
+            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
+        )
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy has SCHEDULE-STATUS update
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
+
+        # user02 has an inbox item
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user02 accepts
+        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01 has an inbox item
+        txn = self.store.newTransaction()
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user01's copy has SCHEDULE-STATUS update
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        # user01 trashes event
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        yield resource.remove()
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy is in the trash, still with user02 accepted
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+        yield txn.commit()
+
+        # user02's copy is cancelled
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;METHOD:CANCEL&quot; in data)
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;STATUS:CANCELLED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        yield resource.remove()
+        data = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertEquals(data, None)
+        yield txn.commit()
+
+        # user01 restores event from the trash
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;trash&quot;, &quot;&quot;)
+        trashedName = yield resource.fromTrash()
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+
+        # user01's trash should be empty
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;trash&quot;)
+        self.assertEquals(len(resourceNames), 0)
+
+        # user01 should have two .ics
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;calendar&quot;)
+        self.assertEquals(len(resourceNames), 2)
+        self.assertTrue(trashedName in resourceNames)
+        resourceNames.remove(trashedName)
+        newName = resourceNames[0]
+
+        # user01's test.ics -- verify it got split correctly, by making sure
+        # it's got a count other than 20 now
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, trashedName)
+        self.assertTrue(&quot;COUNT=&quot; in data)
+        self.assertFalse(&quot;COUNT=20&quot; in data)
+
+        # user01's new .ics -- verify it got split correctly
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, newName)
+        self.assertTrue(&quot;RRULE:FREQ=WEEKLY;UNTIL=&quot; in data)
+
+        # user02's copy should be back on their calendar, and not in trash
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEquals(len(resourceNames), 1)
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEquals(len(resourceNames), 0)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=NEEDS-ACTION&quot; in data)
+
+        yield txn.commit()
+
+
+    @inlineCallbacks
+    def test_trashScheduledSpanningNowAttendeeTrashedThenPutBack(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        # A month in the past
+        start = DateTime.getNowUTC()
+        start.setHHMMSS(0, 0, 0)
+        start.offsetMonth(-1)
+        end = DateTime.getNowUTC()
+        end.setHHMMSS(1, 0, 0)
+        end.offsetMonth(-1)
+        subs = {
+            &quot;start&quot;: start,
+            &quot;end&quot;: end,
+        }
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+RRULE:FREQ=WEEKLY;COUNT=20
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        data2 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+RRULE:FREQ=WEEKLY;COUNT=20
+SUMMARY:Scheduled
+ORGANIZER;CN=&quot;User 01&quot;:mailto:user01@example.com
+ATTENDEE:mailto:user01@example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02@example.com
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot; % subs
+
+        # user01 invites user02
+        txn = self.store.newTransaction()
+        yield self._createResource(
+            txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;, data1
+        )
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy has SCHEDULE-STATUS update
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=1.2&quot; in data)
+
+        # user02 has an inbox item
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user02 accepts
+        yield self._updateResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;, data2)
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01 has an inbox item
+        txn = self.store.newTransaction()
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        # user01's copy has SCHEDULE-STATUS update
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;SCHEDULE-STATUS=2.0&quot; in data)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        yield txn.commit()
+
+        # user02 trashes event
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        yield resource.remove()
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's copy shows user02 declined
+        txn = self.store.newTransaction()
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;PARTSTAT=DECLINED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 1)
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 1)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # user02's copy is in the trash only, and still has ACCEPTED
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+
+        yield txn.commit()
+        # user02 moves it from trash
+        txn = self.store.newTransaction()
+        resource = yield self._getResource(txn, &quot;user02&quot;, &quot;trash&quot;, &quot;&quot;)
+        yield resource.fromTrash()
+        yield txn.commit()
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        # user01's calendar copy shows user02 accepted
+        txn = self.store.newTransaction()
+
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;calendar&quot;, &quot;test.ics&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+
+        # user01's inbox copy also shows user02 accepted
+        data = yield self._getResourceData(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+        resource = yield self._getResource(txn, &quot;user01&quot;, &quot;inbox&quot;, &quot;&quot;)
+        yield resource.remove()
+
+        # user02 has nothing in trash
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;calendar&quot;)
+        self.assertEqual(len(resourceNames), 1)
+
+        resourceNames = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;inbox&quot;)
+        self.assertEqual(len(resourceNames), 0)
+
+        data = yield self._getResourceData(txn, &quot;user02&quot;, &quot;calendar&quot;, &quot;&quot;)
+        self.assertTrue(&quot;PARTSTAT=ACCEPTED&quot; in data)
+
+        yield txn.commit()
+
+
+    @inlineCallbacks
+    def test_trashCalendar(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        txn = self.store.newTransaction()
+
+        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;, create=True)
+        isInTrash = collection.isInTrash()
+        self.assertFalse(isInTrash)
+        whenTrashed = collection.whenTrashed()
+        self.assertEquals(whenTrashed, None)
+
+        home = yield self._homeForUser(txn, &quot;user01&quot;)
+        names = yield home.listChildren()
+        self.assertTrue(&quot;test&quot; in names)
+        names = yield home.listChildren(onlyInTrash=True)
+        self.assertFalse(&quot;test&quot; in names)
+
+        yield collection.remove()
+        isInTrash = collection.isInTrash()
+        self.assertTrue(isInTrash)
+        whenTrashed = collection.whenTrashed()
+        self.assertNotEquals(whenTrashed, None)
+
+        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;)
+        self.assertEquals(collection, None)
+
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+
+        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;)
+        self.assertEquals(collection, None)
+        home = yield self._homeForUser(txn, &quot;user01&quot;)
+        names = yield home.listChildren(onlyInTrash=True)
+        trashedName = names[0]
+        collection = yield self._collectionForUser(txn, &quot;user01&quot;, trashedName, onlyInTrash=True)
+        self.assertNotEquals(collection, None)
+        home = yield self._homeForUser(txn, &quot;user01&quot;)
+        names = yield home.listChildren()
+        self.assertFalse(&quot;test&quot; in names)
+        names = yield home.listChildren(onlyInTrash=True)
+        self.assertTrue(trashedName in names)
+
+        yield collection.fromTrash()
+
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+        home = yield self._homeForUser(txn, &quot;user01&quot;)
+        names = yield home.listChildren()
+        self.assertTrue(trashedName in names)
+        names = yield home.listChildren(onlyInTrash=True)
+        self.assertFalse(&quot;test&quot; in names)
+        yield txn.commit()
+
+
+    @inlineCallbacks
+    def test_trashCalendarWithUnscheduled(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        txn = self.store.newTransaction()
+
+        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;, create=True)
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
+DTSTART;TZID=America/Los_Angeles:20141108T093000
+DTEND;TZID=America/Los_Angeles:20141108T103000
+CREATED:20141106T192546Z
+DTSTAMP:20141106T192546Z
+RRULE:FREQ=DAILY
+SEQUENCE:0
+SUMMARY:repeating event
+TRANSP:OPAQUE
+END:VEVENT
+BEGIN:VEVENT
+UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
+RECURRENCE-ID;TZID=America/Los_Angeles:20141111T093000
+DTSTART;TZID=America/Los_Angeles:20141111T110000
+DTEND;TZID=America/Los_Angeles:20141111T120000
+CREATED:20141106T192546Z
+DTSTAMP:20141106T192546Z
+SEQUENCE:0
+SUMMARY:repeating event
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+        # Create an object
+        resource = yield collection.createObjectResourceWithName(
+            &quot;test.ics&quot;,
+            Component.allFromString(data1)
+        )
+
+        # One object in collection
+        objects = yield collection.listObjectResources()
+        self.assertEquals(len(objects), 1)
+
+        # No objects in trash
+        trash = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;trash&quot;)
+        objects = yield trash.listObjectResources()
+        self.assertEquals(len(objects), 0)
+
+        # Verify it's not in the trash
+        self.assertFalse((yield resource.isInTrash()))
+        trashed = yield resource.whenTrashed()
+        self.assertTrue(trashed is None)
+
+        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;)
+        resources = yield trash.trashForCollection(collection._resourceID)
+        self.assertEquals(len(resources), 0)
+
+        yield txn.commit()
+
+        txn = self.store.newTransaction()
+        collection = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;test&quot;)
+        yield collection.remove()
+        yield txn.commit()
+
+        txn = self.store.newTransaction()
+        # One object in trash
+        trash = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;trash&quot;)
+        objects = yield trash.listObjectResources()
+        self.assertEquals(len(objects), 1)
+
+        resources = yield trash.trashForCollection(collection._resourceID)
+        self.assertEquals(len(resources), 1)
+
+        home = yield self._homeForUser(txn, &quot;user01&quot;)
+        names = yield home.listChildren(onlyInTrash=True)
+        trashedName = names[0]
+        collection = yield self._collectionForUser(txn, &quot;user01&quot;, trashedName, onlyInTrash=True)
+        yield collection.fromTrash()
+
+        yield txn.commit()
+
+        yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+        txn = self.store.newTransaction()
+        home = yield self._homeForUser(txn, &quot;user01&quot;)
+        names = yield home.listChildren()
+        self.assertTrue(trashedName in names)
+        names = yield home.listChildren(onlyInTrash=True)
+        self.assertFalse(trashedName in names)
+        resourceNames = yield self._getResourceNames(txn, &quot;user01&quot;, trashedName)
+        self.assertEqual(len(resourceNames), 1)
+
+        yield txn.commit()
+
+
+
+    @inlineCallbacks
+    def test_shareeDelete(self):
+
+        from twistedcaldav.stdconfig import config
+        self.patch(config, &quot;EnableTrashCollection&quot;, True)
+
+        data1 = &quot;&quot;&quot;BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
+DTSTART;TZID=America/Los_Angeles:20141108T093000
+DTEND;TZID=America/Los_Angeles:20141108T103000
+CREATED:20141106T192546Z
+DTSTAMP:20141106T192546Z
+RRULE:FREQ=DAILY
+SEQUENCE:0
+SUMMARY:repeating event
+TRANSP:OPAQUE
+END:VEVENT
+BEGIN:VEVENT
+UID:5CE3B280-DBC9-4E8E-B0B2-996754020E5F
+RECURRENCE-ID;TZID=America/Los_Angeles:20141111T093000
+DTSTART;TZID=America/Los_Angeles:20141111T110000
+DTEND;TZID=America/Los_Angeles:20141111T120000
+CREATED:20141106T192546Z
+DTSTAMP:20141106T192546Z
+SEQUENCE:0
+SUMMARY:repeating event
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+&quot;&quot;&quot;
+
+        txn = self.store.newTransaction()
+        calendar1 = yield self._collectionForUser(txn, &quot;user01&quot;, &quot;calendar&quot;)
+
+        yield calendar1.createObjectResourceWithName(
+            &quot;test.ics&quot;,
+            Component.allFromString(data1)
+        )
+
+        shareeView = yield calendar1.inviteUIDToShare(&quot;user02&quot;, _BIND_MODE_WRITE, &quot;summary&quot;)
+        inviteUID = shareeView.shareUID()
+        home2 = yield self._homeForUser(txn, &quot;user02&quot;)
+        shareeView = yield home2.acceptShare(inviteUID)
+        calendarName2 = shareeView.name()
+        yield self._collectionForUser(txn, &quot;user02&quot;, calendarName2)
+        yield txn.commit()
+
+        txn = self.store.newTransaction()
+        resource2 = yield self._getResource(txn, &quot;user02&quot;, calendarName2, &quot;test.ics&quot;)
+        yield resource2.remove()
+        yield txn.commit()
+
+        txn = self.store.newTransaction()
+        names = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;trash&quot;)
+        self.assertEquals(len(names), 1)
+        names = yield self._getResourceNames(txn, &quot;user01&quot;, &quot;calendar&quot;)
+        self.assertEquals(len(names), 0)
+        names = yield self._getResourceNames(txn, &quot;user02&quot;, &quot;trash&quot;)
+        self.assertEquals(len(names), 0)
+        names = yield self._getResourceNames(txn, &quot;user02&quot;, calendarName2)
+        self.assertEquals(len(names), 0)
+        yield txn.commit()
</ins></span></pre>
</div>
</div>

</body>
</html>