Skip to content

Commit

Permalink
Fix plural of "partial success" (#11002)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtcohen6 authored Nov 21, 2024
1 parent fd6ec71 commit 6fccfe8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241114-170328.yaml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/microbatch/test_microbatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
31 changes: 22 additions & 9 deletions tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6fccfe8

Please sign in to comment.