Coverage for functions \ flipdare \ generated \ model \ backend \ metric \ outcome_metric.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 typing import Any, TypedDict, cast, Unpack 

23from enum import StrEnum 

24from pydantic import ConfigDict, TypeAdapter 

25from flipdare.firestore.core.app_base_model import AppBaseModel 

26 

27 

28class OutcomeMetricKeys(StrEnum): 

29 SUCCEEDED = "succeeded" 

30 DURATION = "duration" 

31 

32 

33class OutcomeMetric(AppBaseModel): 

34 """Outcome metric.""" 

35 

36 model_config = ConfigDict(populate_by_name=True) 

37 

38 succeeded: bool 

39 duration: int 

40 

41 @classmethod 

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

43 """ 

44 Uses Unpack to give you autocomplete and static warnings 

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

46 

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

48 """ 

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

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

51 if k in cls.__pydantic_fields__: 

52 field_info = cls.__pydantic_fields__[k] 

53 validated_value = cast( 

54 "Any", 

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

56 ) 

57 # Use alias if defined, otherwise use field name 

58 output_key = field_info.alias or k 

59 result[output_key] = validated_value 

60 return result 

61 

62 

63OUTCOMEMETRIC_FIELD_NAMES: list[str] = list(OutcomeMetric.model_fields.keys()) 

64 

65 

66class OutcomeMetricDict(TypedDict, total=False): 

67 succeeded: bool 

68 duration: int