|
8 | 8 | from pathlib import Path
|
9 | 9 | from typing import TYPE_CHECKING, cast
|
10 | 10 |
|
11 |
| -import yaml |
12 |
| -from airbyte_protocol_dataclasses.models.airbyte_protocol import AirbyteConnectionStatus |
13 | 11 | from boltons.typeutils import classproperty
|
14 | 12 |
|
15 |
| -from airbyte_cdk.models import Status |
16 | 13 | from airbyte_cdk.test import entrypoint_wrapper
|
17 | 14 | from airbyte_cdk.test.models import (
|
18 | 15 | ConnectorTestScenario,
|
@@ -121,74 +118,6 @@ def test_check(
|
121 | 118 | connector_root=self.get_connector_root_dir(),
|
122 | 119 | )
|
123 | 120 | assert len(result.connection_status_messages) == 1, (
|
124 |
| - f"Expected exactly one CONNECTION_STATUS message. Got {len(result.connection_status_messages)}: \n" |
125 |
| - + "\n".join([str(m) for m in result._messages or []]) |
126 |
| - + "\nErrors: " |
127 |
| - + str(result.errors) |
128 |
| - or "None" |
| 121 | + f"Expected exactly one CONNECTION_STATUS message. " |
| 122 | + "Got: {result.connection_status_messages!s}" |
129 | 123 | )
|
130 |
| - conn_status = cast( |
131 |
| - AirbyteConnectionStatus, result.connection_status_messages[0].connectionStatus |
132 |
| - ) |
133 |
| - if ( |
134 |
| - scenario.expected_outcome.expect_exception() |
135 |
| - and conn_status.status == Status.SUCCEEDED |
136 |
| - and not result.errors |
137 |
| - ): |
138 |
| - raise AssertionError(f"Expected error in `check` but got success.") |
139 |
| - |
140 |
| - @classmethod |
141 |
| - def get_connector_root_dir(cls) -> Path: |
142 |
| - """Get the root directory of the connector.""" |
143 |
| - return find_connector_root([cls.get_test_class_dir(), Path.cwd()]) |
144 |
| - |
145 |
| - @classproperty |
146 |
| - def acceptance_test_config_path(cls) -> Path: |
147 |
| - """Get the path to the acceptance test config file.""" |
148 |
| - result = cls.get_connector_root_dir() / ACCEPTANCE_TEST_CONFIG |
149 |
| - if result.exists(): |
150 |
| - return result |
151 |
| - |
152 |
| - raise FileNotFoundError(f"Acceptance test config file not found at: {str(result)}") |
153 |
| - |
154 |
| - @classmethod |
155 |
| - def get_scenarios( |
156 |
| - cls, |
157 |
| - ) -> list[ConnectorTestScenario]: |
158 |
| - """Get acceptance tests for a given category. |
159 |
| -
|
160 |
| - This has to be a separate function because pytest does not allow |
161 |
| - parametrization of fixtures with arguments from the test class itself. |
162 |
| - """ |
163 |
| - categories = ["connection", "spec"] |
164 |
| - all_tests_config = yaml.safe_load(cls.acceptance_test_config_path.read_text()) |
165 |
| - if "acceptance_tests" not in all_tests_config: |
166 |
| - raise ValueError( |
167 |
| - f"Acceptance tests config not found in {cls.acceptance_test_config_path}." |
168 |
| - f" Found only: {str(all_tests_config)}." |
169 |
| - ) |
170 |
| - |
171 |
| - test_scenarios: list[ConnectorTestScenario] = [] |
172 |
| - for category in categories: |
173 |
| - if ( |
174 |
| - category not in all_tests_config["acceptance_tests"] |
175 |
| - or "tests" not in all_tests_config["acceptance_tests"][category] |
176 |
| - ): |
177 |
| - continue |
178 |
| - |
179 |
| - test_scenarios.extend( |
180 |
| - [ |
181 |
| - ConnectorTestScenario.model_validate(test) |
182 |
| - for test in all_tests_config["acceptance_tests"][category]["tests"] |
183 |
| - if "config_path" in test and "iam_role" not in test["config_path"] |
184 |
| - ] |
185 |
| - ) |
186 |
| - |
187 |
| - connector_root = cls.get_connector_root_dir().absolute() |
188 |
| - for test in test_scenarios: |
189 |
| - if test.config_path: |
190 |
| - test.config_path = connector_root / test.config_path |
191 |
| - if test.configured_catalog_path: |
192 |
| - test.configured_catalog_path = connector_root / test.configured_catalog_path |
193 |
| - |
194 |
| - return test_scenarios |
0 commit comments