File tree Expand file tree Collapse file tree 2 files changed +45
-11
lines changed
airbyte_cdk/test/declarative/utils Expand file tree Collapse file tree 2 files changed +45
-11
lines changed Original file line number Diff line number Diff line change 1+ # Copyright (c) 2025 Airbyte, Inc., all rights reserved.
2+ """Job runner for Airbyte Standard Tests."""
3+
4+ import logging
15import tempfile
26import uuid
37from dataclasses import asdict
1923
2024@runtime_checkable
2125class 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
2937def 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 (
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments