Skip to content

Commit 845b800

Browse files
committed
fix circular import issue
1 parent 1ac503a commit 845b800

File tree

13 files changed

+72
-53
lines changed

13 files changed

+72
-53
lines changed

airbyte_cdk/test/entrypoint_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
Type,
4545
)
4646
from airbyte_cdk.sources import Source
47-
from airbyte_cdk.test.standard_tests.models.scenario import ExpectedOutcome
47+
from airbyte_cdk.test.models.scenario import ExpectedOutcome
4848

4949

5050
class EntrypointOutput:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
2+
"""Models used for standard tests."""
3+
4+
from airbyte_cdk.test.models.outcome import ExpectedOutcome
5+
from airbyte_cdk.test.models.scenario import ConnectorTestScenario
6+
7+
__all__ = [
8+
"ConnectorTestScenario",
9+
"ExpectedOutcome",
10+
]

airbyte_cdk/test/models/outcome.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2+
"""Run acceptance tests in PyTest.
3+
4+
These tests leverage the same `acceptance-test-config.yml` configuration files as the
5+
acceptance tests in CAT, but they run in PyTest instead of CAT. This allows us to run
6+
the acceptance tests in the same local environment as we are developing in, speeding
7+
up iteration cycles.
8+
"""
9+
10+
from __future__ import annotations
11+
12+
from enum import Enum, auto
13+
14+
15+
class ExpectedOutcome(Enum):
16+
"""Enum to represent the expected outcome of a test scenario.
17+
18+
Class supports comparisons to a boolean or None.
19+
"""
20+
21+
EXPECT_EXCEPTION = auto()
22+
EXPECT_SUCCESS = auto()
23+
ALLOW_ANY = auto()
24+
25+
@classmethod
26+
def from_status_str(cls, status: str | None) -> ExpectedOutcome:
27+
"""Convert a status string to an ExpectedOutcome."""
28+
if status is None:
29+
return ExpectedOutcome.ALLOW_ANY
30+
31+
try:
32+
return {
33+
"succeed": ExpectedOutcome.EXPECT_SUCCESS,
34+
"failed": ExpectedOutcome.EXPECT_EXCEPTION,
35+
}[status]
36+
except KeyError as ex:
37+
raise ValueError(f"Invalid status '{status}'. Expected 'succeed' or 'failed'.") from ex
38+
39+
def expect_exception(self) -> bool:
40+
"""Return whether the expectation is that an exception should be raised."""
41+
return self == ExpectedOutcome.EXPECT_EXCEPTION
42+
43+
def expect_success(self) -> bool:
44+
"""Return whether the expectation is that the test should succeed without exceptions."""
45+
return self == ExpectedOutcome.EXPECT_SUCCESS

airbyte_cdk/test/standard_tests/models/scenario.py renamed to airbyte_cdk/test/models/scenario.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,13 @@
99

1010
from __future__ import annotations
1111

12-
from enum import Enum, auto
1312
from pathlib import Path # noqa: TC003 # Pydantic needs this (don't move to 'if typing' block)
1413
from typing import Any, Literal, cast
1514

1615
import yaml
1716
from pydantic import BaseModel, ConfigDict
1817

19-
20-
class ExpectedOutcome(Enum):
21-
"""Enum to represent the expected outcome of a test scenario.
22-
23-
Class supports comparisons to a boolean or None.
24-
"""
25-
26-
EXPECT_EXCEPTION = auto()
27-
EXPECT_SUCCESS = auto()
28-
ALLOW_ANY = auto()
29-
30-
@classmethod
31-
def from_status_str(cls, status: str | None) -> ExpectedOutcome:
32-
"""Convert a status string to an ExpectedOutcome."""
33-
if status is None:
34-
return ExpectedOutcome.ALLOW_ANY
35-
36-
try:
37-
return {
38-
"succeed": ExpectedOutcome.EXPECT_SUCCESS,
39-
"failed": ExpectedOutcome.EXPECT_EXCEPTION,
40-
}[status]
41-
except KeyError as ex:
42-
raise ValueError(f"Invalid status '{status}'. Expected 'succeed' or 'failed'.") from ex
43-
44-
def expect_exception(self) -> bool:
45-
"""Return whether the expectation is that an exception should be raised."""
46-
return self == ExpectedOutcome.EXPECT_EXCEPTION
47-
48-
def expect_success(self) -> bool:
49-
"""Return whether the expectation is that the test should succeed without exceptions."""
50-
return self == ExpectedOutcome.EXPECT_SUCCESS
18+
from airbyte_cdk.test.models.outcome import ExpectedOutcome
5119

