Coverage for functions \ flipdare \ generated \ model \ notification_model.py: 100%
0 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
1#!/usr/bin/env python
2#
3# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
4#
5# This file is part of Flipdare's proprietary software and contains
6# confidential and copyrighted material. Unauthorised copying,
7# modification, distribution, or use of this file is strictly
8# prohibited without prior written permission from Flipdare Pty Ltd.
9#
10# This software includes third-party components licensed under MIT,
11# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
12#
13# NOTE: THIS FILE IS AUTO GENERATED. DO NOT EDIT.
14#
15# Generated by codegen_models.py
16#
17# Modify 'codegen_models.py'
18# and re-run the script above to update.
19#
20# pragma: no cover
21from __future__ import annotations
22from datetime import datetime
23from google.cloud.firestore_v1.transforms import Sentinel
24from flipdare.core.firestore_field import FirestoreField
25from flipdare.util.time_util import FirestoreTime
26from typing import Any, TypedDict, cast, Unpack
27from enum import StrEnum
28from pydantic import Field, ConfigDict, TypeAdapter
29from flipdare.firestore.core.app_base_model import AppBaseModel
30from flipdare.generated.shared.model.notification_type import NotificationType
31from flipdare.generated.shared.model.notification_status import NotificationStatus
32from flipdare.generated.shared.model.model_obj_type import ModelObjType
33from flipdare.generated.model.internal.video_model import VideoModel, VideoDict
34from flipdare.generated.model.internal.image_model import ImageModel, ImageDict
37class NotificationKeys(StrEnum):
38 ID = "id"
39 CREATED_AT = "created_at"
40 UPDATED_AT = "updated_at"
41 NOTIF_TYPE = "notif_type"
42 STATUS = "status"
43 FROM_UID = "from_uid"
44 TO_UID = "to_uid"
45 OBJ_TYPE = "obj_type"
46 OBJ_ID = "obj_id"
47 MESSAGE = "message"
48 VIDEO = "video"
49 IMAGE = "image"
50 VERSION = "version"
51 PROCESSED = "processed"
52 ERROR_COUNT = "error_count"
55# !! IMPORTANT !!
56# !!
57# !! this should only be used in the database to query.
58# !!
59class NotificationInternalKeys(StrEnum):
60 CREATED_AT = "created_at"
61 UPDATED_AT = "updated_at"
62 VERSION = "VERSION"
63 PROCESSED = "INT_P"
64 ERROR_COUNT = "INT_E"
67class NotificationModel(AppBaseModel):
68 """Represents a notification sent from one user to another, which can be associated with various objects such as dares, groups, or events."""
70 model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True)
72 id: str | None = Field(None, alias="id")
73 created_at: FirestoreField = Field(
74 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
75 )
76 updated_at: FirestoreField = Field(
77 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
78 )
79 notif_type: NotificationType
80 status: NotificationStatus = Field(default=NotificationStatus.UNREAD)
81 from_uid: str | None = None
82 to_uid: str
83 obj_type: ModelObjType
84 obj_id: str
85 message: str | None = None
86 video: VideoModel | None = None
87 image: ImageModel | None = None
88 # Version (base internal field)
89 version: int = Field(default=1, alias="VERSION")
90 # Processed (base internal field)
91 processed: bool = Field(default=False, alias="INT_P")
92 # Error Count (base internal field)
93 error_count: int = Field(default=0, alias="INT_E")
95 @classmethod
96 def validate_partial(cls, **data: Unpack[NotificationDict]) -> dict[str, Any]:
97 """
98 Uses Unpack to give you autocomplete and static warnings
99 if you pass an invalid key or type in your code.
101 Returns a dict with Firestore field names (aliases) for use with batch.update().
102 """
103 result: dict[str, Any] = {}
104 for k, v in data.items():
105 if k in cls.__pydantic_fields__:
106 field_info = cls.__pydantic_fields__[k]
107 validated_value = cast(
108 "Any",
109 TypeAdapter(field_info.annotation).validate_python(v),
110 )
111 # Use alias if defined, otherwise use field name
112 output_key = field_info.alias or k
113 result[output_key] = validated_value
114 return result
117NOTIFICATION_FIELD_NAMES: list[str] = list(NotificationModel.model_fields.keys())
120class NotificationDict(TypedDict, total=False):
121 id: str | None
122 created_at: Sentinel | datetime | str
123 updated_at: Sentinel | datetime | str
124 notif_type: NotificationType
125 status: NotificationStatus | None
126 from_uid: str | None
127 to_uid: str
128 obj_type: ModelObjType
129 obj_id: str
130 message: str | None
131 video: VideoDict | None
132 image: ImageDict | None
133 VERSION: int | None
134 INT_P: bool | None
135 INT_E: int | None