Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integrationdevin-ai-integrationbot commentedDec 16, 2025
edited
Loading

What

Adds comprehensive mock server tests for thesource-instagram connector, focusing on theuser_insights stream 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

  1. Created new test filetest_user_insights.py with:

    • Full refresh sync test
    • Incremental sync tests (first sync without state, subsequent sync with prior state)
    • Error handling tests for 3 IGNORE handlers (error_subcode 2108006, code 100/subcode 33, code 10)
    • Inline response builders following the harvest/sentry pattern for better readability
  2. Addedwith_any_query_params() method toRequestBuilder to support streams with dynamic query parameters (like datetime cursors)

  3. Enhanced existing tests:

    • Added error log assertions totest_media_insights.py andtest_story_insights.py to verify IGNORE handlers don't produce ERROR logs
    • Added transformation assertions totest_users.py andtest_user_lifetime_insights.py to verifypage_id andbreakdown fields are added
  4. Renamedintegration/ directory tomock_server/ per playbook guidelines (all tests use@HttpMocker())

  5. Added full coverage per playbook requirements:

    • Added 2+ parent record tests formedia_insights andstory_insights substreams
    • Added 2+ parent account tests formedia,users,stories, anduser_insights substreams
    • Added transformation assertions forApi stream (account.page_id, account.business_account_id)
    • Added transformation assertions forstories stream (page_id, business_account_id, story_insights_info, timestamp)
    • Added transformation assertions formedia stream (page_id, business_account_id, media_insights_info)
    • Added transformation assertions foruser_lifetime_insights stream (business_account_id, metric)
  6. Addedget_multiple_accounts_response() helper andSECOND_PAGE_ID/SECOND_BUSINESS_ACCOUNT_ID constants for multi-parent account testing

Updates since last revision

  1. Fixed state passing in utils.py -read_output() now correctly passesstate toget_source() for proper state handling in incremental sync tests

  2. Addedtest_substream_with_multiple_parent_accounts totest_user_insights.py per playbook requirements

  3. Updatedtest_incremental_sync_with_prior_state to use specific query params instead ofwith_any_query_params():

    • Now validates that outbound requests include the expectedsince parameter derived from state
    • Mocks all 4 QueryProperties chunks with specificperiod,metric,since, anduntil parameters
    • Enables exact record count assertion (== 1) instead of>= 1
  4. Added date value assertions in the incremental test to verify the record date matches expected value after schema normalization

  5. Error message assertions for IGNORE handlers - All error handler tests verify both:

    • No ERROR logs are produced
    • The specific error_message from manifest.yaml appears in logs
  6. Code quality fixes - Removed unused imports flagged by code quality bot

Review guide

  1. unit_tests/mock_server/test_user_insights.py - New test file with inline response builders
  2. unit_tests/mock_server/request_builder.py - Addedwith_any_query_params() method
  3. unit_tests/mock_server/response_builder.py - Addedget_multiple_accounts_response() helper
  4. unit_tests/mock_server/config.py - Addedwith_start_date() method
  5. unit_tests/mock_server/utils.py - Fixed state passing toget_source()
  6. unit_tests/mock_server/test_media_insights.py - Added error message assertions +test_substream_with_multiple_parent_records
  7. unit_tests/mock_server/test_story_insights.py - Added error message assertion +test_substream_with_multiple_parent_records
  8. unit_tests/mock_server/test_api.py - Added transformation assertions
  9. unit_tests/mock_server/test_stories.py - Added transformation assertions +test_substream_with_multiple_parent_accounts
  10. unit_tests/mock_server/test_media.py - Added transformation assertions +test_substream_with_multiple_parent_accounts
  11. unit_tests/mock_server/test_users.py - Added transformation assertion +test_substream_with_multiple_parent_accounts
  12. unit_tests/mock_server/test_user_lifetime_insights.py - Added transformation assertions +test_substream_with_multiple_parent_accounts

Key review points:

  • Theuser_insights stream usesDatetimeBasedCursor with daily steps and QueryProperties with 4 chunks
  • test_incremental_sync_with_prior_state now validates specific query params (since=2024-01-15T00:00:00+00:00,until=2024-01-15T12:00:00+00:00) derived from state
  • Error message assertions check for specific strings from manifest.yaml error_message templates
  • The state fix inutils.py ensuresget_source() receives state for proper incremental sync behavior

User Impact

No user-facing changes. This PR adds test coverage only.

Can this PR be safely reverted and rolled back?

  • YES 💚

…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>
@devin-ai-integration
Copy link
ContributorAuthor

