Remove MockOverdriveAPI in favor of fixture-seeded token caches (PP-4938) - #3678
Conversation
|
Claude finished @jonathangreen's task in 2m 46s —— View job Code review
SummaryThis is a clean, behavior-preserving refactor: One small note on the PR description rather than the code: it says the patched symbol must stay a class because it is passed to DetailsNit:
|
Greptile SummaryThe PR removes the test-only
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| tests/fixtures/overdrive.py | Replaces the mock subclass factory with real OverdriveAPI construction and equivalent fixture-owned token-cache seeding. |
| tests/manager/celery/tasks/test_overdrive.py | Introduces a local seeded subclass that preserves the class-based importer patch and constructor contract. |
| src/palace/manager/integration/license/overdrive/api.py | Removes three obsolete docstrings without changing production behavior. |
| tests/mocks/overdrive.py | Deletes the redundant test subclass after migrating its cache-seeding responsibility to the fixture. |
Reviews (4): Last reviewed commit: "Update tests/fixtures/overdrive.py" | Re-trigger Greptile
MockOverdriveAPI only pre-seeded the client OAuth and collection token caches on construction. Move that seeding into OverdriveAPIFixture as seed_token_caches/create_api so tests use the real OverdriveAPI class, and drop the tests/mocks module. The one celery test that patches the importer's OverdriveAPI reference gets a local SeededOverdriveAPI subclass, since the patched symbol is also passed to registry.equivalent() and therefore has to remain a class.
_do_get, _do_post and _do_patron_request each carried a docstring saying the method was overridden in MockOverdriveAPI. That class is gone, and it never overrode them in any case. HTTP is mocked at HTTP.request_with_timeout by MockHttpClientFixture.
897b4c9 to
8b92bef
Compare
tdilauro
left a comment
There was a problem hiding this comment.
Looks great! 🔥 🚀
One minor suggestion below for clarity.
Co-authored-by: Tim DiLauro <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3678 +/- ##
=======================================
Coverage 93.55% 93.55%
=======================================
Files 513 513
Lines 46907 46907
Branches 6405 6405
=======================================
+ Hits 43884 43885 +1
+ Misses 1954 1953 -1
Partials 1069 1069 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Removes
tests/mocks/overdrive.pyand moves what it did intoOverdriveAPIFixture.MockOverdriveAPIdid not mock any HTTP: it subclassedOverdriveAPIpurely to pre-seed the client OAuth and collection token caches on construction, so tests would not spend queued responses on a token fetch. HTTP itself is mocked atHTTP.request_with_timeoutbyMockHttpClientFixture.That seeding is now
OverdriveAPIFixture.seed_token_caches, withcreate_apibuilding anOverdriveAPIand seeding it.create_mock_apiis renamedcreate_apito match.One test in
tests/manager/celery/tasks/test_overdrive.pypatches the importer'sOverdriveAPIreference with the class itself, and the patched symbol is passed toregistry.equivalent(), so it has to remain a class rather than a fixture instance. That test gets a small localSeededOverdriveAPIsubclass.Motivation and Context
tests/mocksis being phased out per the project conventions, and this was one of the remaining users. Tests now exercise the realOverdriveAPIclass rather than a subclass that only exists in the test tree.This is the second of a series of PRs separating the Overdrive integration's HTTP concerns from its business logic (PP-4938). The only production change is dropping three docstrings on
_do_get,_do_postand_do_patron_requestthat said the method was overridden inMockOverdriveAPI— they were already inaccurate, and now point at a class that no longer exists. No behavior changes.How Has This Been Tested?
No behavior changed, so the existing tests are the check. Ran the Overdrive suite and everything else that touched the removed module:
263 passed.
mypyclean.Checklist