Coverage for functions \ flipdare \ generated \ model \ issue \ issue_comment_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.model.internal.image_model import ImageModel, ImageDict
31from flipdare.generated.model.internal.video_model import VideoModel, VideoDict
34class IssueCommentKeys(StrEnum):
35 ID = "id"
36 CREATED_AT = "created_at"
37 UPDATED_AT = "updated_at"
38 FROM_UID = "from_uid"
39 TO_UID = "to_uid"
40 IS_ADMIN = "is_admin"
41 MESSAGE = "message"
42 IMAGE = "image"
43 VIDEO = "video"
44 VERSION = "version"
45 PROCESSED = "processed"
46 ERROR_COUNT = "error_count"
49# !! IMPORTANT !!
50# !!
51# !! this should only be used in the database to query.
52# !!
53class IssueCommentInternalKeys(StrEnum):
54 CREATED_AT = "created_at"
55 UPDATED_AT = "updated_at"
56 VERSION = "VERSION"
57 PROCESSED = "INT_P"
58 ERROR_COUNT = "INT_E"
61class IssueCommentModel(AppBaseModel):
62 """Represents a comment made on an issue (has an id since its a sub-collection)"""
64 model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True)
66 id: str | None = Field(None, alias="id")
67 created_at: FirestoreField = Field(
68 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
69 )
70 updated_at: FirestoreField = Field(
71 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp())
72 )
73 from_uid: str
74 to_uid: str
75 is_admin: bool
76 message: str
77 image: ImageModel | None = None
78 video: VideoModel | None = None
79 # Version (base internal field)
80 version: int = Field(default=1, alias="VERSION")
81 # Processed (base internal field)
82 processed: bool = Field(default=False, alias="INT_P")
83 # Error Count (base internal field)
84 error_count: int = Field(default=0, alias="INT_E")
86 @classmethod
87 def validate_partial(cls, **data: Unpack[IssueCommentDict]) -> dict[str, Any]:
88 """
89 Uses Unpack to give you autocomplete and static warnings
90 if you pass an invalid key or type in your code.
92 Returns a dict with Firestore field names (aliases) for use with batch.update().
93 """
94 result: dict[str, Any] = {}
95 for k, v in data.items():
96 if k in cls.__pydantic_fields__:
97 field_info = cls.__pydantic_fields__[k]
98 validated_value = cast(
99 "Any",
100 TypeAdapter(field_info.annotation).validate_python(v),
101 )
102 # Use alias if defined, otherwise use field name
103 output_key = field_info.alias or k
104 result[output_key] = validated_value
105 return result
108ISSUECOMMENT_FIELD_NAMES: list[str] = list(IssueCommentModel.model_fields.keys())
111class IssueCommentDict(TypedDict, total=False):
112 id: str | None
113 created_at: Sentinel | datetime | str
114 updated_at: Sentinel | datetime | str
115 from_uid: str
116 to_uid: str
117 is_admin: bool
118 message: str
119 image: ImageDict | None
120 video: VideoDict | None
121 VERSION: int | None
122 INT_P: bool | None
123 INT_E: int | None