from __future__ import annotations

import logging

from src.core.logging import SensitiveURLRedactionFilter


def test_sensitive_url_redaction_filter_redacts_log_record_args() -> None:
    record = logging.LogRecord(
        name="httpx",
        level=logging.INFO,
        pathname=__file__,
        lineno=1,
        msg="HTTP Request: %s",
        args=("https://api.telegram.org/bot123456:SECRET/getWebhookInfo",),
        exc_info=None,
    )

    assert SensitiveURLRedactionFilter().filter(record) is True

    rendered = record.getMessage()
    assert "SECRET" not in rendered
    assert "bot<redacted>" in rendered
