Skip to content

Commit f227297

Browse files
feat: Add --no-creds option to connector and image test commands
- Add --no-creds flag to airbyte-cdk connector test command - Add --no-creds flag to airbyte-cdk image test command - Skip tests marked with 'requires_creds' when --no-creds is used - For connector test: use '-m not requires_creds' filter - For image test: combine with existing marker using 'image_tests and not requires_creds' - Maintains backward compatibility when flag is not used Co-Authored-By: AJ Steers <aj@airbyte.io>
1 parent f976c72 commit f227297

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

airbyte_cdk/cli/airbyte_cdk/_connector.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,18 @@ def connector_cli_group() -> None:
123123
multiple=True,
124124
help="Additional argument(s) to pass to pytest. Can be specified multiple times.",
125125
)
126+
@click.option(
127+
"--no-creds",
128+
is_flag=True,
129+
default=False,
130+
help="Skip tests that require credentials (marked with 'requires_creds').",
131+
)
126132
def connector_test(
127133
connector: str | Path | None = None,
128134
*,
129135
collect_only: bool = False,
130136
pytest_args: list[str] | None = None,
137+
no_creds: bool = False,
131138
) -> None:
132139
"""Run connector tests.
133140
@@ -147,6 +154,9 @@ def connector_test(
147154
if collect_only:
148155
pytest_args.append("--collect-only")
149156

157+
if no_creds:
158+
pytest_args.extend(["-m", "not requires_creds"])
159+
150160
run_connector_tests(
151161
connector_name=connector_name,
152162
connector_directory=connector_directory,

airbyte_cdk/cli/airbyte_cdk/_image.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,17 @@ def build(
100100
"--image",
101101
help="Image to test, instead of building a new one.",
102102
)
103+
@click.option(
104+
"--no-creds",
105+
is_flag=True,
106+
default=False,
107+
help="Skip tests that require credentials (marked with 'requires_creds').",
108+
)
103109
def image_test( # "image test" command
104110
connector: str | None = None,
105111
*,
106112
image: str | None = None,
113+
no_creds: bool = False,
107114
) -> None:
108115
"""Test a connector Docker image.
109116
@@ -124,7 +131,7 @@ def image_test( # "image test" command
124131
connector_name, connector_directory = resolve_connector_name_and_directory(connector)
125132

126133
# Select only tests with the 'image_tests' mark
127-
pytest_args = ["-m", "image_tests"]
134+
pytest_args = ["-m", "image_tests and not requires_creds" if no_creds else "image_tests"]
128135
if not image:
129136
metadata_file_path: Path = connector_directory / "metadata.yaml"
130137
try:

0 commit comments

Comments
 (0)