feat(app-business-reviews): upgrade SDK to 2.0.0, add pytest unit tests#285
Conversation
🔍 Integration Validation ResultsCommit: Changed directories:
✅ Structure Check output✅ Code Check output✅ Tests Check output✅ README Check output✅ Version Check output |
TheRealAgentK
left a comment
There was a problem hiding this comment.
SDK 2.0.0 migration looks clean and the 40 unit tests cover the 6 actions across App Store, Google Play, and Google Maps. Local CI verified: validate_integration ✅, check_code ✅, ruff ✅, pytest ✅.
Blocking on one thing: no tests/test_app_business_reviews_integration.py. This integration uses custom API-key auth across three providers, so adding e2e coverage is straightforward — env vars per provider key and the live_context fixture per the writing-integration-tests skill. Please add at minimum a read-only happy-path test per provider before merge.
Also: branch name doesn't follow <type>/<issue#>/<desc> per AGENTS.md, and no linked issue.
- Pin autohive-integrations-sdk~=2.0.0 in requirements.txt - Add .data to all context.fetch() return accesses - Convert raise ValueError to return ActionError(message=...) - Return ActionResult(data=..., cost_usd=0.0) from all action handlers - Bump config.json version to 2.0.0 - Add tests/conftest.py and 40-test unit suite covering all 6 actions
… and integration tests
- Fix api_key default from {} to "" in all action handlers
- Delete old manual asyncio test file
- Add test_app_business_reviews_integration.py with pytest.mark.integration, APP_BUSINESS_REVIEWS_API_KEY env var
- Add APP_BUSINESS_REVIEWS_API_KEY to .env.example
56288d2 to
ea19ffb
Compare
|
@TheRealAgentK unit and live integration tests are done and all passing. Here are the results: Unit tests: 40/40 passed covering all 6 actions with happy path, error handling, param validation, and response shape tests. Live integration tests: 12/12 passed against the real SerpApi, covering all 6 actions:
All read-only, nothing destructive. PR description updated with full results. |
There was a problem hiding this comment.
1. mock_context.auth shape doesn't match source — tests/test_app_business_reviews_unit.py:104
ctx.auth = {"api_key": "test_serpapi_key"}Source reads context.auth.get("credentials", {}).get("api_key", "") — so every action receives api_key="" in unit tests. No test asserts on params["api_key"], so the mismatch is silent. Fix:
ctx.auth = {"credentials": {"api_key": "test_serpapi_key"}}2. Stale tests/context.py — delete
Pre-SDK-2.0 testbed shim (still inserts dependencies/ on sys.path). Unused once conftest is fixed.
3. tests/conftest.py is a no-op
sys.path.insert(0, os.path.dirname(__file__)) puts tests/ on path, not the integration root. The actual import wiring is the importlib block duplicated in both test files. Replacement:
# tests/conftest.py
import os, sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))Test files then drop the importlib block and use from app_business_reviews import app_business_reviews. Single-file integration with no actions/ subdir — straightforward.
4. response = None then post-loop if response is not None — app_business_reviews.py:283, 461
Guards the unbound case when max_pages=0. Minor: either initialize app_info = {} / place_info = {} directly, or keep the guard with a comment.
#1 is the real bug. #2–4 also don't match the pattern expected (similar to the issues raised in #284 / #306).
The source code reads context.auth.get("credentials", {}).get("api_key", ""),
but the test fixture set ctx.auth = {"api_key": "..."}. As a result every
action received api_key="" in unit tests. The mismatch was silent because
no test asserted on params["api_key"].
Adds a regression assertion in TestSearchAppsIOS::test_request_params_include_term
that verifies api_key is forwarded from the credentials block, so any future
auth-shape drift will fail the suite immediately.
With tests/conftest.py putting the integration root on sys.path and the workspace conftest.py patching Integration.load to find config.json, test files can now import the integration with a plain 'from app_business_reviews import app_business_reviews'. Removes the importlib.util.spec_from_file_location dance from both test files and the now-unused dependencies/ sys.path entry. Also deletes the legacy tests/context.py shim from the pre-SDK-2.0 testbed. Matches the simpler pattern used in PRs #280, #289, #306, #307.
…' guards Both get_reviews_google_play and get_reviews_google_maps tracked the last response object across the pagination loop just so the post-loop code could call response.data.get(...) for product/place info, with a defensive 'if response is not None' guard for the max_pages=0 case. Capture app_info / place_info inside the loop instead, initialized to an empty dict before the loop. Same behavior, no defensive guard, no loop-leaked variable.
…action Reverts the in-loop assignment introduced in c1455c7. The original code extracted product_info / place_info from the response variable once after the pagination loop, which is the more idiomatic shape (one read, one write). Keeps the sentinel-and-guard pattern that c1455c7 was meant to clean up, but adds a comment explaining why the guard is there (max_pages=0 edge case where the loop never executes).
TheRealAgentK
left a comment
There was a problem hiding this comment.
Self-approved to change status. Needs 3rd person review and e2e testing post-review.

Summary
autohive-integrations-sdkfrom~=1.0.2to~=2.0.0FetchResponseobject (response.data,response.status),ActionResult, andActionErrorcontext.auth.get("credentials", {}).get("api_key", "")inputs["param"], optional useinputs.get("param")2.0.0Test Results
Unit Tests (mocked, CI-safe)
TestSearchAppsIOSTestGetReviewsAppStoreTestSearchAppsAndroidTestGetReviewsGooglePlayTestSearchPlacesGoogleMapsTestGetReviewsGoogleMapsIntegration Tests (live SerpApi)
TestSearchAppsIossearch_apps_iosTestSearchAppsAndroidsearch_apps_androidTestSearchPlacesGoogleMapssearch_places_google_mapsTestGetReviewsAppStoreget_reviews_app_storeTestGetReviewsGooglePlayget_reviews_google_playTestGetReviewsGoogleMapsget_reviews_google_mapsValidation
validate_integration.pycheck_code.pyruff checkHow to run