本文整理汇总了Python中calendarserver.tools.purge.PurgePrincipalService.purgeUIDs方法的典型用法代码示例。如果您正苦于以下问题:Python PurgePrincipalService.purgeUIDs方法的具体用法?Python PurgePrincipalService.purgeUIDs怎么用?Python PurgePrincipalService.purgeUIDs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calendarserver.tools.purge.PurgePrincipalService
的用法示例。
在下文中一共展示了PurgePrincipalService.purgeUIDs方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_purgeUIDs
# 需要导入模块: from calendarserver.tools.purge import PurgePrincipalService [as 别名]
# 或者: from calendarserver.tools.purge.PurgePrincipalService import purgeUIDs [as 别名]
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
# 需要导入模块: from calendarserver.tools.purge import PurgePrincipalService [as 别名]
# 或者: from calendarserver.tools.purge.PurgePrincipalService import purgeUIDs [as 别名]
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
# 需要导入模块: from calendarserver.tools.purge import PurgePrincipalService [as 别名]
# 或者: from calendarserver.tools.purge.PurgePrincipalService import purgeUIDs [as 别名]
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
# 需要导入模块: from calendarserver.tools.purge import PurgePrincipalService [as 别名]
# 或者: from calendarserver.tools.purge.PurgePrincipalService import purgeUIDs [as 别名]
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
# 需要导入模块: from calendarserver.tools.purge import PurgePrincipalService [as 别名]
# 或者: from calendarserver.tools.purge.PurgePrincipalService import purgeUIDs [as 别名]
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_purgeUID
# 需要导入模块: from calendarserver.tools.purge import PurgePrincipalService [as 别名]
# 或者: from calendarserver.tools.purge.PurgePrincipalService import purgeUIDs [as 别名]
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)
示例7: test_purgeWithMissingOrganizer
# 需要导入模块: from calendarserver.tools.purge import PurgePrincipalService [as 别名]
# 或者: from calendarserver.tools.purge.PurgePrincipalService import purgeUIDs [as 别名]
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))