oclaw/tests/test_chat_attachments_payload.py
oliver 420abac9f1 refactor: root-package imports (svc/runtime/interfaces) and fix PYTHONPATH
- Rename platform/ to svc/ to avoid shadowing stdlib platform.
- Replace from oclaw.* with from svc/runtime/interfaces; update -m CLI paths.
- tests/conftest: prepend repo root to sys.path (no parent-folder package name).
- CI: paths and offline_eval script under repo root.
- Ops scripts: PYTHONPATH must be repo root for python -m runtime.* (fixes gateway/WhatsApp sidecar startup).
- Fix default oclaw.json path in tabular/file attachment limits; stabilize attachment test config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 14:51:17 +08:00

27 lines
910 B
Python

"""Regression: admin REST and WS share attachment normalization (typed refs must survive parsing)."""
from __future__ import annotations
from interfaces.admin.chat_api import _parse_attachments_payload
def test_parse_attachments_payload_preserves_image_ref() -> None:
att: dict = {"type": "image_ref", "attachment_id": "a" * 64, "mime": "image/png"}
out = _parse_attachments_payload([att])
assert out == [att]
def test_parse_attachments_payload_preserves_relay_pointer_image() -> None:
att: dict = {
"type": "relay_pointer",
"mime": "image/jpeg",
"attachment_id": "b" * 64,
"pointer_uri": "relay://attachments/x/" + "b" * 64,
}
out = _parse_attachments_payload([att])
assert out == [att]
def test_parse_attachments_payload_empty() -> None:
assert _parse_attachments_payload(None) is None
assert _parse_attachments_payload([]) is None