Skip to content

Commit ff9e842

Browse files
committed
use proper destination test suite class
1 parent eb0af5d commit ff9e842

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

airbyte_cdk/cli/airbyte_cdk/_connector.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
TEST_FILE_TEMPLATE = '''
6969
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
70-
"""FAST Airbyte Standard Tests for the {connector_name} source."""
70+
"""FAST Airbyte Standard Tests for the {connector_name} connector."""
7171
7272
#from airbyte_cdk.test.standard_tests import {base_class_name}
7373
from airbyte_cdk.test.standard_tests.util import create_connector_test_suite
@@ -81,11 +81,13 @@
8181
connector_directory=Path(),
8282
)
8383
84+
# Uncomment the following lines to create a custom test suite class:
85+
#
8486
# class TestSuite({base_class_name}):
85-
# """Test suite for the {connector_name} source.
86-
87-
# This class inherits from SourceTestSuiteBase and implements all of the tests in the suite.
88-
87+
# """Test suite for the `{connector_name}` connector.
88+
#
89+
# This class inherits from `{base_class_name}` and implements all of the tests in the suite.
90+
#
8991
# As long as the class name starts with "Test", pytest will automatically discover and run the
9092
# tests in this class.
9193
# """

airbyte_cdk/test/standard_tests/util.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,14 @@
1010
from airbyte_cdk.test.standard_tests.declarative_sources import (
1111
DeclarativeSourceTestSuite,
1212
)
13+
from airbyte_cdk.test.standard_tests.destination_base import DestinationTestSuiteBase
1314
from airbyte_cdk.test.standard_tests.docker_base import DockerConnectorTestSuite
1415
from airbyte_cdk.test.standard_tests.source_base import SourceTestSuiteBase
1516
from airbyte_cdk.utils.connector_paths import (
1617
METADATA_YAML,
1718
find_connector_root_from_name,
1819
)
1920

20-
TEST_CLASS_MAPPING: dict[
21-
Literal["python", "manifest-only", "java"],
22-
type[DockerConnectorTestSuite],
23-
] = {
24-
"python": SourceTestSuiteBase,
25-
"manifest-only": DeclarativeSourceTestSuite,
26-
"java": DockerConnectorTestSuite,
27-
}
28-
2921

3022
def create_connector_test_suite(
3123
*,
@@ -55,17 +47,25 @@ def create_connector_test_suite(
5547
)
5648
metadata_dict: dict[str, Any] = yaml.safe_load(metadata_yaml_path.read_text())
5749
metadata_tags = metadata_dict["data"].get("tags", [])
58-
for language_option in TEST_CLASS_MAPPING:
59-
if f"language:{language_option}" in metadata_tags:
60-
language = language_option
61-
test_suite_class = TEST_CLASS_MAPPING[language]
62-
break
63-
else:
50+
language_tag = next((tag for tag in metadata_tags if tag.startswith("language:")), None)
51+
if not language_tag:
6452
raise ValueError(
65-
f"Unsupported connector type. "
66-
f"Supported language values are: {', '.join(TEST_CLASS_MAPPING.keys())}. "
53+
f"Metadata YAML file '{metadata_yaml_path}' does not contain a 'language' tag. "
54+
"Please ensure the metadata file is correctly configured."
6755
f"Found tags: {', '.join(metadata_tags)}"
6856
)
57+
language = language_tag.split(":", 1)[1]
58+
59+
if language == "java":
60+
test_suite_class = DockerConnectorTestSuite
61+
elif language == "manifest-only":
62+
test_suite_class = DeclarativeSourceTestSuite
63+
elif language == "python" and connector_name.startswith("source-"):
64+
test_suite_class = SourceTestSuiteBase
65+
elif language == "python" and connector_name.startswith("destination-"):
66+
test_suite_class = DestinationTestSuiteBase
67+
else:
68+
raise ValueError("Unsupported language for connector '{connector_name}': {language}")
6969

7070
subclass_overrides: dict[str, Any] = {
7171
"get_connector_root_dir": classmethod(lambda cls: connector_directory),

0 commit comments

Comments
 (0)