Skip to content

Commit 1250472

Browse files
committed
fix some imports
1 parent 3b88490 commit 1250472

File tree

6 files changed

+44
-32
lines changed

6 files changed

+44
-32
lines changed

airbyte_cdk/test/declarative/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from scenario import (
1+
from airbyte_cdk.test.declarative.models.scenario import (
22
AcceptanceTestScenario,
33
)
44

airbyte_cdk/test/declarative/test_suites/connector_base.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import pytest
1111
import yaml
12-
from airbyte_connector_tester.job_runner import run_test_job
1312
from pydantic import BaseModel
1413

1514
from airbyte_cdk import Connector
@@ -21,10 +20,30 @@
2120
from airbyte_cdk.test.declarative.models import (
2221
AcceptanceTestScenario,
2322
)
23+
from airbyte_cdk.test.declarative.utils.job_runner import run_test_job
2424

2525
ACCEPTANCE_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+
2847
class 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(

airbyte_cdk/test/declarative/test_suites/destination_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
22
"""Base class for destination test suites."""
33

4-
from airbyte_connector_tester.connector_tests import ConnectorTestSuiteBase
4+
from airbyte_cdk.test.declarative.test_suites.connector_base import ConnectorTestSuiteBase
55

66

77
class DestinationTestSuiteBase(ConnectorTestSuiteBase):

airbyte_cdk/test/declarative/test_suites/source_base.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55
from pathlib import Path
66

77
import pytest
8-
from airbyte_connector_tester.connector_tests import ConnectorTestSuiteBase
9-
from airbyte_connector_tester.instances import (
10-
AcceptanceTestScenario,
11-
get_acceptance_tests,
12-
)
13-
from airbyte_connector_tester.job_runner import run_test_job
148

159
from airbyte_cdk.models import (
1610
AirbyteStream,
@@ -19,6 +13,9 @@
1913
DestinationSyncMode,
2014
SyncMode,
2115
)
16+
from airbyte_cdk.test.declarative.models import (
17+
AcceptanceTestScenario,
18+
)
2219

2320

2421
class SourceTestSuiteBase(ConnectorTestSuiteBase):

airbyte_cdk/test/declarative/utils/job_runner.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
from typing import Callable, Literal
55

66
import orjson
7-
from airbyte_connector_tester.instances import AcceptanceTestScenario
87

98
from airbyte_cdk import Connector
109
from airbyte_cdk.test import entrypoint_wrapper
10+
from airbyte_cdk.test.declarative.models import (
11+
AcceptanceTestScenario,
12+
)
1113

1214

1315
def run_test_job(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2+
"""Test declarative tests framework."""
3+
4+
from airbyte_cdk.test.declarative import (
5+
ConnectorTestSuiteBase,
6+
DestinationTestSuiteBase,
7+
SourceTestSuiteBase,
8+
)
9+
10+
11+
def test_declarative_test_suites():
12+
"""Test declarative tests framework."""
13+
assert ConnectorTestSuiteBase()
14+
assert DestinationTestSuiteBase()
15+
assert SourceTestSuiteBase()

0 commit comments

Comments
 (0)