Coverage for functions \ flipdare \ generated \ model \ liked_model.py: 100%

0 statements  

« 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.model_obj_type import ModelObjType 

31 

32 

33class LikedKeys(StrEnum): 

34 ID = "id" 

35 CREATED_AT = "created_at" 

36 UPDATED_AT = "updated_at" 

37 FROM_UID = "from_uid" 

38 OBJ_ID = "obj_id" 

39 OBJ_TYPE = "obj_type" 

40 VERSION = "version" 

41 PROCESSED = "processed" 

42 ERROR_COUNT = "error_count" 

43 

44 

45# !! IMPORTANT !! 

46# !! 

47# !! this should only be used in the database to query. 

48# !! 

49class LikedInternalKeys(StrEnum): 

50 CREATED_AT = "created_at" 

51 UPDATED_AT = "updated_at" 

52 VERSION = "VERSION" 

53 PROCESSED = "INT_P" 

54 ERROR_COUNT = "INT_E" 

55 

56 

57class LikedModel(AppBaseModel): 

58 """Represents a like from a user on various objects in the system, such as dares, groups, or events.""" 

59 

60 model_config = ConfigDict(populate_by_name=True, arbitrary_types_allowed=True) 

61 

62 id: str | None = Field(None, alias="id") 

63 created_at: FirestoreField = Field( 

64 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp()) 

65 ) 

66 updated_at: FirestoreField = Field( 

67 default_factory=cast("Any", lambda: FirestoreTime.server_timestamp()) 

68 ) 

69 from_uid: str 

70 obj_id: str 

71 obj_type: ModelObjType 

72 # Version (base internal field) 

73 version: int = Field(default=1, alias="VERSION") 

74 # Processed (base internal field) 

75 processed: bool = Field(default=False, alias="INT_P") 

76 # Error Count (base internal field) 

77 error_count: int = Field(default=0, alias="INT_E") 

78 

79 @classmethod 

80 def validate_partial(cls, **data: Unpack[LikedDict]) -> dict[str, Any]: 

81 """ 

82 Uses Unpack to give you autocomplete and static warnings 

83 if you pass an invalid key or type in your code. 

84 

85 Returns a dict with Firestore field names (aliases) for use with batch.update(). 

86 """ 

87 result: dict[str, Any] = {} 

88 for k, v in data.items(): 

89 if k in cls.__pydantic_fields__: 

90 field_info = cls.__pydantic_fields__[k] 

91 validated_value = cast( 

92 "Any", 

93 TypeAdapter(field_info.annotation).validate_python(v), 

94 ) 

95 # Use alias if defined, otherwise use field name 

96 output_key = field_info.alias or k 

97 result[output_key] = validated_value 

98 return result 

99 

100 

101LIKED_FIELD_NAMES: list[str] = list(LikedModel.model_fields.keys()) 

102 

103 

104class LikedDict(TypedDict, total=False): 

105 id: str | None 

106 created_at: Sentinel | datetime | str 

107 updated_at: Sentinel | datetime | str 

108 from_uid: str 

109 obj_id: str 

110 obj_type: ModelObjType 

111 VERSION: int | None 

112 INT_P: bool | None 

113 INT_E: int | None