Files
GIA/core/tests/test_transport_capabilities.py

35 lines
1.0 KiB
Python

from asgiref.sync import async_to_sync
from django.test import SimpleTestCase
from core.clients import transport
from core.transports.capabilities import (
capability_snapshot,
supports,
unsupported_reason,
)
class TransportCapabilitiesTests(SimpleTestCase):
def test_signal_reactions_supported(self):
self.assertTrue(supports("signal", "reactions"))
def test_instagram_reactions_not_supported(self):
self.assertFalse(supports("instagram", "reactions"))
self.assertIn(
"instagram does not support reactions",
unsupported_reason("instagram", "reactions"),
)
def test_snapshot_has_schema_version(self):
snapshot = capability_snapshot()
self.assertIn("schema_version", snapshot)
self.assertIn("services", snapshot)
def test_transport_send_fails_fast_when_unsupported(self):
result = async_to_sync(transport.send_message_raw)(
"xmpp",
"person@example.com",
text="hello",
)
self.assertFalse(result)