本文整理汇总了Python中calendarserver.tools.purge.PurgePrincipalService类的典型用法代码示例。如果您正苦于以下问题:Python PurgePrincipalService类的具体用法?Python PurgePrincipalService怎么用?Python PurgePrincipalService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PurgePrincipalService类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_purgeUIDs
def test_purgeUIDs(self):
"""
Verify purgeUIDs removes homes, and doesn't provision homes that don't exist
"""
# Now you see it
txn = self._sqlCalendarStore.newTransaction()
home = (yield txn.calendarHomeWithUID(self.uid))
self.assertNotEquals(home, None)
(yield txn.commit())
count, ignored = (yield PurgePrincipalService.purgeUIDs(self.storeUnderTest(), self.directory,
self.rootResource, (self.uid,), verbose=False, proxies=False, completely=True))
self.assertEquals(count, 1) # 1 event
# Now you don't
txn = self._sqlCalendarStore.newTransaction()
home = (yield txn.calendarHomeWithUID(self.uid))
self.assertEquals(home, None)
# Verify calendar1 was unshared to uid2
home2 = (yield txn.calendarHomeWithUID(self.uid2))
self.assertEquals((yield home2.childWithName(self.sharedName)), None)
(yield txn.commit())
count, ignored = (yield PurgePrincipalService.purgeUIDs(self.storeUnderTest(), self.directory,
self.rootResource, (self.uid,), verbose=False, proxies=False, completely=True))
self.assertEquals(count, 0)
# And you still don't (making sure it's not provisioned)
txn = self._sqlCalendarStore.newTransaction()
home = (yield txn.calendarHomeWithUID(self.uid))
self.assertEquals(home, None)
(yield txn.commit())
示例2: test_purgeUIDsNotCompletely
def test_purgeUIDsNotCompletely(self):
"""
Verify purgeUIDs removes some events, but leaves others and the home behind
"""
self.patch(config, "EnablePrivateEvents", True)
# Now you see it
txn = self._sqlCalendarStore.newTransaction()
home = (yield txn.calendarHomeWithUID(self.uid))
self.assertNotEquals(home, None)
(yield txn.commit())
count, ignored = (yield PurgePrincipalService.purgeUIDs(self.storeUnderTest(), self.directory,
self.rootResource, (self.uid,), verbose=False, proxies=False, completely=False))
self.assertEquals(count, 1) # 2 events
# Now you still see it
txn = self._sqlCalendarStore.newTransaction()
home = (yield txn.calendarHomeWithUID(self.uid))
self.assertNotEquals(home, None)
# Verify calendar1 was unshared to uid2
home2 = (yield txn.calendarHomeWithUID(self.uid2))
self.assertEquals((yield home2.childWithName(self.sharedName)), None)
(yield txn.commit())
count, ignored = (yield PurgePrincipalService.purgeUIDs(self.storeUnderTest(), self.directory,
self.rootResource, (self.uid,), verbose=False, proxies=False, completely=False))
self.assertEquals(count, 1)
# And you still do
txn = self._sqlCalendarStore.newTransaction()
home = (yield txn.calendarHomeWithUID(self.uid))
self.assertNotEquals(home, None)
(yield txn.commit())
示例3: test_purgeUIDs
def test_purgeUIDs(self):
"""
Verify purgeUIDs removes homes, and doesn't provision homes that don't exist
"""
# Now you see it
home = yield self.homeUnderTest(name=self.uid)
self.assertNotEquals(home, None)
calobj2 = yield self.calendarObjectUnderTest(name="attendee.ics", calendar_name="calendar2", home=self.uid2)
comp = yield calobj2.componentForUser()
self.assertTrue("STATUS:CANCELLED" not in str(comp))
self.assertTrue(";UNTIL=" not in str(comp))
yield self.commit()
count = (yield PurgePrincipalService.purgeUIDs(
self.storeUnderTest(), self.directory,
(self.uid,), verbose=False, proxies=False))
self.assertEquals(count, 2) # 2 events
# Wait for queue to process
while(True):
txn = self.transactionUnderTest()
work = yield PrincipalPurgeHomeWork.all(txn)
yield self.commit()
if len(work) == 0:
break
d = Deferred()
reactor.callLater(1, lambda : d.callback(None))
yield d
# Now you don't
home = yield self.homeUnderTest(name=self.uid)
self.assertEquals(home, None)
# Verify calendar1 was unshared to uid2
home2 = yield self.homeUnderTest(name=self.uid2)
self.assertEquals((yield home2.childWithName(self.sharedName)), None)
yield self.commit()
count = yield PurgePrincipalService.purgeUIDs(
self.storeUnderTest(),
self.directory,
(self.uid,),
verbose=False,
proxies=False,
)
self.assertEquals(count, 0)
# And you still don't (making sure it's not provisioned)
home = yield self.homeUnderTest(name=self.uid)
self.assertEquals(home, None)
yield self.commit()
calobj2 = yield self.calendarObjectUnderTest(name="attendee.ics", calendar_name="calendar2", home=self.uid2)
comp = yield calobj2.componentForUser()
self.assertTrue("STATUS:CANCELLED" in str(comp))
self.assertTrue(";UNTIL=" not in str(comp))
yield self.commit()
示例4: test_purgeUIDCompletely
def test_purgeUIDCompletely(self):
txn = self._sqlCalendarStore.newTransaction()
# Create an addressbook and one CardDAV resource
abHome = (yield txn.addressbookHomeWithUID("home1", create=True))
abColl = (yield abHome.addressbookWithName("addressbook"))
(yield abColl.createAddressBookObjectWithName("card1",
VCardComponent.fromString(VCARD_1)))
self.assertEquals(len((yield abColl.addressbookObjects())), 1)
# Verify there are 8 events in calendar1
calHome = (yield txn.calendarHomeWithUID("home1"))
calColl = (yield calHome.calendarWithName("calendar1"))
self.assertEquals(len((yield calColl.calendarObjects())), 8)
# Make the newly created objects available to the purgeUID transaction
(yield txn.commit())
# Purge home1 completely
total, ignored = (yield PurgePrincipalService.purgeUIDs(self._sqlCalendarStore, self.directory,
self.rootResource, ("home1",), verbose=False, proxies=False, completely=True))
# 9 items deleted: 8 events and 1 vcard
self.assertEquals(total, 9)
# Homes have been deleted as well
txn = self._sqlCalendarStore.newTransaction()
abHome = (yield txn.addressbookHomeWithUID("home1"))
self.assertEquals(abHome, None)
calHome = (yield txn.calendarHomeWithUID("home1"))
self.assertEquals(calHome, None)
示例5: test_purgeUID
def test_purgeUID(self):
txn = self._sqlCalendarStore.newTransaction()
# Create an addressbook and one CardDAV resource
abHome = (yield txn.addressbookHomeWithUID("home1", create=True))
abColl = (yield abHome.addressbookWithName("addressbook"))
(yield abColl.createAddressBookObjectWithName("card1",
VCardComponent.fromString(VCARD_1)))
self.assertEquals(len((yield abColl.addressbookObjects())), 1)
# Verify there are 8 events in calendar1
calHome = (yield txn.calendarHomeWithUID("home1"))
calColl = (yield calHome.calendarWithName("calendar1"))
self.assertEquals(len((yield calColl.calendarObjects())), 8)
# Make the newly created objects available to the purgeUID transaction
(yield txn.commit())
# Purge home1
total, ignored = (yield PurgePrincipalService.purgeUIDs(self._sqlCalendarStore, self.directory,
self.rootResource, ("home1",), verbose=False, proxies=False,
when=PyCalendarDateTime(now, 4, 1, 12, 0, 0, 0, PyCalendarTimezone(utc=True))))
# 4 items deleted: 3 events and 1 vcard
self.assertEquals(total, 4)
txn = self._sqlCalendarStore.newTransaction()
# adressbook home is deleted since it's now empty
abHome = (yield txn.addressbookHomeWithUID("home1"))
self.assertEquals(abHome, None)
calHome = (yield txn.calendarHomeWithUID("home1"))
calColl = (yield calHome.calendarWithName("calendar1"))
self.assertEquals(len((yield calColl.calendarObjects())), 5)
示例6: test_cancelAsAttendeeMultipleOccurrences
def test_cancelAsAttendeeMultipleOccurrences(self):
# Multiple meeting occurrences with no master, where purged CUA is
# an attendee
event = Component.fromString(INVITED_TO_MULTIPLE_OCCURRENCES_ICS)
action = PurgePrincipalService._cancelEvent(event, PyCalendarDateTime(2010, 12, 6, 12, 0, 0, PyCalendarTimezone(utc=True)),
"urn:uuid:9DC04A71-E6DD-11DF-9492-0800200C9A66")
self.assertEquals(action, PurgePrincipalService.CANCELEVENT_SHOULD_DELETE)
示例7: test_cancelAllDayRepeating
def test_cancelAllDayRepeating(self):
# A repeating All Day event where purged CUA is organizer
event = Component.fromString(REPEATING_2_ICS_BEFORE)
action = PurgePrincipalService._cancelEvent(event, PyCalendarDateTime(2010, 12, 6, 12, 0, 0, PyCalendarTimezone(utc=True)),
"urn:uuid:0F168477-CF3D-45D3-AE60-9875EA02C4D1")
self.assertEquals(action, PurgePrincipalService.CANCELEVENT_MODIFIED)
self.assertEquals(str(event), REPEATING_2_ICS_AFTER)
示例8: test_purgeUID
def test_purgeUID(self):
txn = self._sqlCalendarStore.newTransaction()
# Create an addressbook and one CardDAV resource
abHome = (yield txn.addressbookHomeWithUID("home1", create=True))
abColl = (yield abHome.addressbookWithName("addressbook"))
(yield abColl.createAddressBookObjectWithName(
"card1",
VCardComponent.fromString(VCARD_1)))
self.assertEquals(len((yield abColl.addressbookObjects())), 1)
# Verify there are 8 events in calendar1
calHome = (yield txn.calendarHomeWithUID("home1"))
calColl = (yield calHome.calendarWithName("calendar1"))
self.assertEquals(len((yield calColl.calendarObjects())), 8)
# Make the newly created objects available to the purgeUID transaction
(yield txn.commit())
# Purge home1 completely
total = yield PurgePrincipalService.purgeUIDs(
self._sqlCalendarStore, self.directory,
("home1",), verbose=False, proxies=False)
# Wait for queue to process
while(True):
txn = self.transactionUnderTest()
work = yield PrincipalPurgeHomeWork.all(txn)
yield self.commit()
if len(work) == 0:
break
d = Deferred()
reactor.callLater(1, lambda : d.callback(None))
yield d
# 9 items deleted: 8 events and 1 vcard
self.assertEquals(total, 9)
# Homes have been deleted as well
txn = self._sqlCalendarStore.newTransaction()
abHome = (yield txn.addressbookHomeWithUID("home1"))
self.assertEquals(abHome, None)
calHome = (yield txn.calendarHomeWithUID("home1"))
self.assertEquals(calHome, None)
示例9: test_purgeWithMissingOrganizer
def test_purgeWithMissingOrganizer(self):
"""
Verify purgeUID sends cancels even when organizer is not in the directory
"""
# Now you see it
home2 = yield self.homeUnderTest(name=self.uid2)
self.assertNotEquals(home2, None)
home3 = yield self.homeUnderTest(name=self.uid3)
self.assertNotEquals(home3, None)
calobj2 = yield self.calendarObjectUnderTest(name="missing.ics", calendar_name="calendar2", home=self.uid2)
comp = yield calobj2.componentForUser()
self.assertTrue("STATUS:CANCELLED" not in str(comp))
yield self.commit()
count, ignored = (yield PurgePrincipalService.purgeUIDs(self.storeUnderTest(), self.directory,
self.rootResource, (self.uid3,), verbose=False, proxies=False, completely=True))
self.assertEquals(count, 1) # 1 events
calobj2 = yield self.calendarObjectUnderTest(name="missing.ics", calendar_name="calendar2", home=self.uid2)
comp = yield calobj2.componentForUser()
self.assertTrue("STATUS:CANCELLED" in str(comp))
示例10: test_cancelAsAttendee
def test_cancelAsAttendee(self):
# A repeating meeting event where purged CUA is an attendee
event = Component.fromString(REPEATING_ATTENDEE_MEETING_ICS)
action = PurgePrincipalService._cancelEvent(event, PyCalendarDateTime(2010, 12, 6, 12, 0, 0, PyCalendarTimezone(utc=True)),
"urn:uuid:0F168477-CF3D-45D3-AE60-9875EA02C4D1")
self.assertEquals(action, PurgePrincipalService.CANCELEVENT_SHOULD_DELETE)
示例11: test_cancelFutureEvent
def test_cancelFutureEvent(self):
# A future event
event = Component.fromString(FUTURE_EVENT_ICS)
action = PurgePrincipalService._cancelEvent(event, PyCalendarDateTime(2010, 12, 6, 12, 0, 0, PyCalendarTimezone(utc=True)),
"urn:uuid:0F168477-CF3D-45D3-AE60-9875EA02C4D1")
self.assertEquals(action, PurgePrincipalService.CANCELEVENT_SHOULD_DELETE)
示例12: test_cancelNonMeeting
def test_cancelNonMeeting(self):
# A repeating non-meeting event
event = Component.fromString(REPEATING_NON_MEETING_ICS)
action = PurgePrincipalService._cancelEvent(event, DateTime(2010, 12, 6, 12, 0, 0, Timezone(utc=True)),
"urn:uuid:0F168477-CF3D-45D3-AE60-9875EA02C4D1")
self.assertEquals(action, PurgePrincipalService.CANCELEVENT_SHOULD_DELETE)