Skip to content

Commit ddb0a92

Browse files
committed
/* PR_START p/fix_cli_logging 03 */ Add test to check CLI logging
1 parent adf7a46 commit ddb0a92

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

scripts/ci_tests/dbt_metricflow_package_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from pathlib import Path
66
from typing import Optional
77

8+
from dbt_metricflow.cli.cli_configuration import CLIConfiguration
9+
810

911
def _run_shell_command(command: str, cwd: Optional[Path] = None) -> None:
1012
if cwd is None:
@@ -37,3 +39,16 @@ def _run_shell_command(command: str, cwd: Optional[Path] = None) -> None:
3739
"mf query --metrics transactions --group-by metric_time --order metric_time",
3840
cwd=tutorial_directory,
3941
)
42+
43+
# Check that log messages are written as spected to the log file.
44+
log_file_path = tutorial_directory.joinpath("logs", CLIConfiguration.LOG_FILE_NAME)
45+
assert log_file_path.exists(), f"Log file not present at expected location: {str(log_file_path)}"
46+
47+
with open(tutorial_directory.joinpath("logs", CLIConfiguration.LOG_FILE_NAME)) as fp:
48+
log_file_contents = fp.read()
49+
50+
assert CLIConfiguration.LOG_FILE_NAME in log_file_contents, (
51+
f"Log file ({log_file_path}) is missing message indicating logging has been set up."
52+
f"\nLog file contents:"
53+
f"\n{textwrap.indent(log_file_contents, prefix=' ')}"
54+
)

0 commit comments

Comments
 (0)