コード例 #1
0
  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()
コード例 #2
0
  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()
コード例 #3
0
 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)
コード例 #4
0
 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)
コード例 #5
0
 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)