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

1"""Module that defines an interface for a mail message.""" 

2from abc import abstractmethod 

3 

4from .recipient import Recipients 

5 

6 

7class Message: 

8 """Interface for an immutable message.""" 

9 

10 @property 

11 @abstractmethod 

12 def recipients(self) -> Recipients: 

13 """Returns the recipients for the message.""" 

14 raise NotImplementedError 

15 

16 @abstractmethod 

17 def with_recipients(self, recipients: Recipients) -> "Message": 

18 """Set the recipients for the message. 

19 

20 This method must return a new Message instance. 

21 """ 

22 raise NotImplementedError 

23 

24 @property 

25 @abstractmethod 

26 def subject(self) -> str: 

27 """Return the subject of the message.""" 

28 raise NotImplementedError 

29 

30 @abstractmethod 

31 def with_subject(self, subject: str) -> "Message": 

32 """Set the subject for the message. 

33 

34 This method must return a new Message instance. 

35 """ 

36 raise NotImplementedError 

37 

38 @property 

39 @abstractmethod 

40 def headers(self) -> dict[str, str]: 

41 """Returns the headers for this message.""" 

42 raise NotImplementedError 

43 

44 @abstractmethod 

45 def with_headers(self, headers: dict[str, str]) -> "Message": 

46 """Set the headers for the message. 

47 

48 This method must return a new Message instance. 

49 """ 

50 raise NotImplementedError 

51 

52 @property 

53 @abstractmethod 

54 def html(self) -> str | None: 

55 """Returns the HTML for the message.""" 

56 raise NotImplementedError 

57 

58 @abstractmethod 

59 def with_html(self, html: str) -> "Message": 

60 """Set the HTML for the message. 

61 

62 This method must return a new Message instance. 

63 """ 

64 raise NotImplementedError 

65 

66 @property 

67 @abstractmethod 

68 def text(self) -> str | None: 

69 """Return the text for the message.""" 

70 raise NotImplementedError 

71 

72 @abstractmethod 

73 def with_text(self, text: str) -> "Message": 

74 """Set the text for the message. 

75 

76 This method must return a new Message instance. 

77 """ 

78 raise NotImplementedError