Coverage for src/kwai/core/mail/message.py: 100%
3 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module that defines an interface for a mail message."""
3from abc import abstractmethod
5from .recipient import Recipients
8class Message:
9 """Interface for an immutable message."""
11 @property
12 @abstractmethod
13 def recipients(self) -> Recipients:
14 """Returns the recipients for the message."""
15 raise NotImplementedError
17 @abstractmethod
18 def with_recipients(self, recipients: Recipients) -> "Message":
19 """Set the recipients for the message.
21 This method must return a new Message instance.
22 """
23 raise NotImplementedError
25 @property
26 @abstractmethod
27 def subject(self) -> str:
28 """Return the subject of the message."""
29 raise NotImplementedError
31 @abstractmethod
32 def with_subject(self, subject: str) -> "Message":
33 """Set the subject for the message.
35 This method must return a new Message instance.
36 """
37 raise NotImplementedError
39 @property
40 @abstractmethod
41 def headers(self) -> dict[str, str]:
42 """Returns the headers for this message."""
43 raise NotImplementedError
45 @abstractmethod
46 def with_headers(self, headers: dict[str, str]) -> "Message":
47 """Set the headers for the message.
49 This method must return a new Message instance.
50 """
51 raise NotImplementedError
53 @property
54 @abstractmethod
55 def html(self) -> str | None:
56 """Returns the HTML for the message."""
57 raise NotImplementedError
59 @abstractmethod
60 def with_html(self, html: str) -> "Message":
61 """Set the HTML for the message.
63 This method must return a new Message instance.
64 """
65 raise NotImplementedError
67 @property
68 @abstractmethod
69 def text(self) -> str | None:
70 """Return the text for the message."""
71 raise NotImplementedError
73 @abstractmethod
74 def with_text(self, text: str) -> "Message":
75 """Set the text for the message.
77 This method must return a new Message instance.
78 """
79 raise NotImplementedError