|
@@ -40,9 +40,13 @@ from vendor_path import setup_vendor_path
|
|
|
|
|
|
|
|
setup_vendor_path()
|
|
setup_vendor_path()
|
|
|
|
|
|
|
|
-from chattolib._pb.chatto.realtime.v1.events_pb2 import MessageMention
|
|
|
|
|
|
|
+from chattolib._pb.chatto.realtime.v1.events_pb2 import (
|
|
|
|
|
+ MessageMention,
|
|
|
|
|
+ PresenceChangedEvent,
|
|
|
|
|
+)
|
|
|
from chattolib.client import ChattoClient
|
|
from chattolib.client import ChattoClient
|
|
|
from chattolib.exceptions import ChattoConnectError, ChattoError
|
|
from chattolib.exceptions import ChattoConnectError, ChattoError
|
|
|
|
|
+from chattolib.realtime import RealtimeEvent
|
|
|
from chattolib.types import (
|
|
from chattolib.types import (
|
|
|
Asset,
|
|
Asset,
|
|
|
AssetUpload,
|
|
AssetUpload,
|
|
@@ -1278,10 +1282,24 @@ class TestReactionForwarding:
|
|
|
"""The wire carries the proto enum as a plain int (protobuf runtime
|
|
"""The wire carries the proto enum as a plain int (protobuf runtime
|
|
|
without native enums), so ``status`` has no ``.name`` attribute. A
|
|
without native enums), so ``status`` has no ``.name`` attribute. A
|
|
|
``.name`` read raised AttributeError on every presence change, and
|
|
``.name`` read raised AttributeError on every presence change, and
|
|
|
- each one cost a 30s reconnect gap that swallowed inbound messages."""
|
|
|
|
|
- event = self._event("presence_changed", actor_id="human-1")
|
|
|
|
|
- event.payload = MagicMock(spec=["status"])
|
|
|
|
|
- event.payload.status = 1 # PRESENCE_STATUS_ONLINE as a raw int
|
|
|
|
|
|
|
+ each one cost a 30s reconnect gap that swallowed inbound messages.
|
|
|
|
|
+
|
|
|
|
|
+ Both envelope and payload are real chattolib types here, not mocks
|
|
|
|
|
+ shaped like them: the earlier presence tests mocked ``status`` as a
|
|
|
|
|
+ StrEnum, which carries ``.name`` and so exercised a shape the wire
|
|
|
|
|
+ never sends.
|
|
|
|
|
+ """
|
|
|
|
|
+ payload = PresenceChangedEvent()
|
|
|
|
|
+ payload.status = 1 # PRESENCE_STATUS_ONLINE as a raw int
|
|
|
|
|
+ event = RealtimeEvent(
|
|
|
|
|
+ id="evt-presence-human-1",
|
|
|
|
|
+ created_at=None,
|
|
|
|
|
+ actor_id="human-1",
|
|
|
|
|
+ cursor=None,
|
|
|
|
|
+ kind="presence_changed",
|
|
|
|
|
+ payload=payload,
|
|
|
|
|
+ raw=None,
|
|
|
|
|
+ )
|
|
|
adapter._user_cache["human-1"] = _make_user("human-1", "human")
|
|
adapter._user_cache["human-1"] = _make_user("human-1", "human")
|
|
|
|
|
|
|
|
await adapter._handle_realtime_event(event)
|
|
await adapter._handle_realtime_event(event)
|
|
@@ -1399,8 +1417,6 @@ class TestRealtimeResume:
|
|
|
the socket was down."""
|
|
the socket was down."""
|
|
|
|
|
|
|
|
def _event(self, cursor):
|
|
def _event(self, cursor):
|
|
|
- from chattolib.realtime import RealtimeEvent
|
|
|
|
|
-
|
|
|
|
|
return RealtimeEvent(
|
|
return RealtimeEvent(
|
|
|
id=f"evt-{cursor}",
|
|
id=f"evt-{cursor}",
|
|
|
created_at=None,
|
|
created_at=None,
|