Skip to content

Commit 1aa2a71

Browse files
committed
chore: add unit test
1 parent d8f9588 commit 1aa2a71

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

unit_tests/source_declarative_manifest/test_source_declarative_remote_manifest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
#
44

55
import pytest
6+
from pathlib import Path
7+
from unittest.mock import mock_open, patch
68

79
from airbyte_cdk.cli.source_declarative_manifest._run import (
810
create_declarative_source,
911
handle_command,
12+
_parse_manifest_from_args,
1013
)
1114
from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource
1215

@@ -27,3 +30,22 @@ def test_given_no_injected_declarative_manifest_then_raise_value_error(invalid_r
2730
def test_given_injected_declarative_manifest_then_return_declarative_manifest(valid_remote_config):
2831
source = create_declarative_source(["check", "--config", str(valid_remote_config)])
2932
assert isinstance(source, ManifestDeclarativeSource)
33+
34+
35+
def test_parse_manifest_from_args(valid_remote_config: Path) -> None:
36+
mock_manifest_content = '{"test_manifest": "fancy_declarative_components"}'
37+
with patch("builtins.open", mock_open(read_data=mock_manifest_content)):
38+
# Test with manifest path
39+
result = _parse_manifest_from_args(
40+
[
41+
"check",
42+
"--config",
43+
str(valid_remote_config),
44+
"--manifest-path",
45+
"manifest.yaml",
46+
]
47+
)
48+
assert result == {"test_manifest": "fancy_declarative_components"}
49+
50+
# Test without manifest path
51+
assert _parse_manifest_from_args(["check", "--config", str(valid_remote_config)]) is None

0 commit comments

Comments
 (0)