import logging

from app.core.logging_setup import ScrubbingFormatter


def test_scrubbing_formatter_redacts_identifiers_and_adds_blank_line() -> None:
    formatter = ScrubbingFormatter("%(levelname)s:%(name)s:%(message)s")
    record = logging.LogRecord(
        name="test.logger",
        level=logging.WARNING,
        pathname=__file__,
        lineno=1,
        msg="router decision: task_id=task-1 dialog_session_id=dialog-1 graph_id=project_qa/context_retrieval",
        args=(),
        exc_info=None,
    )

    rendered = formatter.format(record)

    assert "task_id=<redacted>" in rendered
    assert "dialog_session_id=<redacted>" in rendered
    assert "graph_id=<redacted>" in rendered
    assert "task-1" not in rendered
    assert rendered.endswith("\n")
