test_appengine.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:REMAP 作者: REMAPApp 项目源码 文件源码
def test_get_and_put_cached(self):
        storage = appengine.StorageByKeyName(
            appengine.CredentialsModel, 'foo', 'credentials', cache=memcache)

        self.assertEqual(None, storage.get())
        self.credentials.set_store(storage)

        http = http_mock.HttpMock(data=BASIC_RESP)
        self.credentials._refresh(http)
        credmodel = appengine.CredentialsModel.get_by_key_name('foo')
        self.assertEqual(BASIC_TOKEN, credmodel.credentials.access_token)

        # Now remove the item from the cache.
        memcache.delete('foo')

        # Check that getting refreshes the cache.
        credentials = storage.get()
        self.assertEqual(BASIC_TOKEN, credentials.access_token)
        self.assertNotEqual(None, memcache.get('foo'))

        # Deleting should clear the cache.
        storage.delete()
        credentials = storage.get()
        self.assertEqual(None, credentials)
        self.assertEqual(None, memcache.get('foo'))

        # Verify mock.
        self._verify_basic_refresh(http)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号