Coverage for polar/models/webhook_delivery.py: 87%
21 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 17:15 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 17:15 +0000
1from typing import TYPE_CHECKING 1ab
2from uuid import UUID 1ab
4from sqlalchemy import Boolean, ForeignKey, Integer, Text, Uuid 1ab
5from sqlalchemy.orm import Mapped, declared_attr, mapped_column, relationship 1ab
7from polar.kit.db.models.base import RecordModel 1ab
9if TYPE_CHECKING: 9 ↛ 10line 9 didn't jump to line 10 because the condition on line 9 was never true1ab
10 from .webhook_endpoint import WebhookEndpoint
11 from .webhook_event import WebhookEvent
14class WebhookDelivery(RecordModel): 1ab
15 __tablename__ = "webhook_deliveries" 1ab
17 webhook_endpoint_id: Mapped[UUID] = mapped_column( 1ab
18 Uuid,
19 ForeignKey("webhook_endpoints.id", ondelete="CASCADE"),
20 nullable=False,
21 index=True,
22 )
24 @declared_attr 1ab
25 def webhook_endpoint(cls) -> Mapped["WebhookEndpoint"]: 1ab
26 return relationship("WebhookEndpoint", lazy="raise") 1ab
28 webhook_event_id: Mapped[UUID] = mapped_column( 1ab
29 Uuid,
30 ForeignKey("webhook_events.id", ondelete="CASCADE"),
31 nullable=False,
32 index=True,
33 )
35 @declared_attr 1ab
36 def webhook_event(cls) -> Mapped["WebhookEvent"]: 1ab
37 return relationship("WebhookEvent", lazy="raise") 1ab
39 succeeded: Mapped[bool] = mapped_column(Boolean, nullable=False) 1ab
40 http_code: Mapped[int | None] = mapped_column(Integer, nullable=True) 1ab
41 response: Mapped[str | None] = mapped_column(Text, nullable=True) 1ab