Coverage for opt/mealie/lib/python3.12/site-packages/mealie/db/models/household/webhooks.py: 90%

25 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-11-25 17:29 +0000

1from datetime import UTC, datetime, time 1a

2from typing import TYPE_CHECKING, Optional 1a

3 

4from sqlalchemy import Boolean, ForeignKey, String, Time, orm 1a

5from sqlalchemy.orm import Mapped, mapped_column 1a

6 

7from .._model_base import BaseMixins, SqlAlchemyBase 1a

8from .._model_utils.auto_init import auto_init 1a

9from .._model_utils.guid import GUID 1a

10 

11if TYPE_CHECKING: 11 ↛ 12line 11 didn't jump to line 12 because the condition on line 11 was never true1a

12 from ..group import Group 

13 from .household import Household 

14 

15 

16class GroupWebhooksModel(SqlAlchemyBase, BaseMixins): 1a

17 __tablename__ = "webhook_urls" 1a

18 id: Mapped[GUID] = mapped_column(GUID, primary_key=True, default=GUID.generate) 1a

19 

20 group: Mapped[Optional["Group"]] = orm.relationship("Group", back_populates="webhooks", single_parent=True) 1a

21 group_id: Mapped[GUID | None] = mapped_column(GUID, ForeignKey("groups.id"), index=True) 1a

22 household: Mapped[Optional["Household"]] = orm.relationship( 1a

23 "Household", back_populates="webhooks", single_parent=True 

24 ) 

25 household_id: Mapped[GUID | None] = mapped_column(GUID, ForeignKey("households.id"), index=True) 1a

26 

27 enabled: Mapped[bool | None] = mapped_column(Boolean, default=False) 1a

28 name: Mapped[str | None] = mapped_column(String) 1a

29 url: Mapped[str | None] = mapped_column(String) 1a

30 

31 # New Fields 

32 webhook_type: Mapped[str | None] = mapped_column(String, default="") # Future use for different types of webhooks 1a

33 scheduled_time: Mapped[time | None] = mapped_column(Time, default=lambda: datetime.now(UTC).time()) 1a

34 

35 # Column is no longer used but is kept for since it's super annoying to 

36 # delete a column in SQLite and it's not a big deal to keep it around 

37 time: Mapped[str | None] = mapped_column(String, default="00:00") 1a

38 

39 @auto_init() 1a

40 def __init__(self, **_) -> None: ... 1abcdefghijklmnopqrstuvwxyzABCDEF