def testBaseModelMemcacheWrappedGetWhenCachedBadSerializationUnexpected(self):
    key_name = 'foo_key_name'
    memcache_key = 'mwg_%s_%s' % (models.BaseModel.kind(), key_name)

    self.mox.StubOutWithMock(models, 'memcache', True)
    self.mox.StubOutWithMock(models.BaseModel, 'get_by_key_name', True)
    self.mox.StubOutWithMock(models.db, 'model_from_protobuf', True)

    models.memcache.get(memcache_key).AndReturn('serialized')
    models.db.model_from_protobuf('serialized').AndRaise(Exception)
    models.memcache.delete(memcache_key).AndReturn(None)
    models.BaseModel.get_by_key_name(key_name).AndReturn(None)

    self.mox.ReplayAll()
    self.assertEqual(
        None, models.BaseModel.MemcacheWrappedGet(key_name, retry=True))
    self.mox.VerifyAll()
Test BaseModel.MemcacheWrappedGet() when cached.
dataset/ETHPy150Open google/simian/src/tests/simian/mac/models/base_test.py/ModelsModuleTest.testBaseModelMemcacheWrappedGetWhenCachedBadSerializationUnexpected