Coverage for functions \ flipdare \ util \ mail_reply_type.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-05-08 12:22 +1000

1#!/usr/bin/env python 

2# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved. 

3# 

4# This file is part of Flipdare's proprietary software and contains 

5# confidential and copyrighted material. Unauthorised copying, 

6# modification, distribution, or use of this file is strictly 

7# prohibited without prior written permission from Flipdare Pty Ltd. 

8# 

9# This software includes third-party components licensed under MIT, 

10# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details. 

11# 

12 

13from email.utils import formataddr 

14from enum import StrEnum 

15from typing import Self 

16 

17from flipdare.constants import ( 

18 DEF_MAIL_FROM, 

19 DEF_MAIL_FROM_LABEL, 

20 DEF_MAIL_SUPPORT, 

21 DEF_MAIL_SUPPORT_LABEL, 

22 DEF_NO_REPLY_EMAIL, 

23 DEF_NO_REPLY_LABEL, 

24) 

25 

26__all__ = ["MailReplyType"] 

27 

28 

29class MailReplyType(StrEnum): 

30 _email: str 

31 _label: str 

32 

33 SUPPORT = ("support", DEF_MAIL_SUPPORT, DEF_MAIL_SUPPORT_LABEL) 

34 NO_REPLY = ("no_reply", DEF_NO_REPLY_EMAIL, DEF_NO_REPLY_LABEL) 

35 ADMIN = ("admin", DEF_MAIL_FROM, DEF_MAIL_FROM_LABEL) 

36 

37 def __new__(cls, value: str, email: str, label: str) -> Self: 

38 obj = str.__new__(cls, value) 

39 obj._value_ = value 

40 obj._email = email 

41 obj._label = label 

42 return obj 

43 

44 @property 

45 def email(self) -> str: 

46 return self._email 

47 

48 @property 

49 def label(self) -> str: 

50 return self._label 

51 

52 @property 

53 def formatted(self) -> str: 

54 return formataddr((self._label, self._email))