Coverage for functions \ flipdare \ mailer \ user \ flag_removed_email.py: 83%

30 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 

13 

14from typing import override 

15from flipdare.mailer._jinja_email_template import JinjaEmailTemplate 

16from flipdare.mailer.app_email_params import AppEmailParams 

17from flipdare.mailer.app_email_type import AppEmailType 

18from flipdare.generated.schema.email.body.user.flag_removed_email_schema import ( 

19 FlagRemovedEmailSchema, 

20) 

21from flipdare.wrapper import FlagWrapper, UserWrapper 

22 

23__all__ = ["FlagRemovedEmail"] 

24 

25 

26class FlagRemovedEmail(JinjaEmailTemplate[FlagRemovedEmailSchema]): 

27 

28 SCHEMA_CLASS = FlagRemovedEmailSchema 

29 

30 def __init__(self, flag: FlagWrapper, flagged_user: UserWrapper) -> None: 

31 data = FlagRemovedEmailSchema( 

32 { 

33 "to_name": flagged_user.model.safe_name, 

34 "obj_id": flag.slug_code, 

35 "obj_label": flag.flag_type.label, 

36 }, 

37 ) 

38 

39 email_type = AppEmailType.USR_FLAG_RESTRICTION_REMOVED 

40 super().__init__( 

41 data=data, 

42 params=AppEmailParams( 

43 email_type=email_type, 

44 schema=None, 

45 ), 

46 ) 

47 

48 @override 

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

50 return [] # no fields expected to have newlines, but can add if needed in the future 

51 

52 @property 

53 @override 

54 def data(self) -> FlagRemovedEmailSchema: 

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

56 return self._data 

57 

58 @property 

59 def to_name(self) -> str: 

60 return self.data["to_name"] 

61 

62 @property 

63 def obj_id(self) -> str: 

64 return self.data["obj_id"] 

65 

66 @property 

67 def obj_label(self) -> str: 

68 return self.data["obj_label"]