Skip to content

feat: add empty_streams filtering to standard test suites #641

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions airbyte_cdk/test/models/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
from collections.abc import Generator


class EmptyStreamConfig(BaseModel):
"""Configuration for streams that should be excluded from tests."""

name: str
bypass_reason: str


class ConnectorTestScenario(BaseModel):
"""Acceptance test scenario, as a Pydantic model.

Expand All @@ -50,6 +57,7 @@ class AcceptanceTestFileTypes(BaseModel):
_id: str | None = None # Used to override the default ID generation

configured_catalog_path: Path | None = None
empty_streams: list[EmptyStreamConfig] | None = None
timeout_seconds: int | None = None
expect_records: AcceptanceTestExpectRecords | None = None
file_types: AcceptanceTestFileTypes | None = None
Expand Down
8 changes: 7 additions & 1 deletion airbyte_cdk/test/standard_tests/docker_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_scenarios(
This has to be a separate function because pytest does not allow
parametrization of fixtures with arguments from the test class itself.
"""
categories = ["connection", "spec"]
categories = ["connection", "spec", "basic_read"]
try:
acceptance_test_config_path = cls.acceptance_test_config_path
except FileNotFoundError as e:
Expand Down Expand Up @@ -336,6 +336,12 @@ def test_docker_image_build_and_read(
# If `read_from_streams` is a list, we filter the discovered streams.
streams_list = list(set(streams_list) & set(read_from_streams))

if scenario.empty_streams:
streams_to_exclude = {empty_stream.name for empty_stream in scenario.empty_streams}
streams_list = [
stream for stream in streams_list if stream not in streams_to_exclude
]

configured_catalog: ConfiguredAirbyteCatalog = ConfiguredAirbyteCatalog(
streams=[
ConfiguredAirbyteStream(
Expand Down
5 changes: 5 additions & 0 deletions airbyte_cdk/test/standard_tests/source_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ def test_basic_read(
# Failed as expected; we're done.
return

streams_to_exclude = set()
if scenario.empty_streams:
streams_to_exclude = {empty_stream.name for empty_stream in scenario.empty_streams}

configured_catalog = ConfiguredAirbyteCatalog(
streams=[
ConfiguredAirbyteStream(
Expand All @@ -129,6 +133,7 @@ def test_basic_read(
destination_sync_mode=DestinationSyncMode.append_dedup,
)
for stream in discover_result.catalog.catalog.streams # type: ignore [reportOptionalMemberAccess, union-attr]
if stream.name not in streams_to_exclude
]
)
result = run_test_job(
Expand Down
Loading