Skip to content
Open
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
2 changes: 1 addition & 1 deletion elementary/monitor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
57 changes: 57 additions & 0 deletions tests/unit/cli/test_send_report_include.py
Original file line number Diff line number Diff line change
@@ -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
)
Loading