From 6fccfe84eaf61ae278b18b0fe29b62c239bf1001 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Thu, 21 Nov 2024 17:33:45 +0100 Subject: [PATCH] Fix plural of "partial success" (#11002) --- .../unreleased/Fixes-20241114-170328.yaml | 6 ++++ core/dbt/events/types.py | 2 +- .../functional/microbatch/test_microbatch.py | 4 +-- tests/unit/test_events.py | 31 +++++++++++++------ 4 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 .changes/unreleased/Fixes-20241114-170328.yaml diff --git a/.changes/unreleased/Fixes-20241114-170328.yaml b/.changes/unreleased/Fixes-20241114-170328.yaml new file mode 100644 index 00000000000..3d1546cc594 --- /dev/null +++ b/.changes/unreleased/Fixes-20241114-170328.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix plural of 'partial success' in log message +time: 2024-11-14T17:03:28.888232+01:00 +custom: + Author: jtcohen6 + Issue: "10999" diff --git a/core/dbt/events/types.py b/core/dbt/events/types.py index 6cb9b688484..85d2df355ae 100644 --- a/core/dbt/events/types.py +++ b/core/dbt/events/types.py @@ -1941,7 +1941,7 @@ def code(self) -> str: def message(self) -> str: error_plural = pluralize(self.num_errors, "error") warn_plural = pluralize(self.num_warnings, "warning") - partial_success_plural = pluralize(self.num_partial_success, "partial success") + partial_success_plural = f"""{self.num_partial_success} partial {"success" if self.num_partial_success == 1 else "successes"}""" if self.keyboard_interrupt: message = yellow("Exited because of keyboard interrupt") diff --git a/tests/functional/microbatch/test_microbatch.py b/tests/functional/microbatch/test_microbatch.py index c9b9db2ff4e..e216bcbe772 100644 --- a/tests/functional/microbatch/test_microbatch.py +++ b/tests/functional/microbatch/test_microbatch.py @@ -620,7 +620,7 @@ def test_run_with_event_time(self, project): assert "PARTIAL SUCCESS" not in console_output assert "ERROR" in console_output - assert "Completed with 1 error, 0 partial successs, and 0 warnings" in console_output + assert "Completed with 1 error, 0 partial successes, and 0 warnings" in console_output self.assert_row_count(project, "microbatch_model", 2) @@ -629,7 +629,7 @@ def test_run_with_event_time(self, project): assert "PARTIAL SUCCESS" not in console_output assert "ERROR" in console_output - assert "Completed with 1 error, 0 partial successs, and 0 warnings" in console_output + assert "Completed with 1 error, 0 partial successes, and 0 warnings" in console_output self.assert_row_count(project, "microbatch_model", 2) diff --git a/tests/unit/test_events.py b/tests/unit/test_events.py index 038a228022c..e336ad139ff 100644 --- a/tests/unit/test_events.py +++ b/tests/unit/test_events.py @@ -18,8 +18,7 @@ TestLevel, WarnLevel, ) -from dbt.events.types import RunResultError -from dbt.task.printer import print_run_result_error +from dbt.task.printer import print_run_end_messages from dbt_common.events import types from dbt_common.events.base_types import msg_from_base_event from dbt_common.events.event_manager import EventManager, TestEventManager @@ -554,23 +553,37 @@ def test_single_run_error(): event_mgr = TestEventManager() ctx_set_event_manager(event_mgr) + class MockNode: + unique_id: str = "" + node_info = None + error_result = RunResult( status=RunStatus.Error, timing=[], thread_id="", execution_time=0.0, - node=None, + node=MockNode(), adapter_response=dict(), message="oh no!", failures=1, batch_results=None, ) - - print_run_result_error(error_result) - events = [e for e in event_mgr.event_history if isinstance(e[0], RunResultError)] - - assert len(events) == 1 - assert events[0][0].msg == "oh no!" + results = [error_result] + print_run_end_messages(results) + + summary_event = [ + e for e in event_mgr.event_history if isinstance(e[0], core_types.EndOfRunSummary) + ] + run_result_error_events = [ + e for e in event_mgr.event_history if isinstance(e[0], core_types.RunResultError) + ] + + # expect correct plural + assert "partial successes" in summary_event[0][0].message() + + # expect one error to show up + assert len(run_result_error_events) == 1 + assert run_result_error_events[0][0].msg == "oh no!" finally: # Set an empty event manager unconditionally on exit. This is an early