Add cats to the pet pool with a corrected multi-species search#143
Merged
Conversation
Smoss
force-pushed
the
smoss/multi-species-vendored-client
branch
from
July 8, 2026 00:14
82c547a to
31083d6
Compare
binamkayastha
previously approved these changes
Jul 8, 2026
binamkayastha
left a comment
Collaborator
There was a problem hiding this comment.
LGTM - we can merge after we try testing this out for a week on the test bluesky accounts
Reimplements #124 (closes #115). #124 was reverted (#132) because its request body -- species.plural filters plus filterRadius -- was rejected by the live API, silently returning zero results. The body now uses the documented search shape: species.singular filters OR'd via filterProcessing, plus geodistance, in a single call against the available/haspic view. - rescue_groups.py: register one SourceRescueGroups over PET_SPECIES ("dogs", "cats"); parse each animal's species from the included species relationship; filter the "more cats soon!" placeholder. - config.py: PET_SPECIES and RESCUEGROUPS_LIMIT (50, matching two per-species calls at 25 each). - main.py: module-level imports; debug mode returns dog + cat manual sources backed by the new sample_cats.json fixture. - tests: request-shape assertions (filters, filterProcessing, geodistance, no filterRadius), species parsing from included data, and RealCaptureParsingTests, which parses the real API capture in tests/fixtures/sample_data.json end-to-end. - tests/test_rescue_groups_live.py: hits the real API when CUTEPETSBOSTON_RESCUEGROUPS_API_KEY is set -- the only check that can catch a request body the live API rejects, which is how #124 slipped through. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reintroduces the functionality to include cats in the pet pool, correcting the request body to align with the live API's requirements. The new implementation uses singular species filters combined with geodistance in a single API call. - Updated rescue_groups.py to handle both dogs and cats, ensuring proper species parsing. - Adjusted config.py for PET_SPECIES and RESCUEGROUPS_LIMIT settings. - Modified main.py for debug mode to support the new sample_cats.json. - Enhanced tests to validate the new request shape and species parsing, including live API checks. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Smoss
force-pushed
the
smoss/multi-species-vendored-client
branch
from
July 14, 2026 23:40
42ce3b1 to
a8b4862
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #115. Reimplements #124 — which was reverted in #132 after breaking in production — as a single hand-rolled search against the RescueGroups API, based directly on
master(no vendored client; the generated-client approach from #138 was dropped in favor of keeping the codebase's manual HTTP style).Why #124 broke, and why this won't
#124's request body (
species.pluralfilters +filterRadius) was rejected by the live API, which silently returned zero results — unit tests couldn't catch it. This PR uses the documented search-body shape:species.singularfilters OR'd viafilterProcessing, plusgeodistance, in one call against theavailable/haspicview:{"data": {"filters": [ {"fieldName": "species.singular", "operation": "equal", "criteria": "dog"}, {"fieldName": "species.singular", "operation": "equal", "criteria": "cat"}], "filterProcessing": "1 OR 2", "geodistance": {"postalcode": "02108", "miles": 50}}}And because a wrong body fails silently,
tests/test_rescue_groups_live.py(gated onCUTEPETSBOSTON_RESCUEGROUPS_API_KEY) now exists to validate the request shape against the real API — the check that would have caught #124 before merge.Changes
PET_SPECIES = ("dogs", "cats")inconfig.py; oneSourceRescueGroupsfetches both in a single call (RESCUEGROUPS_LIMIT = 50)speciesrelationship; unconfigured species and the"more cats soon!"placeholder are skippedSourceManualdog + cat fixtures (tests/fixtures/sample_cats.json)main.pyimports moved to module levelRealCaptureParsingTestsparses the real API capture (tests/fixtures/sample_data.json) end-to-end as a drift guard; request-shape unit tests assert the exact filters/filterProcessing/geodistancepayload and thatfilterRadiusis goneNo website or poster changes needed — cat posts appear on cutepetsboston.org automatically once posted to Mastodon.
Test plan
pytest tests/— 101 passed, 1 skipped (live test, no key)python -m unittest discover -s tests— 36 passedpython main.py --debugsources --debugposters— fetches 27 records (25 dogs + 2 cats)CUTEPETSBOSTON_RESCUEGROUPS_API_KEY=... pytest tests/test_rescue_groups_live.py— needs someone with the key before merge🤖 Generated with Claude Code