28 lines
953 B
Python
28 lines
953 B
Python
"""Text-only messages retain lab3 behavior under the lab4 wire schema."""
|
|
|
|
import unittest
|
|
from datetime import datetime, timezone
|
|
from uuid import uuid4
|
|
|
|
from src.models import CreateMessage
|
|
from src.store import message_view
|
|
|
|
|
|
class Lab3CompatibilityTests(unittest.TestCase):
|
|
def test_missing_and_explicit_empty_attachments_are_equivalent(self):
|
|
missing = CreateMessage.model_validate({"text": "hello"})
|
|
explicit = CreateMessage.model_validate({"text": "hello", "attachment_ids": []})
|
|
self.assertEqual(missing, explicit)
|
|
self.assertEqual(missing.attachment_ids, [])
|
|
|
|
def test_text_message_response_has_empty_attachment_ids(self):
|
|
row = {
|
|
"id": uuid4(), "chat_id": uuid4(), "sender_id": uuid4(),
|
|
"text": "hello", "created_at": datetime.now(timezone.utc),
|
|
}
|
|
self.assertEqual(message_view(row)["attachment_ids"], [])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|