testing with betamax?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- networking
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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...
- Lingua principale
- Python
- Stelle
- 505
- Fork
- 153
- Merge medio
- 5g 6h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di psf/cachecontrol
-
Cache Deserialization (part two) -- warning message incorrect?Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
psf/cachecontrol#209 · 5 commenti ·
-
Race condition in send()Forse già presa @JulienPalard l’ha presa 148 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
psf/cachecontrol#424 · 1 commento ·
-
HTTP 302 Found responses with Cache Headers not being cachedForse già presa @cburroughs l’ha presa 280 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
psf/cachecontrol#384 · 18 commenti ·
-
Head request is not cached even with cacheable_methods=("GET", HEAD") without a previous GETForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
psf/cachecontrol#337 · 6 commenti ·
-
Investigate failure to load caches above `2^32 - 1` bytesForse di nuovo libera @woodruffw l’ha presa 853 giorni fa e non c’è nessuna pull request aperta. Aperta
psf/cachecontrol#336 · 4 commenti · 1 reazione · 1 assegnatario ·
Tutte le issue di psf/cachecontrol
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
onyx-dot-app/onyx#16016 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
black --check exits 0 and prints All done when a multi file run is interruptedForse già presa @jiteshgulati l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
Non-positive worker counts wait for results without starting workersForse già presa @IlyaKhalafi l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno