Skip to content

test(redis cache): re-enable Test_RedisScheme + not-installed test for redis-py 8.x#721

Closed
wbarnha wants to merge 1 commit into
masterfrom
claude/reenable-redis-cache-tests
Closed

test(redis cache): re-enable Test_RedisScheme + not-installed test for redis-py 8.x#721
wbarnha wants to merge 1 commit into
masterfrom
claude/reenable-redis-cache-tests

Conversation

@wbarnha

@wbarnha wbarnha commented Jul 20, 2026

Copy link
Copy Markdown
Member

Description

Re-enables three redis cache tests skipped "Needs fixing" that had drifted against redis-py 8.x and the current cache backend.

  • Test_RedisScheme::test_single_client / test_cluster_client referenced redis.StrictRedis / aredis.RedisCluster as attributes of the backend module — which no longer exist there. They now assert against the scheme→client-class map the backend actually builds (_client_by_scheme): single-node resolves to redis-py 8.x's concrete redis.client.Redis; cluster resolves to redis.RedisCluster. The single-node client is built for real (redis-py connects lazily) and its connection_pool.connection_kwargs (host/port/db) are checked; the cluster class — which connects on construction — is mocked exactly like the existing mocked_redis fixture, while scheme selection and db-stripping run for real. test_single_client is strictly stronger than the original.
  • test_redis__aredis_is_not_installed now patches the redis module name the backend's on_start guard actually reads (if redis is None), so it raises ImproperlyConfigured without opening a socket (the old fixture patched aredis, which the guard never checks — so it opened a real connection to localhost:6079).

Only external redis client classes are mocked; the backend logic runs for real. Test-only change.

Latent source bug noticed (not fixed here)

The backend does import redis.asyncio as aredis but its on_start guard only checks if redis is None, never aredis. So the "async redis not installed" path is effectively dead / guards the wrong name. Left for a separate source-side PR to keep this change test-only.

Verification

tests/functional/web/test_cache.py32 passed; flake8/black/isort clean. Produced under adversarial faithfulness review.

🤖 Generated with Claude Code


Generated by Claude Code

Both were skipped "Needs fixing" and had drifted against redis-py 8.x and the
current cache backend:

* Test_RedisScheme referenced `redis.StrictRedis`/`aredis.RedisCluster` as the
  backend module's client types, which no longer exist there.  Assert instead
  against the scheme->client-class map the backend actually builds
  (`_client_by_scheme`): single-node resolves to redis-py 8.x's concrete
  `redis.client.Redis`; cluster resolves to `redis.RedisCluster`.  The
  single-node client is built for real (redis-py connects lazily) and its
  `connection_pool.connection_kwargs` are checked; the cluster class -- which
  would connect on construction -- is mocked like the existing `mocked_redis`
  fixture, while scheme selection and db-stripping run for real.
* test_redis__aredis_is_not_installed now patches the `redis` module name the
  backend's on_start guard actually reads (`if redis is None`), so it raises
  ImproperlyConfigured without opening a socket.

Only external redis client classes are mocked; the backend logic runs for real.

NB: the backend imports `redis.asyncio as aredis` but never guards on it -- a
possible latent bug left for a separate source-side change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HHPL4VFWQRQPpjR1gXSKyL
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.19%. Comparing base (0a92897) to head (23a912f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #721      +/-   ##
==========================================
+ Coverage   94.15%   94.19%   +0.04%     
==========================================
  Files         104      104              
  Lines       11136    11136              
  Branches     1201     1201              
==========================================
+ Hits        10485    10490       +5     
+ Misses        550      547       -3     
+ Partials      101       99       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

wbarnha commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

Closing in favour of #724, which now contains this test rewrite plus the backend not-installed-guard source fix, as a single independent PR off master. No content is lost — it all lives in #724.


Generated by Claude Code

@wbarnha wbarnha closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant