Coverage for functions \ flipdare \ mailer \ admin \ app_log_email.py: 90%

20 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.log_email_schema import LogEmailSchema 

18from flipdare.generated.schema.email.subject.admin.log_subject_schema import LogSubjectSchema 

19 

20__all__ = ["AppLogEmail"] 

21 

22 

23class AppLogEmail(JinjaEmailTemplate[LogEmailSchema]): 

24 __slots__ = ("_subject",) 

25 

26 SCHEMA_CLASS = LogEmailSchema 

27 

28 def __init__( 

29 self, 

30 data: LogEmailSchema, 

31 ) -> None: 

32 super().__init__( 

33 data=data, 

34 params=AppEmailParams( 

35 email_type=AppEmailType.ADM_APP_LOG, 

36 schema=LogSubjectSchema( 

37 log_type=data["log_type"].upper(), 

38 source=data["source"], 

39 ), 

40 ), 

41 ) 

42 

43 @override 

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

45 return ["message", "stack_trace"] 

46 

47 @property 

48 @override 

49 def data(self) -> LogEmailSchema: 

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

51 return self._data