本文整理匯總了Python中WMCore.ACDC.CouchCollection.CouchCollection.drop方法的典型用法代碼示例。如果您正苦於以下問題:Python CouchCollection.drop方法的具體用法?Python CouchCollection.drop怎麽用?Python CouchCollection.drop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WMCore.ACDC.CouchCollection.CouchCollection
的用法示例。
在下文中一共展示了CouchCollection.drop方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testCreatePopulateDrop
# 需要導入模塊: from WMCore.ACDC.CouchCollection import CouchCollection [as 別名]
# 或者: from WMCore.ACDC.CouchCollection.CouchCollection import drop [as 別名]
def testCreatePopulateDrop(self):
"""
_testCreatePopulateDrop_
Test creating, populating and dropping a collection.
"""
testCollectionA = CouchCollection(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "Thunderstruck")
testCollectionB = CouchCollection(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "StruckThunder")
testCollectionA.setOwner(self.owner)
testCollectionB.setOwner(self.owner)
testCollectionA.create()
testCollectionB.create()
# There should be nothing in couch. Documents are only added for
# filesets and files.
testFilesA = []
for i in range(5):
testFile = File(lfn = makeUUID(), size = random.randint(1024, 4096),
events = random.randint(1024, 4096))
testFilesA.append(testFile)
testFilesB = []
for i in range(10):
testFile = File(lfn = makeUUID(), size = random.randint(1024, 4096),
events = random.randint(1024, 4096))
testFilesB.append(testFile)
testFilesetA = CouchFileset(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "TestFilesetA")
testFilesetB = CouchFileset(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "TestFilesetB")
testFilesetC = CouchFileset(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "TestFilesetC")
testCollectionA.addFileset(testFilesetA)
testCollectionB.addFileset(testFilesetB)
testCollectionB.addFileset(testFilesetC)
testFilesetA.add(testFilesA)
testFilesetB.add(testFilesA)
testFilesetC.add(testFilesA)
testFilesetC.add(testFilesB)
# Drop testCollectionA
testCollectionA.drop()
# Try to populate testFilesetA
testCollectionC = CouchCollection(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "ThunderStruck")
testCollectionC.setOwner(self.owner)
testCollectionC.populate()
self.assertEqual(len(testCollectionC["filesets"]), 0,
"Error: There should be no filesets in this collect.")
# Try to populate testFilesetB
testCollectionD = CouchCollection(database = self.testInit.couchDbName,
url = self.testInit.couchUrl,
name = "StruckThunder")
testCollectionD.setOwner(self.owner)
testCollectionD.populate()
for fileset in testCollectionD["filesets"]:
testFiles = testFilesA
if fileset["name"] == "TestFilesetC":
testFiles.extend(testFilesB)
self.assertEqual(len(testFiles), len(fileset.files.keys()),
"Error: Wrong number of files in fileset.")
for testFile in testFiles:
self.assertTrue(testFile["lfn"] in fileset.files.keys(),
"Error: File is missing.")
self.assertEqual(testFile["events"],
fileset.files[testFile["lfn"]]["events"],
"Error: Wrong number of events.")
self.assertEqual(testFile["size"],
fileset.files[testFile["lfn"]]["size"],
"Error: Wrong file size.")
return