Coverage for app / backend / src / couchers / notifications / utils.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-19 14:14 +0000

1from couchers.models import NotificationTopicAction 

2from couchers.notifications.locales import get_notifs_i18next 

3 

4enum_from_topic_action: dict[tuple[str, str], NotificationTopicAction] = { 

5 (item.topic, item.action): item for item in NotificationTopicAction 

6} 

7 

8 

9_DELETED_USER_NOTIFICATIONS = { 

10 NotificationTopicAction.account_deletion__start, 

11 NotificationTopicAction.account_deletion__complete, 

12 NotificationTopicAction.account_deletion__recovered, 

13} 

14 

15 

16def can_notify_deleted_user(topic_action: NotificationTopicAction) -> bool: 

17 return topic_action in _DELETED_USER_NOTIFICATIONS 

18 

19 

20def get_topic_action_description(topic_action: NotificationTopicAction, locale: str) -> str: 

21 description_key = f"topic_action_descriptions.{topic_action.topic}.{topic_action.action}" 

22 return get_notifs_i18next().localize(description_key, locale)