diff --git a/elementary/monitor/cli.py b/elementary/monitor/cli.py index f1c4cbbfd..459bbc1b2 100644 --- a/elementary/monitor/cli.py +++ b/elementary/monitor/cli.py @@ -779,7 +779,7 @@ def send_report( project_name=project_name, remote_file_path=bucket_file_path, disable_html_attachment=(disable == "html_attachment"), - include_description=(include == "description"), + include_description=(include in ("description", "descriptions")), ) anonymous_tracking.track_cli_end( diff --git a/tests/unit/cli/test_send_report_include.py b/tests/unit/cli/test_send_report_include.py new file mode 100644 index 000000000..3ad98e85d --- /dev/null +++ b/tests/unit/cli/test_send_report_include.py @@ -0,0 +1,57 @@ +from typing import Optional +from unittest import mock + +import pytest +from click.testing import CliRunner + +from elementary.config.config import Config +from elementary.monitor.cli import monitor + + +@pytest.fixture(autouse=True) +def isolated_env(tmp_path, monkeypatch): + monkeypatch.setenv("DBT_LOG_PATH", str(tmp_path)) + monkeypatch.setattr(Config, "DEFAULT_CONFIG_DIR", str(tmp_path)) + monkeypatch.setattr(Config, "DEFAULT_TARGET_PATH", str(tmp_path)) + with mock.patch("elementary.monitor.cli.AnonymousCommandLineTracking"): + yield + + +@pytest.mark.parametrize( + "include,expected_include_description", + [ + (None, False), + ("descriptions", True), + ("description", True), + ("other", False), + ], +) +def test_send_report_include_description( + tmp_path, include: Optional[str], expected_include_description: bool +): + include_args = ["--include", include] if include else [] + with mock.patch("elementary.monitor.cli.SelectorFilter"), mock.patch( + "elementary.monitor.cli.DataMonitoringReport" + ) as data_monitoring_report: + result = CliRunner().invoke( + monitor, + [ + "send-report", + "--config-dir", + str(tmp_path), + "--target-path", + str(tmp_path), + "--slack-token", + "mock", + "--slack-channel-name", + "mock", + *include_args, + ], + catch_exceptions=False, + ) + assert result.exit_code == 0, result.output + send_report = data_monitoring_report.return_value.send_report + assert ( + send_report.call_args.kwargs["include_description"] + == expected_include_description + )