SameerMesiah97 commented on code in PR #68985:
URL: https://github.com/apache/airflow/pull/68985#discussion_r3501107332
##########
airflow-ctl/tests/airflow_ctl/ctl/test_cli_config.py:
##########
@@ -321,6 +322,23 @@ def list(self, is_alive: bool | None = None) ->
JobCollectionResponse | ServerRe
assert is_alive_arg.kwargs["default"] is None
assert is_alive_arg.kwargs["type"] is bool
+ def test_command_factory_parses_json_dict_datamodel_fields(self):
+ """Dict datamodel fields should parse JSON object CLI values."""
+ command_factory = CommandFactory()
+ dags_trigger_args = []
+ for generated_group_command in command_factory.group_commands:
+ if generated_group_command.name != "dags":
+ continue
+ for sub_command in generated_group_command.subcommands:
+ if sub_command.name == "trigger":
+ dags_trigger_args = list(sub_command.args)
+ break
+
+ conf_arg = next(arg for arg in dags_trigger_args if arg.flags ==
("--conf",))
+ parsed_conf = conf_arg.kwargs["type"]('{"my-key": "my-value"}')
+
+ assert parsed_conf == {"my-key": "my-value"}
+
Review Comment:
I think the test coverage should be expanded to cover the other branches in
json_dict_type, for example:
1) A `dict` input (exercises the early return).
2) Invalid JSON (covers the `JSONDecodeError` path).
3) Valid JSON that is not an object (e.g. `[]`, `"string"`, `123`), to
verify the expected JSON object validation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]