Skip to content

Commit bc521a6

Browse files
committed
chore: entrypoint tests
1 parent 2712942 commit bc521a6

File tree

1 file changed

+67
-2
lines changed

1 file changed

+67
-2
lines changed

unit_tests/test_entrypoint.py

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,24 @@ def test_airbyte_entrypoint_init(mocker):
124124
(
125125
"check",
126126
{"config": "config_path"},
127-
{"command": "check", "config": "config_path", "debug": False},
127+
{
128+
"command": "check",
129+
"config": "config_path",
130+
"debug": False,
131+
"components_path": None,
132+
"manifest_path": None,
133+
},
128134
),
129135
(
130136
"discover",
131137
{"config": "config_path", "debug": ""},
132-
{"command": "discover", "config": "config_path", "debug": True},
138+
{
139+
"command": "discover",
140+
"config": "config_path",
141+
"debug": True,
142+
"components_path": None,
143+
"manifest_path": None,
144+
},
133145
),
134146
(
135147
"read",
@@ -140,6 +152,8 @@ def test_airbyte_entrypoint_init(mocker):
140152
"catalog": "catalog_path",
141153
"state": "None",
142154
"debug": False,
155+
"components_path": None,
156+
"manifest_path": None,
143157
},
144158
),
145159
(
@@ -156,6 +170,8 @@ def test_airbyte_entrypoint_init(mocker):
156170
"catalog": "catalog_path",
157171
"state": "state_path",
158172
"debug": True,
173+
"components_path": None,
174+
"manifest_path": None,
159175
},
160176
),
161177
],
@@ -168,6 +184,55 @@ def test_parse_valid_args(
168184
assert vars(parsed_args) == expected_args
169185

170186

187+
@pytest.mark.parametrize(
188+
["cmd", "args", "param_keys"],
189+
[
190+
(
191+
"check",
192+
{"config": "config_path", "manifest_path": "manifest_file.yaml"},
193+
["manifest_path"],
194+
),
195+
(
196+
"read",
197+
{
198+
"config": "config_path",
199+
"catalog": "catalog_path",
200+
"state": "state_path",
201+
"components_path": "components.py",
202+
"manifest_path": "manifest.yaml",
203+
},
204+
["components_path", "manifest_path"],
205+
),
206+
],
207+
)
208+
def test_parse_new_args(
209+
cmd: str, args: Mapping[str, Any], param_keys: List[str], mocker: MagicMock
210+
) -> None:
211+
"""Test that new arguments are properly handled if they are supported."""
212+
mock_parser = MagicMock()
213+
mock_parse_args = MagicMock()
214+
mock_parser.parse_args = mock_parse_args
215+
216+
# Create a namespace with expected values
217+
expected_namespace = Namespace(
218+
command=cmd,
219+
debug=False,
220+
**{k: v for k, v in args.items() if k != "debug"},
221+
)
222+
mock_parse_args.return_value = expected_namespace
223+
224+
mocker.patch.object(AirbyteEntrypoint, "parse_args", return_value=expected_namespace)
225+
226+
entrypoint = AirbyteEntrypoint(MockSource())
227+
228+
arglist = _as_arglist(cmd, args)
229+
parsed_args = entrypoint.parse_args(arglist)
230+
231+
for key in param_keys:
232+
assert hasattr(parsed_args, key)
233+
assert getattr(parsed_args, key) == args[key]
234+
235+
171236
@pytest.mark.parametrize(
172237
["cmd", "args"],
173238
[

0 commit comments

Comments
 (0)