Original prompt from sophie.cui@airbyte.io
Received message in Slack channel #ask-devin-ai:@Devin !create_api_mock_server_tests instagramThread URL: https://airbytehq-team.slack.com/archives/C08BHPUMEPJ/p1765911122858819PLAYBOOK_md:# Create API Mock Server Tests PlaybookYou are AI Create Mock Server Test Devin, an expert at creating mock server tests for Airbyte connectors.## ContextYou are working on a task to create comprehensive mock server tests for an Airbyte connector. The connector name should be inferred from the GitHub issue title, description, labels, or code references. If you cannot confidently identify the connector, comment back asking for clarification.## Requirements for Mock Server TestsThe following requirements define what must be tested for each stream in the connector:### General Requirements- Use the existing mock server tests for `source-harvest`, `source-woocommerce`, and `source-sentry` as references. These are located in `airbyte-integrations/connectors/{connector-name}/unit_tests/mock_server/` (or `unit_tests/integration/` for older connectors).- Create one test file per stream.- Check `manifest.yaml` to see what configurations need additional test cases.- Add assertions on key fields (like expected record IDs), not just record counts.- Record count assertions should be exact and use `==` instead of `>=`.  - Exception: `>=` is allowed when testing "at least N" contracts or when shared mocks across partitions make counts non-deterministic. Always assert on specific IDs and add a comment explaining the exception.- For graceful error handling, check logs with assert statements in addition to verifying 0 results.- Aim for 100% test coverage for all per-stream configurations across every stream.### Full Refresh Sync- All streams should test full refresh sync behavior at minimum.### Error Handling- All streams with an error handler defined in `manifest.yaml` should confirm IGNORE, FAIL, etc. behavior for each type of error handler case.- Test both erro... (21958 chars truncated...)

@devin-ai-integration
Copy link
ContributorAuthor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Contributor

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

Helpful Resources

PR Slash Commands

Airbyte Maintainers (that's you!) can execute the following slash commands on your PR:

  • /format-fix - Fixes most formatting issues.
  • /bump-version - Bumps connector versions.
    • You can specify a custom changelog by passingchangelog. Example:/bump-version changelog="My cool update"
    • Leaving the changelog arg blank will auto-populate the changelog from the PR title.
  • /bump-progressive-rollout-version - Bumps connector version with an RC suffix for progressive rollouts.
    • Creates a release candidate version (e.g.,2.16.10-rc.1) withenableProgressiveRollout: true
    • Example:/bump-progressive-rollout-version changelog="Add new feature for progressive rollout"
  • /run-cat-tests - Runs legacy CAT tests (Connector Acceptance Tests)
  • /run-live-tests - Runs live tests for the modified connector(s).
  • /run-regression-tests - Runs regression tests for the modified connector(s).
  • /build-connector-images - Builds and publishes a pre-release docker image for the modified connector(s).
  • /publish-connectors-prerelease - Publishes pre-release connector builds (tagged as{version}-dev.{git-sha}) for all modified connectors in the PR.
  • Connector release lifecycle (AI-powered):
    • /ai-prove-fix - Runs prerelease readiness checks, including testing against customer connections.
    • /ai-canary-prerelease - Rolls out prerelease to 5-10 connections for canary testing.
    • /ai-release-watch - Monitors rollout post-release and tracks sync success rates.
  • JVM connectors:
    • /update-connector-cdk-version connector=<CONNECTOR_NAME> - Updates the specified connector to the latest CDK version.
      Example:/update-connector-cdk-version connector=destination-bigquery
    • /bump-bulk-cdk-version bump=patch changelog='foo' - Bump the Bulk CDK's version.bump can be major/minor/patch.
  • Python connectors:
    • /poe connector source-example lock - Run the Poelock task on thesource-example connector, committing the results back to the branch.
    • /poe source example lock - Alias for/poe connector source-example lock.
    • /poe source example use-cdk-branch my/branch - Pin thesource-example CDK reference to the branch name specified.
    • /poe source example use-cdk-latest - Update thesource-example CDK dependency to the latest available version.

📝Edit this welcome message.

@github-actions
Copy link
Contributor

github-actionsbot commentedDec 16, 2025
edited
Loading

source-instagram Connector Test Results

78 tests   75 ✅  39s ⏱️
 2 suites   3 💤
 2 files     0 ❌

Results for commit5797463.

♻️ This comment has been updated with latest results.

@sophiecuiysophiecuiy changed the titlefeat(source-instagram): Add comprehensive mock server tests for user_insights streamfeat(source-instagram): Add comprehensive mock server testsDec 16, 2025
…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>
@sophiecuiysophiecuiy changed the titlefeat(source-instagram): Add comprehensive mock server teststest(source-instagram): Add comprehensive mock server testsDec 16, 2025
…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>
@sophiecuiy
Copy link
Contributor

sophiecuiy commentedDec 17, 2025
edited by github-actionsbot
Loading

/format-fix

Format-fix job started...Check job output.

✅ Changes applied successfully. (c618f1f)

github-actions[bot] reacted with hooray emojigithub-actions[bot] reacted with rocket emojigithub-actions[bot] and devin-ai-integration[bot] reacted with eyes emoji

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
@sophiecuiysophiecuiy merged commit4666499 intomasterDec 17, 2025
34 of 35 checks passed
@sophiecuiysophiecuiy deleted the devin/1765911305-instagram-mock-server-tests branchDecember 17, 2025 22:22
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@sophiecuiysophiecuiysophiecuiy approved these changes

@suisuixia42suisuixia42Awaiting requested review from suisuixia42

+1 more reviewer

@github-code-qualitygithub-code-quality[bot]github-code-quality[bot] left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

@sophiecuiysophiecuiy

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@sophiecuiy@octavia-squidington-iii

[8]ページ先頭

©2009-2025 Movatter.jp