Add @runtime_checkable Channel Protocol with send(XmppMessage) -> bool as the structural contract for all output channels (XMPP, future CalDAV, etc). 6 unit tests covering protocol structure, conforming/non-conforming classes, method signature introspection, and bool return type. Co-authored-by: opencode/test-engineer <test-engineer@agents.invalid> Co-authored-by: opencode/coder <coder@agents.invalid>
28 lines
783 B
Python
28 lines
783 B
Python
"""Protocole abstrait définissant le contrat des canaux de sortie."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Protocol, runtime_checkable
|
|
|
|
from pronote_sync.models.xmpp import XmppMessage
|
|
|
|
|
|
@runtime_checkable
|
|
class Channel(Protocol):
|
|
"""Contrat structurel d'un canal de sortie du pipeline.
|
|
|
|
Un canal de sortie reçoit un message final :class:`XmppMessage` et tente de
|
|
l'envoyer vers la destination qu'il représente (CalDAV, XMPP, etc.).
|
|
|
|
:ivar send: Envoie un message sur le canal.
|
|
"""
|
|
|
|
def send(self, message: XmppMessage) -> bool:
|
|
"""Envoie un message sur le canal.
|
|
|
|
:param message: Message final à transmettre.
|
|
:return: ``True`` si l'envoi a réussi, ``False`` sinon.
|
|
:rtype: bool
|
|
"""
|
|
...
|