Skip to content

Conversation

@edgarrmondragon
Copy link
Collaborator

@edgarrmondragon edgarrmondragon commented Jan 6, 2026

Summary by Sourcery

Introduce a fixture-based configuration mechanism for target tests and update existing target test suites to use it.

New Features:

  • Add a plugin_config pytest fixture to target test classes for providing configurable target plugin settings.
  • Allow the target test runner fixture to consume configuration from the plugin_config fixture instead of a static config dict.

Enhancements:

  • Refactor parquet, CSV, and SQLite target tests to build their configs dynamically via plugin_config and other pytest fixtures.
  • Add tests validating that factory-generated target test classes expose and correctly wire the plugin_config fixture into the runner.

Tests:

  • Extend factory tests to cover the presence, override behavior, and usage of the plugin_config fixture in generated target test classes.

Signed-off-by: Edgar Ramírez-Mondragón <edgarrm358@gmail.com>
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 6, 2026

Reviewer's Guide

Adds a fixture-based configuration mechanism for target tests via a new plugin_config fixture in the factory-generated test classes, updates existing target package tests to use this fixture for dynamic configs, and adds coverage to ensure the new fixture and runner wiring behave correctly.

Sequence diagram for plugin_config-based target test runner setup

sequenceDiagram
    actor Pytest
    participant GeneratedTargetTestClass
    participant plugin_config_fixture
    participant runner_fixture
    participant TargetTestRunner

    Pytest->>GeneratedTargetTestClass: request runner_fixture
    GeneratedTargetTestClass->>plugin_config_fixture: call plugin_config()
    plugin_config_fixture-->>GeneratedTargetTestClass: dict or None
    GeneratedTargetTestClass->>runner_fixture: call runner(plugin_config)
    runner_fixture->>TargetTestRunner: __init__(target_class, config=plugin_config, suite_config, kwargs)
    TargetTestRunner-->>runner_fixture: TargetTestRunner instance
    runner_fixture-->>Pytest: TargetTestRunner instance
Loading

Class diagram for generated target test class and TargetTestRunner

classDiagram
    class GeneratedTargetTestClass {
        +dict config
        +dict suite_config
        +plugin_config() dict or None
        +runner(plugin_config dict or None) TargetTestRunner
    }

    class TargetTestRunner {
        +TargetTestRunner(target_class, config, suite_config, kwargs)
    }

    GeneratedTargetTestClass --> TargetTestRunner : creates
Loading

Flow diagram for plugin_config resolution in target tests

flowchart TD
    A[Request runner fixture] --> B[Call plugin_config fixture]
    B --> C{plugin_config is None?}
    C -->|Yes| D[Use default config from factory]
    C -->|No| E[Use plugin_config dict]
    D --> F[Instantiate TargetTestRunner with default config]
    E --> F[Instantiate TargetTestRunner with custom config]
Loading

File-Level Changes

Change Details Files
Introduce a plugin_config fixture in factory-generated target test classes and wire the runner fixture to consume it instead of a static config argument.
  • Add a plugin_config pytest fixture that returns the provided config by default and is intended to be overridden by user tests.
  • Update the runner fixture to depend on plugin_config and pass its value as the config argument when constructing TargetTestRunner.
  • Document behavior of plugin_config and runner fixtures via docstrings.
singer_sdk/testing/factory.py
Add tests validating fixture-based config behavior in the target test class factory.
  • Create a new TestTargetFixtureBasedConfig test class to validate that plugin_config fixture exists on generated test classes.
  • Add a test to ensure plugin_config can be overridden in subclasses of the generated test class.
  • Add a test to ensure the runner fixture accepts plugin_config as a parameter in its signature.
tests/core/testing/test_factory.py
Refactor target package tests to use the new plugin_config fixture for dynamic configuration instead of hard-coded module-level config objects.
  • Update TargetParquet tests to pass config=None to get_target_test_class and provide a plugin_config fixture that derives the filepath from a test_output_dir fixture, with proper directory setup/teardown.
  • Update TargetCSV tests similarly to use config=None and a plugin_config fixture that builds target_folder from a per-class test_output_dir fixture, simplifying the resource fixture to just return that directory.
  • Update TargetSQLite tests to use config=None and provide a plugin_config fixture that constructs a database path from pytest's tmp_path fixture.
tests/packages/test_target_parquet.py
tests/packages/test_target_csv.py
tests/packages/test_target_sqlite.py
Minor doc/clarity tweak in tap CSV tests related to state timing.
  • Clarify the comment describing the FUTURE datetime used for state testing.
tests/packages/test_tap_csv.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.06%. Comparing base (5b18479) to head (2ac72b1).

Files with missing lines Patch % Lines
singer_sdk/testing/factory.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3434      +/-   ##
==========================================
- Coverage   94.07%   94.06%   -0.02%     
==========================================
  Files          69       69              
  Lines        5777     5780       +3     
  Branches      716      716              
==========================================
+ Hits         5435     5437       +2     
- Misses        239      240       +1     
  Partials      103      103              
Flag Coverage Δ
core 81.90% <75.00%> (-0.01%) ⬇️
end-to-end 76.41% <75.00%> (-0.01%) ⬇️
optional-components 43.47% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 6, 2026

CodSpeed Performance Report

Merging #3434 will not alter performance

Comparing feat/target-test-plugin-config-fixture (2ac72b1) with main (c802f94)1

Summary

✅ 8 untouched

Footnotes

  1. No successful run was found on main (5b18479) during the generation of this report, so c802f94 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants