- Notifications
You must be signed in to change notification settings - Fork5k
test(source-instagram): Add comprehensive mock server tests#70951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
…insights stream- Add new test file for user_insights stream with full refresh, incremental sync, and error handling tests- Add error log assertions to existing error handler tests in media_insights and story_insights- Add transformation assertions for users and user_lifetime_insights streams- Add ANY_QUERY_PARAMS support to request_builder for dynamic query parameters- Add JSON fixtures for user_insights API responsesCo-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
Original prompt from sophie.cui@airbyte.io |
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. Helpful Resources
PR Slash CommandsAirbyte Maintainers (that's you!) can execute the following slash commands on your PR:
|
github-actionsbot commentedDec 16, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
…SON fixturesRefactored test_user_insights.py to build responses inline following theharvest/sentry pattern, making tests more readable and self-contained.- Added _build_user_insights_response() helper for success responses- Added _build_error_response() helper for error responses- Removed 7 separate JSON fixture files that are no longer neededCo-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
…laybookPer the playbook's directory structure decision tree, renamed the testdirectory from integration/ to mock_server/ since all tests are mockserver tests using @HttpMocker().Co-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
…ents- Add 2+ parent record tests for media_insights and story_insights substreams- Add transformation assertions for Api stream (account.page_id, account.business_account_id)- Add transformation assertions for stories stream (page_id, business_account_id, story_insights_info, timestamp)All 30 mock server tests pass locally.Co-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
…ights.pyCo-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
…or full coverageCo-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
…rs, and Stories streamsCo-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
…eInsights streamCo-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
…unt assertions- Add error message assertions for IGNORE handlers in test_user_insights.py, test_media_insights.py, and test_story_insights.py per playbook requirements- Fix record count assertions to use exact == counts where deterministic- Use >= with explanatory comment for non-deterministic cases (QueryProperties chunks)- Add with_start_date() method to ConfigBuilder for test control- Add comprehensive comments explaining with_any_query_params() usageCo-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
airbyte-integrations/connectors/source-instagram/unit_tests/mock_server/test_story_insights.py FixedShow fixedHide fixed
Uh oh!
There was an error while loading.Please reload this page.
airbyte-integrations/connectors/source-instagram/unit_tests/mock_server/test_story_insights.py FixedShow fixedHide fixed
Uh oh!
There was an error while loading.Please reload this page.
airbyte-integrations/connectors/source-instagram/unit_tests/mock_server/test_story_insights.py FixedShow fixedHide fixed
Uh oh!
There was an error while loading.Please reload this page.
airbyte-integrations/connectors/source-instagram/unit_tests/mock_server/test_user_insights.py FixedShow fixedHide fixed
Uh oh!
There was an error while loading.Please reload this page.
sophiecuiy commentedDec 17, 2025 • edited by github-actionsbot
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by github-actionsbot
Uh oh!
There was an error while loading.Please reload this page.
/format-fix
|
Co-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
…server-tests' into devin/1765911305-instagram-mock-server-tests
- Fix utils.py to pass state to get_source() for proper state handling- Add test_substream_with_multiple_parent_accounts to test_user_insights.py- Update test_incremental_sync_with_prior_state to use specific query params instead of with_any_query_params() to validate outbound request parameters- Add assertions on specific date values in the incremental testCo-Authored-By: sophie.cui@airbyte.io <sophie.cui@airbyte.io>
| _catalog=catalog(stream_name,sync_mode) | ||
| _config=config_builder.build() | ||
| returnread(get_source(config=_config),_config,_catalog,state,expecting_exception) | ||
| returnread(get_source(config=_config,state=state),_config,_catalog,state,expecting_exception) |
| from .configimportBUSINESS_ACCOUNT_ID,PAGE_ID,ConfigBuilder | ||
| from .request_builderimportRequestBuilder,get_account_request | ||
| from .response_builderimportSECOND_BUSINESS_ACCOUNT_ID,SECOND_PAGE_ID,get_account_response,get_multiple_accounts_response |
4666499 intomasterUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
What
Adds comprehensive mock server tests for the
source-instagramconnector, focusing on theuser_insightsstream which was the only incremental stream without test coverage. Also enhances existing tests with missing assertions per the mock server test playbook.Requested by@sophiecuiy (sophie.cui@airbyte.io)
Link to Devin run:https://app.devin.ai/sessions/62f76a729ac14a56bc83aa105c85ddb2
How
Created new test file
test_user_insights.pywith:Added
with_any_query_params()method toRequestBuilderto support streams with dynamic query parameters (like datetime cursors)Enhanced existing tests:
test_media_insights.pyandtest_story_insights.pyto verify IGNORE handlers don't produce ERROR logstest_users.pyandtest_user_lifetime_insights.pyto verifypage_idandbreakdownfields are addedRenamed
integration/directory tomock_server/per playbook guidelines (all tests use@HttpMocker())Added full coverage per playbook requirements:
media_insightsandstory_insightssubstreamsmedia,users,stories, anduser_insightssubstreamsApistream (account.page_id, account.business_account_id)storiesstream (page_id, business_account_id, story_insights_info, timestamp)mediastream (page_id, business_account_id, media_insights_info)user_lifetime_insightsstream (business_account_id, metric)Added
get_multiple_accounts_response()helper andSECOND_PAGE_ID/SECOND_BUSINESS_ACCOUNT_IDconstants for multi-parent account testingUpdates since last revision
Fixed state passing in utils.py -
read_output()now correctly passesstatetoget_source()for proper state handling in incremental sync testsAdded
test_substream_with_multiple_parent_accountstotest_user_insights.pyper playbook requirementsUpdated
test_incremental_sync_with_prior_stateto use specific query params instead ofwith_any_query_params():sinceparameter derived from stateperiod,metric,since, anduntilparameters== 1) instead of>= 1Added date value assertions in the incremental test to verify the record date matches expected value after schema normalization
Error message assertions for IGNORE handlers - All error handler tests verify both:
Code quality fixes - Removed unused imports flagged by code quality bot
Review guide
unit_tests/mock_server/test_user_insights.py- New test file with inline response buildersunit_tests/mock_server/request_builder.py- Addedwith_any_query_params()methodunit_tests/mock_server/response_builder.py- Addedget_multiple_accounts_response()helperunit_tests/mock_server/config.py- Addedwith_start_date()methodunit_tests/mock_server/utils.py- Fixed state passing toget_source()unit_tests/mock_server/test_media_insights.py- Added error message assertions +test_substream_with_multiple_parent_recordsunit_tests/mock_server/test_story_insights.py- Added error message assertion +test_substream_with_multiple_parent_recordsunit_tests/mock_server/test_api.py- Added transformation assertionsunit_tests/mock_server/test_stories.py- Added transformation assertions +test_substream_with_multiple_parent_accountsunit_tests/mock_server/test_media.py- Added transformation assertions +test_substream_with_multiple_parent_accountsunit_tests/mock_server/test_users.py- Added transformation assertion +test_substream_with_multiple_parent_accountsunit_tests/mock_server/test_user_lifetime_insights.py- Added transformation assertions +test_substream_with_multiple_parent_accountsKey review points:
user_insightsstream usesDatetimeBasedCursorwith daily steps and QueryProperties with 4 chunkstest_incremental_sync_with_prior_statenow validates specific query params (since=2024-01-15T00:00:00+00:00,until=2024-01-15T12:00:00+00:00) derived from stateutils.pyensuresget_source()receives state for proper incremental sync behaviorUser Impact
No user-facing changes. This PR adds test coverage only.
Can this PR be safely reverted and rolled back?