Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove section check from get-value command #29541

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions airflow/cli/commands/config_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ def show_config(args):

def get_value(args):
"""Get one value from configuration."""
if not conf.has_section(args.section):
raise SystemExit(f"The section [{args.section}] is not found in config.")

if not conf.has_option(args.section, args.option):
potiuk marked this conversation as resolved.
Show resolved Hide resolved
raise SystemExit(f"The option [{args.section}/{args.option}] is not found in config.")

Expand Down
12 changes: 6 additions & 6 deletions tests/cli/commands/test_config_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ def test_should_display_value(self):
assert "test_value" == temp_stdout.getvalue().strip()

@mock.patch("airflow.cli.commands.config_command.conf")
def test_should_raise_exception_when_section_is_missing(self, mock_conf):
def test_should_not_raise_exception_when_section_for_config_with_value_defined_elsewhere_is_missing(
self, mock_conf
):
# no section in config
mock_conf.has_section.return_value = False
# pretend that the option is defined by other means
mock_conf.has_option.return_value = True

with pytest.raises(SystemExit) as ctx:
config_command.get_value(
self.parser.parse_args(["config", "get-value", "missing-section", "dags_folder"])
)
assert "The section [missing-section] is not found in config." == str(ctx.value)
config_command.get_value(self.parser.parse_args(["config", "get-value", "some_section", "value"]))

@mock.patch("airflow.cli.commands.config_command.conf")
def test_should_raise_exception_when_option_is_missing(self, mock_conf):
Expand Down