Coverage for fastid / notify / repositories.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.13.1, created at 2026-10-18 16:37 +0000

1from typing import Any 

2 

3from fastid.database.repository import SQLAlchemyRepository 

4from fastid.database.specification import Specification 

5from fastid.notify.models import EmailTemplate, Notification, TelegramTemplate 

6 

7 

8class EmailTemplateRepository(SQLAlchemyRepository[EmailTemplate]): 

9 model_type = EmailTemplate 

10 

11 

12class EmailTemplateSlugSpecification(Specification): 

13 def __init__(self, slug: str) -> None: 

14 self.slug = slug 

15 

16 def apply(self, stmt: Any) -> Any: 

17 return stmt.where(EmailTemplate.slug == self.slug) 

18 

19 

20class TelegramTemplateRepository(SQLAlchemyRepository[TelegramTemplate]): 

21 model_type = TelegramTemplate 

22 

23 

24class TelegramTemplateSlugSpecification(Specification): 

25 def __init__(self, slug: str) -> None: 

26 self.slug = slug 

27 

28 def apply(self, stmt: Any) -> Any: 

29 return stmt.where(TelegramTemplate.slug == self.slug) 

30 

31 

32class NotificationRepository(SQLAlchemyRepository[Notification]): 

33 model_type = Notification