Squash of the 54 commits on victor-kyriazakos:feat/user-channel-warning-suppression (PR #112302, head f45c640e55) so the contributor's authorship survives a rebase-merge; the commits interleave with a cron delivery-ledger rework that the salvage removes in follow-up commits, so per-commit cherry-picks were not practical. Adds display.suppress_warning_notifications (global + per-platform, default false): one resolver (gateway/warning_notifications.py), BasePlatformAdapter.emit_warning / emit_media_warning / warning_text, a notification_category classification carried through wakes, queues and persistence, and render/present boundaries for CLI/TUI.
26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
"""UI sink gating never suppresses the producer or interprets its return value."""
|
|
import pytest
|
|
from gateway import warning_notifications as policy
|
|
|
|
|
|
@pytest.mark.parametrize("setting", [None, False, True])
|
|
@pytest.mark.parametrize("diagnostic", [False, True])
|
|
def test_render_notification_calls_renderer_only_when_visible(setting, diagnostic):
|
|
cfg = {} if setting is None else {"display": {"suppress_warning_notifications": setting}}
|
|
observed = ["producer ran"]
|
|
def renderer():
|
|
observed.append("rendered")
|
|
return False # not a delivery receipt
|
|
presented = policy.render_notification(renderer, platform="cli", user_config=cfg, diagnostic=diagnostic)
|
|
expected = not (diagnostic and setting is True)
|
|
assert presented is expected
|
|
assert observed == (["producer ran", "rendered"] if expected else ["producer ran"])
|
|
|
|
|
|
def test_render_failure_propagates_and_requested_result_does_not_read_policy(monkeypatch):
|
|
def fail():
|
|
raise RuntimeError("renderer failed")
|
|
monkeypatch.setattr(policy, "warning_notifications_enabled", lambda *a: pytest.fail("must not consult policy for result"))
|
|
with pytest.raises(RuntimeError, match="renderer failed"):
|
|
policy.render_notification(fail, platform="tui", diagnostic=False)
|