|
10 | 10 | from airbyte_cdk.test.standard_tests.declarative_sources import ( |
11 | 11 | DeclarativeSourceTestSuite, |
12 | 12 | ) |
| 13 | +from airbyte_cdk.test.standard_tests.destination_base import DestinationTestSuiteBase |
13 | 14 | from airbyte_cdk.test.standard_tests.docker_base import DockerConnectorTestSuite |
14 | 15 | from airbyte_cdk.test.standard_tests.source_base import SourceTestSuiteBase |
15 | 16 | from airbyte_cdk.utils.connector_paths import ( |
16 | 17 | METADATA_YAML, |
17 | 18 | find_connector_root_from_name, |
18 | 19 | ) |
19 | 20 |
|
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 | | - |
29 | 21 |
|
30 | 22 | def create_connector_test_suite( |
31 | 23 | *, |
@@ -55,17 +47,25 @@ def create_connector_test_suite( |
55 | 47 | ) |
56 | 48 | metadata_dict: dict[str, Any] = yaml.safe_load(metadata_yaml_path.read_text()) |
57 | 49 | 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: |
64 | 52 | 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." |
67 | 55 | f"Found tags: {', '.join(metadata_tags)}" |
68 | 56 | ) |
| 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}") |
69 | 69 |
|
70 | 70 | subclass_overrides: dict[str, Any] = { |
71 | 71 | "get_connector_root_dir": classmethod(lambda cls: connector_directory), |
|
0 commit comments