Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions tests/hermes_cli/test_kanban_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ async def test_gateway_create_autosubscribes_on_explicit_board(kanban_home):


@pytest.mark.asyncio
async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path):
async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path, monkeypatch):
"""When a completed event carries ``artifacts`` in its payload, the
notifier uploads each file to the subscribed chat as a native
attachment. Images batch through send_multiple_images; documents
Expand All @@ -494,6 +494,13 @@ async def test_notifier_uploads_artifacts_on_completion(kanban_home, tmp_path):
from gateway.config import Platform
from tools import kanban_tools as kt

# ``_deliver_kanban_artifacts`` routes candidates through
# ``BasePlatformAdapter.filter_local_delivery_paths``, which only accepts
# paths under ``MEDIA_DELIVERY_SAFE_ROOTS`` or roots explicitly allowlisted
# via ``HERMES_MEDIA_ALLOW_DIRS``. Test fixtures live under ``tmp_path``,
# so allowlist it for the duration of the test.
monkeypatch.setenv("HERMES_MEDIA_ALLOW_DIRS", str(tmp_path))

# Materialize real files so os.path.isfile passes inside the helper.
chart_path = tmp_path / "q3-revenue.png"
chart_path.write_bytes(b"PNG-fake-bytes")
Expand Down Expand Up @@ -572,7 +579,7 @@ async def _fast_sleep(_):


@pytest.mark.asyncio
async def test_notifier_artifact_delivery_skips_missing_files(kanban_home, tmp_path):
async def test_notifier_artifact_delivery_skips_missing_files(kanban_home, tmp_path, monkeypatch):
"""Missing artifact paths are silently skipped — they may have been
referenced by name only. The notifier must not crash and must still
deliver any artifacts that do exist."""
Expand All @@ -581,6 +588,10 @@ async def test_notifier_artifact_delivery_skips_missing_files(kanban_home, tmp_p
from gateway.config import Platform
from tools import kanban_tools as kt

# Allow ``tmp_path`` through the media-delivery safety filter. See the
# companion test for the full explanation.
monkeypatch.setenv("HERMES_MEDIA_ALLOW_DIRS", str(tmp_path))

real_pdf = tmp_path / "real.pdf"
real_pdf.write_bytes(b"%PDF-fake")

Expand Down
Loading