testing with betamax?
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 30/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python
- 領域
- networking
調査の方向性
Start with CacheControlAdapter.send(), the existing cachecontrol test suite, and Betamax's old_adapters handling. Define tests for cache hits and misses when CacheControl is combined with Betamax, with completion shown by requests being served from the cache when present and delegated without unintended network access otherwise.
索引モデルが issue の本文から書いたものです。
説明
is there a way to test this module alongside betamax?
the idea would be that the cachecontrol module would hit its own cache if present, otherwise bounce back into betamax. I am already using betamax extensively in my project to "mock" HTTP requests (record and replay, really) and it's been quite useful. But when I pair it with cachecontrol, I don't get good results.
either:
- i add cachecontrol as an "old_adapter" in the betamax session, which works in the sense that requests never hit the network, but then they never hit the cachecontrol adapter either, because the query gets cached in betamax. even if they would hit cachecontrol, they would need to hit the network first
- I mount cachecontrol on top of a betamax session, in which case cachecontrol completely obliterates the betamax adapter and sends requests on the network (instead of tapping in betamax)
Those two possible scenarios are pretty much covered in this ifcase:
cache_adapter = cachecontrol.CacheControlAdapter(cache=FeedContentCacheStorage(self.db_path))
# assume we mount over http and https all at once so check
# only the latter
adapter = self._session.adapters.get('https://', None)
if hasattr(adapter, 'old_adapters'):
# looks like a betamax session was setup, hook ourselves behind it
logging.debug('appending cache adapter (%r) to existing betamax adapter (%r)', cache_adapter, adapter)
adapter.old_adapters['http://'] = cache_adapter
adapter.old_adapters['https://'] = cache_adapter
else:
logging.debug('mounting cache adapter (%r)', cache_adapter)
# override existing adapters to use the cache adapter instead
self._session.mount('http://', cache_adapter)
self._session.mount('https://', cache_adapter)
That's pretty much case 1 above, which falls back to case 2 if we don't detect a "betamax" adapter in place.
And of course, it doesn't work.
What I would need is something like betamax's "old_adapters" system. Instead of calling the parent class, CacheControlAdapter.send() should allow the caller to define a list of adapters to call instead. The way betamax does this is fairly simple: there's an old_adapters parameter that you can pass and that it uses for sending its requests..
I have looked into the cachecontrol test suite to figure out if there could be inspiration there, but it seems to "mock" an http adapter instead of delegating requests... Since I don't want to reimplement the entire thing myself (and I can't figure out how to hook betamax in there either), could we add a similar functionality here?
Thanks!
PS: it seems I can mock a parent class but that seems horribly dirty - I am not sure I want to go that far...
- 主要言語
- Python
- スター
- 505
- フォーク
- 153
- 平均マージ
- 5日 6時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
psf/cachecontrol のほかの issue
-
Cache Deserialization (part two) -- warning message incorrect?再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
psf/cachecontrol#209 · コメント 5 件 ·
-
Race condition in send()対応中かも @JulienPalard が 148 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
psf/cachecontrol#424 · コメント 1 件 ·
-
HTTP 302 Found responses with Cache Headers not being cached対応中かも @cburroughs が 280 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
psf/cachecontrol#384 · コメント 18 件 ·
-
Head request is not cached even with cacheable_methods=("GET", HEAD") without a previous GET再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
psf/cachecontrol#337 · コメント 6 件 ·
-
Investigate failure to load caches above `2^32 - 1` bytes再び着手できるかも @woodruffw が 853 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
psf/cachecontrol#336 · コメント 4 件 · リアクション 1 件 · 担当者 1 名 ·
psf/cachecontrol の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Deltares/imod-python#1940 ·
メンテナーはふだん 1 日以内に返信
-
effort: low prio: low ready
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
digitalfabrik/integreat-cms#4621 ·
メンテナーはふだん 5 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
ioos/compliance-checker#1375 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
netbox status: backlog topic: testing type: housekeeping
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
netbox-community/netbox#23395 ·
メンテナーはふだん 1 日以内に返信