Skip to content

Commit

Permalink
changed HR formater to print Violations of all failing rules
Browse files Browse the repository at this point in the history
  • Loading branch information
thomend committed Oct 2, 2024
1 parent 16f8079 commit 321a846
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/dbt_score/formatters/human_readable_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def model_evaluated(
self._failed_models.append((model, score))
if (
score.value < self._config.fail_any_model_under
or score.value < self._config.fail_project_under
or any(isinstance(result, RuleViolation) for result in results.values())
or self._config.show_all
):
print(
Expand Down
17 changes: 14 additions & 3 deletions tests/formatters/test_human_readable_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ def test_human_readable_formatter_model(
}
formatter.model_evaluated(model1, results, Score(10.0, "🥇"))
stdout = capsys.readouterr().out
assert stdout == ""
assert (
stdout
== """🥇 \x1b[1mmodel1\x1b[0m (score: 10.0)
\x1b[1;31mERR \x1b[0m tests.conftest.rule_severity_medium: Oh noes
\x1b[1;33mWARN\x1b[0m (critical) tests.conftest.rule_severity_critical: Error
"""
)


def test_human_readable_formatter_model_show_all(
Expand Down Expand Up @@ -147,14 +154,18 @@ def test_human_readable_formatter_low_model_score(
)


def test_human_readable_formatter_low_project_score(
def test_human_readable_formatter_low_project_score_high_model_score(
capsys,
default_config,
manifest_loader,
model1,
rule_severity_critical,
):
"""Ensure the formatter has the correct output when the projet has a low score."""
"""Ensure the formatter has the correct output when the projet has a low score.
If model itself has a high project score then we need to pass `show_all` flag
to make it visible.
"""
default_config.overload({"show_all": True})
formatter = HumanReadableFormatter(
manifest_loader=manifest_loader, config=default_config
Expand Down

0 comments on commit 321a846

Please sign in to comment.