Skip to content
Open
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
15 changes: 15 additions & 0 deletions scripts/ci_tests/dbt_metricflow_package_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from pathlib import Path
from typing import Optional

from dbt_metricflow.cli.cli_configuration import CLIConfiguration


def _run_shell_command(command: str, cwd: Optional[Path] = None) -> None:
if cwd is None:
Expand Down Expand Up @@ -37,3 +39,16 @@ def _run_shell_command(command: str, cwd: Optional[Path] = None) -> None:
"mf query --metrics transactions --group-by metric_time --order metric_time",
cwd=tutorial_directory,
)

# Check that log messages are written as spected to the log file.
log_file_path = tutorial_directory.joinpath("logs", CLIConfiguration.LOG_FILE_NAME)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"logs" is a magic string. Is there no constant for that path location name?

assert log_file_path.exists(), f"Log file not present at expected location: {str(log_file_path)}"

with open(tutorial_directory.joinpath("logs", CLIConfiguration.LOG_FILE_NAME)) as fp:
log_file_contents = fp.read()

assert CLIConfiguration.LOG_FILE_NAME in log_file_contents, (
f"Log file ({log_file_path}) is missing message indicating logging has been set up."
f"\nLog file contents:"
f"\n{textwrap.indent(log_file_contents, prefix=' ')}"
)