Coverage for functions \ flipdare \ generated \ model \ group_member_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.user.request_status import RequestStatus 

31from flipdare.generated.shared.model.group_member_type import GroupMemberType 

32 

33 

34class GroupMemberKeys(StrEnum): 

35 ID = "id" 

36 CREATED_AT = "created_at" 

37 UPDATED_AT = "updated_at" 

38 STATUS = "status" 

39 GID = "gid" 

40 UID = "uid" 

41 MEMBER_TYPE = "member_type" 

42 VERSION = "version" 

43 PROCESSED = "processed" 

44 ERROR_COUNT = "error_count" 

45 REQUEST_NOTIFICATION_SENT = "request_notification_sent" 

46 STATUS_NOTIFICATION_SENT = "status_notification_sent" 

47 

48 

49# !! IMPORTANT !! 

50# !! 

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

52# !! 

53class GroupMemberInternalKeys(StrEnum): 

54 CREATED_AT = "created_at" 

55 UPDATED_AT = "updated_at" 

56 VERSION = "VERSION" 

57 PROCESSED = "INT_P" 

58 ERROR_COUNT = "INT_E" 

59 REQUEST_NOTIFICATION_SENT = "INT_G_R" 

60 STATUS_NOTIFICATION_SENT = "INT_G_S" 

61 

62 

63class GroupMemberModel(AppBaseModel): 

64 """Represents a member of a group, including their role and status within the group.""" 

65 

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

67 

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

69 created_at: FirestoreField = Field( 

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

71 ) 

72 updated_at: FirestoreField = Field( 

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

74 ) 

75 status: RequestStatus = Field(default=RequestStatus.PENDING) 

76 gid: str 

77 uid: str 

78 member_type: GroupMemberType 

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") 

85 # Request Notification Sent (internal field) 

86 request_notification_sent: bool = Field(default=False, alias="INT_G_R") 

87 # Status Notification Sent (internal field) 

88 status_notification_sent: bool = Field(default=False, alias="INT_G_S") 

89 

90 @classmethod 

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

92 """ 

93 Uses Unpack to give you autocomplete and static warnings 

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

95 

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

97 """ 

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

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

100 if k in cls.__pydantic_fields__: 

101 field_info = cls.__pydantic_fields__[k] 

102 validated_value = cast( 

103 "Any", 

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

105 ) 

106 # Use alias if defined, otherwise use field name 

107 output_key = field_info.alias or k 

108 result[output_key] = validated_value 

109 return result 

110 

111 

112GROUPMEMBER_FIELD_NAMES: list[str] = list(GroupMemberModel.model_fields.keys()) 

113 

114 

115class GroupMemberDict(TypedDict, total=False): 

116 id: str | None 

117 created_at: Sentinel | datetime | str 

118 updated_at: Sentinel | datetime | str 

119 status: RequestStatus | None 

120 gid: str 

121 uid: str 

122 member_type: GroupMemberType 

123 VERSION: int | None 

124 INT_P: bool | None 

125 INT_E: int | None 

126 INT_G_R: bool | None 

127 INT_G_S: bool | None