Convert the Bibliotheca integration into a package#3543
Conversation
|
Claude finished @jonathangreen's task in 4m 59s —— View job Code Review: Convert the Bibliotheca integration into a package
SummaryThis is a clean, faithful move-only refactor, and I found no blocking issues. I independently verified the load-bearing claims rather than taking them on faith:
The Nice cleanup — no changes requested. |
Greptile SummaryThis PR moves the Bibliotheca integration into a package layout. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "Update stale test module cross-reference..." | Re-trigger Greptile |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3543 +/- ##
==========================================
+ Coverage 93.47% 93.48% +0.01%
==========================================
Files 512 516 +4
Lines 46619 46673 +54
Branches 6353 6359 +6
==========================================
+ Hits 43575 43632 +57
+ Misses 1968 1966 -2
+ Partials 1076 1075 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The coverage issues here are preexisting, and the overall coverage doesn't change. So I think this one is ready for a review. I tagged you @dbernstein since you did the recent Bibliotheca refactoring. |
The Bibliotheca integration was five flat bibliotheca_* modules sitting
directly in integration/license/, while every other integration
(overdrive/, boundless/, opds/) is a package. Restructure it to match.
The five modules become bibliotheca/{api,importer,purchase_record_importer,
circulation_updater,scripts}.py, and the 1295-line api.py is split along
the same seams the siblings use: settings.py (as in overdrive and
boundless), parser.py (as in boundless), and coverage.py (as in
overdrive).
Splitting the parsers out exposed a cycle: BibliothecaAPI constructs the
parsers, but ErrorParser, EventParser and PatronCirculationParser reached
back for BibliothecaAPI.SERVICE_NAME and .ARGUMENT_TIME_FORMAT. Add a
constants.py holding those values and point the parsers at it, mirroring
how boundless/parser.py and overdrive/coverage.py already avoid the same
cycle. BibliothecaAPI keeps both class attributes, so nothing that reads
them off the API changes.
Also drop EventParser.EVENT_SOURCE and EventParser.SET_DELIVERY_MECHANISM_AT.
Both were unread: EVENT_SOURCE has no readers anywhere, and the two sites
that read SET_DELIVERY_MECHANISM_AT do so off a BaseCirculationAPI, which
EventParser is not. Removing them lets parser.py stop importing the
circulation API layer entirely. BibliothecaAPI.SET_DELIVERY_MECHANISM_AT
is a different attribute on a different class and is untouched.
Mirror the layout in tests/, moving the fixture into a conftest.py as
boundless does. TestBibliographicCoverageProvider subclassed
TestBibliothecaAPI without using anything from it, which made pytest
re-run all 22 API tests a second time; it no longer does. All 38 declared
tests are preserved, with test_internal_formats moving to
TestItemListParser, the class it actually exercises.
test_bibliotheca_importer.py was renamed to tests/manager/integration/license/bibliotheca/test_importer.py, so point the docstring at the new location. Use the full path rather than the bare module name, since boundless/ and overdrive/ each have a test_importer.py of their own.
9d0a886 to
c2b3695
Compare
Description
Restructures the Bibliotheca integration from five flat
bibliotheca_*modules into abibliotheca/package, matching the layout of every other integration.The 1295-line
bibliotheca.pyis split along the seams the siblings already use:settings.py(as inoverdrive/andboundless/),parser.py(as inboundless/), andcoverage.py(as inoverdrive/).A cycle had to be broken first.
BibliothecaAPIconstructs the parsers, butErrorParser,EventParserandPatronCirculationParserreached back forBibliothecaAPI.SERVICE_NAMEand.ARGUMENT_TIME_FORMAT. The newconstants.pyholds those values and the parsers read them from there — the same wayboundless/parser.pyandoverdrive/coverage.pyalready avoid this.BibliothecaAPIkeeps both class attributes (tests andlicense_providers.pyread them off the class), so no caller changes.Two dead attributes removed.
EventParser.EVENT_SOURCEhas no readers anywhere in the repo.EventParser.SET_DELIVERY_MECHANISM_ATalso has none: the only two read sites (api/circulation/dispatcher.pyandfeed/annotator/circulation.py) access it off aBaseCirculationAPI, andEventParseris anXMLProcessor. Dropping them letsparser.pystop importing the circulation API layer entirely.BibliothecaAPI.SET_DELIVERY_MECHANISM_ATis a separate attribute on a separate class and is unchanged.Tests mirror the new layout, with the shared fixture moved into a
conftest.pyasboundless/does.TestBibliographicCoverageProvidersubclassedTestBibliothecaAPIwhile using nothing from it, so pytest was silently re-running all 22 API tests a second time — that inheritance is gone. All 38 declared tests survive;test_internal_formatsmoves toTestItemListParser, the class it actually exercises.Motivation and Context
src/palace/manager/integration/license/heldbibliotheca_api.py-style flat modules for Bibliotheca whileoverdrive/,boundless/andopds/were all packages. This is a structural cleanup only — no behavior change.How Has This Been Tested?
mypyclean across all 1171 source files.test_loan,test_dispatcher,test_collection,test_monitor,test_configuration,service/, …): 522 passed.SET_DELIVERY_MECHANISM_AT(test_dispatcher.py,test_library_annotator.py) run green after the attribute removal.bin/scripts had their imports statically resolved against the new module paths.Class::methodtest pairs diffs empty apart from the intentionaltest_internal_formatsrelocation.Checklist