99
1010import pytest
1111import yaml
12- from airbyte_connector_tester .job_runner import run_test_job
1312from pydantic import BaseModel
1413
1514from airbyte_cdk import Connector
2120from airbyte_cdk .test .declarative .models import (
2221 AcceptanceTestScenario ,
2322)
23+ from airbyte_cdk .test .declarative .utils .job_runner import run_test_job
2424
2525ACCEPTANCE_TEST_CONFIG_PATH = Path ("acceptance-test-config.yml" )
2626
2727
28+ def _get_acceptance_tests (
29+ category : str ,
30+ accept_test_config_path : Path = ACCEPTANCE_TEST_CONFIG_PATH ,
31+ ) -> list [AcceptanceTestScenario ]:
32+ all_tests_config = yaml .safe_load (accept_test_config_path .read_text ())
33+ if "acceptance_tests" not in all_tests_config :
34+ raise ValueError (f"Acceptance tests config not found in { accept_test_config_path } " )
35+ if category not in all_tests_config ["acceptance_tests" ]:
36+ return []
37+ if "tests" not in all_tests_config ["acceptance_tests" ][category ]:
38+ raise ValueError (f"No tests found for category { category } " )
39+
40+ return [
41+ AcceptanceTestScenario .model_validate (test )
42+ for test in all_tests_config ["acceptance_tests" ][category ]["tests" ]
43+ if "iam_role" not in test ["config_path" ]
44+ ]
45+
46+
2847class ConnectorTestSuiteBase (abc .ABC ):
2948 """Base class for connector test suites."""
3049
@@ -49,27 +68,6 @@ def new_connector(self, **kwargs: dict[str, Any]) -> Connector:
4968 """
5069 return self .connector_factory ()
5170
52- # Internal Methods - We don't expect subclasses to override these
53-
54- @classmethod
55- def _get_acceptance_tests (
56- category : str ,
57- accept_test_config_path : Path = ACCEPTANCE_TEST_CONFIG_PATH ,
58- ) -> list [AcceptanceTestScenario ]:
59- all_tests_config = yaml .safe_load (accept_test_config_path .read_text ())
60- if "acceptance_tests" not in all_tests_config :
61- raise ValueError (f"Acceptance tests config not found in { accept_test_config_path } " )
62- if category not in all_tests_config ["acceptance_tests" ]:
63- return []
64- if "tests" not in all_tests_config ["acceptance_tests" ][category ]:
65- raise ValueError (f"No tests found for category { category } " )
66-
67- return [
68- AcceptanceTestScenario .model_validate (test )
69- for test in all_tests_config ["acceptance_tests" ][category ]["tests" ]
70- if "iam_role" not in test ["config_path" ]
71- ]
72-
7371 # Test Definitions
7472
7573 @pytest .mark .parametrize (
@@ -89,7 +87,7 @@ def test_use_plugin_parametrized_test(
8987
9088 @pytest .mark .parametrize (
9189 "instance" ,
92- self . _get_acceptance_tests ("connection" ),
90+ _get_acceptance_tests ("connection" ),
9391 ids = lambda instance : instance .instance_name ,
9492 )
9593 def test_check (
0 commit comments