Coverage for fastid / webhooks / repositories.py: 100%
14 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-10-18 16:37 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-10-18 16:37 +0000
1from typing import Any
3from fastid.database.repository import SQLAlchemyRepository
4from fastid.database.specification import Specification
5from fastid.database.utils import UUIDv7
6from fastid.webhooks.models import Webhook, WebhookEvent, WebhookType
9class WebhookRepository(SQLAlchemyRepository[Webhook]):
10 model_type = Webhook
13class WebhookTypeSpecification(Specification):
14 def __init__(self, webhook_type: WebhookType) -> None:
15 self.type = webhook_type
17 def apply(self, stmt: Any) -> Any:
18 return stmt.where(Webhook.type == self.type)
21class WebhookEventRepository(SQLAlchemyRepository[WebhookEvent]):
22 model_type = WebhookEvent
25class WebhookEventWebhookIDSpecification(Specification):
26 def __init__(self, webhook_id: UUIDv7) -> None:
27 self.webhook_id = webhook_id
29 def apply(self, stmt: Any) -> Any:
30 return stmt.where(WebhookEvent.webhook_id == self.webhook_id)