def testBlobStoreRaisesForMissingConfig(self): with test_lib.ConfigOverrider( {"DualBlobStore.primary_implementation": "InMemoryDBBlobsMixin"}): with self.assertRaises(ValueError): dual_blob_store.DualBlobStore() with test_lib.ConfigOverrider( {"DualBlobStore.secondary_implementation": "InMemoryDBBlobsMixin"}): with self.assertRaises(ValueError): dual_blob_store.DualBlobStore()
def testBlobStoreRaisesForInvalidConfig(self): with test_lib.ConfigOverrider({ "DualBlobStore.primary_implementation": "InMemoryBlobStore", "DualBlobStore.secondary_implementation": "invalid" }): with self.assertRaises(ValueError): dual_blob_store.DualBlobStore() with test_lib.ConfigOverrider({ "DualBlobStore.primary_implementation": "invalid", "DualBlobStore.secondary_implementation": "InMemoryBlobStore" }): with self.assertRaises(ValueError): dual_blob_store.DualBlobStore()
def CreateBlobStore(self): with mock.patch.object( blob_store, "REGISTRY", { "PrimaryBlobStore": PrimaryBlobStore, "SecondaryBlobStore": SecondaryBlobStore }): bs = dual_blob_store.DualBlobStore("PrimaryBlobStore", "SecondaryBlobStore") return bs, lambda: _StopBackgroundThreads(bs)
def testBlobStoreLoadsClassNamesFromConfig(self): with mock.patch.object( blob_store, "REGISTRY", { "PrimaryBlobStore": PrimaryBlobStore, "SecondaryBlobStore": SecondaryBlobStore }): with test_lib.ConfigOverrider({ "DualBlobStore.primary_implementation": "PrimaryBlobStore", "DualBlobStore.secondary_implementation": "SecondaryBlobStore" }): bs = dual_blob_store.DualBlobStore() self.assertIsInstance(bs._primary, PrimaryBlobStore) self.assertIsInstance(bs._secondary, SecondaryBlobStore) _StopBackgroundThreads(bs)
def CreateBlobStore(self): backing_store_name = compatibility.GetName(mem_blobs.InMemoryBlobStore) bs = dual_blob_store.DualBlobStore(backing_store_name, backing_store_name) return bs, lambda: _StopBackgroundThread(bs)