Coverage for functions \ flipdare \ mailer \ admin \ app_contact_email.py: 83%

29 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 typing import override 

14from flipdare.mailer._jinja_email_template import JinjaEmailTemplate 

15from flipdare.mailer.app_email_params import AppEmailParams 

16from flipdare.mailer.app_email_type import AppEmailType 

17from flipdare.generated.schema.email.body.admin.contact_email_schema import ContactEmailSchema 

18from flipdare.generated.schema.email.subject.admin.contact_subject_schema import ( 

19 ContactSubjectSchema, 

20) 

21 

22__all__ = ["AppContactEmail"] 

23 

24 

25class AppContactEmail(JinjaEmailTemplate[ContactEmailSchema]): 

26 SCHEMA_CLASS = ContactEmailSchema 

27 

28 def __init__(self, from_email: str, from_subject: str, message: str) -> None: 

29 data = ContactEmailSchema( 

30 message=message, 

31 from_email=from_email, 

32 subject=from_subject, 

33 ) 

34 super().__init__( 

35 data=data, 

36 params=AppEmailParams( 

37 email_type=AppEmailType.ADM_CONTACT, 

38 schema=ContactSubjectSchema( 

39 email=from_email, 

40 label=from_subject, 

41 ), 

42 ), 

43 ) 

44 

45 @property 

46 @override 

47 def data(self) -> ContactEmailSchema: 

48 assert isinstance(self._data, dict) # narrowing, we known we have a dict.. 

49 return self._data 

50 

51 @override 

52 def newline_fields(self) -> list[str]: 

53 return ["message"] 

54 

55 @property 

56 def from_email(self) -> str: 

57 return self.data["from_email"] 

58 

59 @property 

60 def message(self) -> str: 

61 return self.data["message"] 

62 

63 @property 

64 def from_subject(self) -> str: 

65 return self.data["subject"]