33#
44
55import pytest
6+ from pathlib import Path
7+ from unittest .mock import mock_open , patch
68
79from airbyte_cdk .cli .source_declarative_manifest ._run import (
810 create_declarative_source ,
911 handle_command ,
12+ _parse_manifest_from_args ,
1013)
1114from 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
2730def 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