-
Notifications
You must be signed in to change notification settings - Fork 33
feat: implement formal pytest plugin for test extras #461
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
devin-ai-integration
wants to merge
8
commits into
aj/feat/mini-cat-test-suites
from
feat/pytest-plugin-for-test-extras
Closed
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
377009a
feat: implement formal pytest plugin for test extras
devin-ai-integration[bot] 385d811
chore: use placeholder API key in sample connector config
devin-ai-integration[bot] 1753a17
chore: update poetry.lock
devin-ai-integration[bot] ab11a63
chore: remove sensitive file from git tracking
devin-ai-integration[bot] 8d9ee65
chore: update gitignore to exclude test secrets
devin-ai-integration[bot] e0d6b1b
fix: correct import path and add type annotations
devin-ai-integration[bot] 1d72e7c
fix: address PR comments and dependency issues
devin-ai-integration[bot] 7f132ae
chore: format code with ruff
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,3 +15,4 @@ dist | |
| .idea | ||
| .vscode | ||
| **/__pycache__ | ||
| unit_tests/resources/sample_connector/secrets/config.json | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # Airbyte CDK Test Extras | ||
|
|
||
| This module provides test utilities and fixtures for Airbyte connectors, including pre-built test suites that connector developers can easily use to run a full suite of tests. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Option 1: Using the built-in pytest plugin (recommended) | ||
|
|
||
| The CDK includes a pytest plugin that automatically discovers connectors and their tests, eliminating the need for scaffolding files. To use it: | ||
|
|
||
| 1. Install the Airbyte CDK with test extras: | ||
|
|
||
| ```bash | ||
| pip install airbyte-cdk[tests] | ||
aaronsteers marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| 2. Run pytest in your connector directory with auto-discovery enabled: | ||
|
|
||
| ```bash | ||
| pytest --auto-discover | ||
| ``` | ||
|
|
||
| If your connector is in a different directory, you can specify it: | ||
|
|
||
| ```bash | ||
| pytest --auto-discover --connector-dir /path/to/connector | ||
| ``` | ||
|
|
||
| The plugin will: | ||
| - Automatically discover your connector type (source or destination) | ||
| - Find your connector class | ||
| - Load test scenarios from your acceptance test config file | ||
| - Run the appropriate tests | ||
|
|
||
| ### Option 2: Creating a minimal test scaffold (traditional approach) | ||
|
|
||
| If you prefer more control over test discovery and execution, you can create a minimal test scaffold: | ||
|
|
||
| 1. Create a test file (e.g., `test_connector.py`): | ||
|
|
||
| ```python | ||
| from airbyte_cdk.test.declarative.test_suites.source_base import SourceTestSuiteBase | ||
| from your_connector.source import YourConnector | ||
|
|
||
| class TestYourConnector(SourceTestSuiteBase): | ||
| connector = YourConnector | ||
|
|
||
| @classmethod | ||
| def create_connector(cls, scenario): | ||
| return cls.connector() | ||
| ``` | ||
|
|
||
| 2. Run pytest with the connector option: | ||
|
|
||
| ```bash | ||
| pytest --run-connector | ||
| ``` | ||
|
|
||
| ## Acceptance Test Config | ||
|
|
||
| The test suites will automatically look for and use an acceptance test config file named either: | ||
| - `connector-acceptance-tests.yml` | ||
| - `acceptance-test-config.yml` | ||
|
|
||
| The config file is used to: | ||
| - Discover test scenarios | ||
| - Configure test behavior | ||
| - Set expectations for test results | ||
|
|
||
| ## Available Test Suites | ||
|
|
||
| - `ConnectorTestSuiteBase`: Base test suite for all connectors | ||
| - `SourceTestSuiteBase`: Test suite for source connectors | ||
| - `DestinationTestSuiteBase`: Test suite for destination connectors | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.