5220

5321
class ConnectorTestScenario(BaseModel):

airbyte_cdk/test/standard_tests/_job_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Status,
1717
)
1818
from airbyte_cdk.test import entrypoint_wrapper
19-
from airbyte_cdk.test.standard_tests.models import (
19+
from airbyte_cdk.test.models import (
2020
ConnectorTestScenario,
2121
)
2222

airbyte_cdk/test/standard_tests/connector_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
Type,
2121
)
2222
from airbyte_cdk.test import entrypoint_wrapper
23-
from airbyte_cdk.test.standard_tests._job_runner import IConnector, run_test_job
24-
from airbyte_cdk.test.standard_tests.models import (
23+
from airbyte_cdk.test.models import (
2524
ConnectorTestScenario,
2625
)
26+
from airbyte_cdk.test.standard_tests._job_runner import IConnector, run_test_job
2727
from airbyte_cdk.utils.connector_paths import (
2828
ACCEPTANCE_TEST_CONFIG,
2929
find_connector_root,

airbyte_cdk/test/standard_tests/declarative_sources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from airbyte_cdk.sources.declarative.concurrent_declarative_source import (
1010
ConcurrentDeclarativeSource,
1111
)
12+
from airbyte_cdk.test.models import ConnectorTestScenario
1213
from airbyte_cdk.test.standard_tests._job_runner import IConnector
13-
from airbyte_cdk.test.standard_tests.models import ConnectorTestScenario
1414
from airbyte_cdk.test.standard_tests.source_base import SourceTestSuiteBase
1515
from airbyte_cdk.utils.connector_paths import MANIFEST_YAML
1616

airbyte_cdk/test/standard_tests/models/__init__.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

airbyte_cdk/test/standard_tests/source_base.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Base class for source test suites."""
33

44
from dataclasses import asdict
5+
from typing import TYPE_CHECKING
56

67
from airbyte_cdk.models import (
78
AirbyteMessage,
@@ -12,14 +13,16 @@
1213
SyncMode,
1314
Type,
1415
)
15-
from airbyte_cdk.test import entrypoint_wrapper
16+
from airbyte_cdk.test.models import (
17+
ConnectorTestScenario,
18+
)
1619
from airbyte_cdk.test.standard_tests._job_runner import run_test_job
1720
from airbyte_cdk.test.standard_tests.connector_base import (
1821
ConnectorTestSuiteBase,
1922
)
20-
from airbyte_cdk.test.standard_tests.models import (
21-
ConnectorTestScenario,
22-
)
23+
24+
if TYPE_CHECKING:
25+
from airbyte_cdk.test import entrypoint_wrapper
2326

2427

2528
class SourceTestSuiteBase(ConnectorTestSuiteBase):

airbyte_cdk/test/utils/reading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from airbyte_cdk.models import AirbyteStateMessage, ConfiguredAirbyteCatalog, SyncMode
77
from airbyte_cdk.test.catalog_builder import CatalogBuilder
88
from airbyte_cdk.test.entrypoint_wrapper import EntrypointOutput, read
9-
from airbyte_cdk.test.standard_tests.models.scenario import ExpectedOutcome
9+
from airbyte_cdk.test.models.outcome import ExpectedOutcome
1010

1111

1212
def catalog(stream_name: str, sync_mode: SyncMode) -> ConfiguredAirbyteCatalog:

0 commit comments

Comments
 (0)