feat: define Channel Protocol for output channels (M10-U2)
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>
This commit is contained in:
27
pronote_sync/channels/protocol.py
Normal file
27
pronote_sync/channels/protocol.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""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
|
||||
"""
|
||||
...
|
||||
Reference in New Issue
Block a user