Coverage for functions \ flipdare \ generated \ model \ internal \ video_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.model.internal.stored_file_model import StoredFileModel, StoredFileDict 

31from flipdare.generated.model.internal.image_model import ImageModel, ImageDict 

32 

33 

34class VideoKeys(StrEnum): 

35 UPDATED_AT = "updated_at" 

36 CREATED_AT = "created_at" 

37 SOURCE = "source" 

38 W = "w" 

39 H = "h" 

40 SEC = "sec" 

41 LOW = "low" 

42 THUMBNAIL = "thumbnail" 

43 

44 

45# !! IMPORTANT !! 

46# !! 

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

48# !! 

49class VideoInternalKeys(StrEnum): 

50 UPDATED_AT = "updated_at" 

51 CREATED_AT = "created_at" 

52 

53 

54class VideoModel(AppBaseModel): 

55 """Represent a video with dimensions, a source file, and an optional thumbnail.""" 

56 

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

58 

59 updated_at: FirestoreField = Field( 

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

61 ) 

62 created_at: FirestoreField = Field( 

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

64 ) 

65 source: StoredFileModel 

66 w: int 

67 h: int 

68 sec: int 

69 low: StoredFileModel | None = None 

70 thumbnail: ImageModel | None = None 

71 

72 @classmethod 

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

74 """ 

75 Uses Unpack to give you autocomplete and static warnings 

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

77 

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

79 """ 

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

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

82 if k in cls.__pydantic_fields__: 

83 field_info = cls.__pydantic_fields__[k] 

84 validated_value = cast( 

85 "Any", 

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

87 ) 

88 # Use alias if defined, otherwise use field name 

89 output_key = field_info.alias or k 

90 result[output_key] = validated_value 

91 return result 

92 

93 

94VIDEO_FIELD_NAMES: list[str] = list(VideoModel.model_fields.keys()) 

95 

96 

97class VideoDict(TypedDict, total=False): 

98 updated_at: Sentinel | datetime | str 

99 created_at: Sentinel | datetime | str 

100 source: StoredFileDict 

101 w: int 

102 h: int 

103 sec: int 

104 low: StoredFileDict | None 

105 thumbnail: ImageDict | None