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

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

2 

3from abc import abstractmethod 

4 

5from .recipient import Recipients 

6 

7 

8class Message: 

9 """Interface for an immutable message.""" 

10 

11 @property 

12 @abstractmethod 

13 def recipients(self) -> Recipients: 

14 """Returns the recipients for the message.""" 

15 raise NotImplementedError 

16 

17 @abstractmethod 

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

19 """Set the recipients for the message. 

20 

21 This method must return a new Message instance. 

22 """ 

23 raise NotImplementedError 

24 

25 @property 

26 @abstractmethod 

27 def subject(self) -> str: 

28 """Return the subject of the message.""" 

29 raise NotImplementedError 

30 

31 @abstractmethod 

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

33 """Set the subject for the message. 

34 

35 This method must return a new Message instance. 

36 """ 

37 raise NotImplementedError 

38 

39 @property 

40 @abstractmethod 

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

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

43 raise NotImplementedError 

44 

45 @abstractmethod 

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

47 """Set the headers for the message. 

48 

49 This method must return a new Message instance. 

50 """ 

51 raise NotImplementedError 

52 

53 @property 

54 @abstractmethod 

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

56 """Returns the HTML for the message.""" 

57 raise NotImplementedError 

58 

59 @abstractmethod 

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

61 """Set the HTML for the message. 

62 

63 This method must return a new Message instance. 

64 """ 

65 raise NotImplementedError 

66 

67 @property 

68 @abstractmethod 

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

70 """Return the text for the message.""" 

71 raise NotImplementedError 

72 

73 @abstractmethod 

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

75 """Set the text for the message. 

76 

77 This method must return a new Message instance. 

78 """ 

79 raise NotImplementedError