Coverage for kwai/core/mail/message.py: 100%
8 statements
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
1"""Module that defines an interface for a mail message."""
2from abc import abstractmethod
4from .recipient import Recipients
7class Message:
8 """Interface for an immutable message."""
10 @property
11 @abstractmethod
12 def recipients(self) -> Recipients:
13 """Returns the recipients for the message."""
14 raise NotImplementedError
16 @abstractmethod
17 def with_recipients(self, recipients: Recipients) -> "Message":
18 """Set the recipients for the message.
20 This method must return a new Message instance.
21 """
22 raise NotImplementedError
24 @property
25 @abstractmethod
26 def subject(self) -> str:
27 """Return the subject of the message."""
28 raise NotImplementedError
30 @abstractmethod
31 def with_subject(self, subject: str) -> "Message":
32 """Set the subject for the message.
34 This method must return a new Message instance.
35 """
36 raise NotImplementedError
38 @property
39 @abstractmethod
40 def headers(self) -> dict[str, str]:
41 """Returns the headers for this message."""
42 raise NotImplementedError
44 @abstractmethod
45 def with_headers(self, headers: dict[str, str]) -> "Message":
46 """Set the headers for the message.
48 This method must return a new Message instance.
49 """
50 raise NotImplementedError
52 @property
53 @abstractmethod
54 def html(self) -> str | None:
55 """Returns the HTML for the message."""
56 raise NotImplementedError
58 @abstractmethod
59 def with_html(self, html: str) -> "Message":
60 """Set the HTML for the message.
62 This method must return a new Message instance.
63 """
64 raise NotImplementedError
66 @property
67 @abstractmethod
68 def text(self) -> str | None:
69 """Return the text for the message."""
70 raise NotImplementedError
72 @abstractmethod
73 def with_text(self, text: str) -> "Message":
74 """Set the text for the message.
76 This method must return a new Message instance.
77 """
78 raise NotImplementedError