Skip to content

Commit c4e6655

Browse files
committed
clean up IConnector interface
1 parent 2812e7d commit c4e6655

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

airbyte_cdk/test/declarative/utils/job_runner.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Copyright (c) 2025 Airbyte, Inc., all rights reserved.
2+
"""Job runner for Airbyte Standard Tests."""
3+
4+
import logging
15
import tempfile
26
import uuid
37
from dataclasses import asdict
@@ -19,11 +23,15 @@
1923

2024
@runtime_checkable
2125
class IConnector(Protocol):
22-
"""A connector that can be run in a test scenario."""
26+
"""A connector that can be run in a test scenario.
27+
28+
Note: We currently use 'spec' to determine if we have a connector object.
29+
In the future, it would be preferred to leverage a 'launch' method instead,
30+
directly on the connector (which doesn't yet exist).
31+
"""
2332

24-
def launch(self, args: list[str] | None) -> None:
25-
"""Launch the connector with the given arguments."""
26-
...
33+
def spec(self, logger: logging.Logger) -> Any:
34+
"""Connectors should have a `spec` method."""
2735

2836

2937
def run_test_job(
@@ -45,13 +53,7 @@ def run_test_job(
4553
if isinstance(connector, type) or callable(connector):
4654
# If the connector is a class or a factory lambda, instantiate it.
4755
connector_obj = connector()
48-
elif (
49-
isinstance(
50-
connector,
51-
IConnector,
52-
)
53-
or True
54-
): # TODO: Get a valid protocol check here
56+
elif isinstance(connector, IConnector): # TODO: Get a valid protocol check here
5557
connector_obj = connector
5658
else:
5759
raise ValueError(
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2+
"""Unit tests for FAST Airbyte Standard Tests."""
3+
4+
from typing import Any
5+
6+
import pytest
7+
8+
from airbyte_cdk.sources.concurrent_source.concurrent_source import ConcurrentSource
9+
from airbyte_cdk.sources.declarative.declarative_source import DeclarativeSource
10+
from airbyte_cdk.sources.source import Source
11+
from airbyte_cdk.test.declarative.utils.job_runner import IConnector
12+
13+
14+
@pytest.mark.parametrize(
15+
"input, expected",
16+
[
17+
(DeclarativeSource, True),
18+
(Source, True),
19+
(None, False),
20+
("", False),
21+
([], False),
22+
({}, False),
23+
(object(), False),
24+
],
25+
)
26+
def test_is_iconnector_check(input: Any, expected: bool) -> None:
27+
"""Assert whether inputs are valid as an IConnector object or class."""
28+
if isinstance(input, type):
29+
assert issubclass(input, IConnector) == expected
30+
return
31+
32+
assert isinstance(input, IConnector) == expected

0 commit comments

Comments
 (0)