Coverage for functions \ flipdare \ generated \ schema \ error_schema.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 

21# pragma: no cover 

22 

23 

24from typing import TypedDict, NotRequired 

25from flipdare.generated.shared.app_log_category import AppLogCategory 

26from enum import StrEnum 

27from flipdare.error.app_error_protocol import AppErrorProtocol 

28from typing import TypeGuard, Any, Mapping 

29 

30 

31class ErrorKey(StrEnum): 

32 ENDPOINT = "endpoint" 

33 CODE = "code" 

34 CATEGORY = "category" 

35 TITLE = "title" 

36 MESSAGE = "message" 

37 CAUSE = "cause" 

38 

39 

40class ErrorSchema(TypedDict): 

41 """JSON body returned for all error responses.""" 

42 

43 endpoint: str 

44 code: AppErrorProtocol 

45 category: AppLogCategory 

46 title: str 

47 message: str 

48 cause: NotRequired[str] 

49 

50 

51# ---- Convenience predicates ----------------------------------------- 

52 

53 

54def is_error_schema(data: Mapping[str, Any]) -> TypeGuard[ErrorSchema]: 

55 required_keys = { 

56 ErrorKey.ENDPOINT.value, 

57 ErrorKey.CODE.value, 

58 ErrorKey.CATEGORY.value, 

59 ErrorKey.TITLE.value, 

60 ErrorKey.MESSAGE.value, 

61 } 

62 # Using issubset is often cleaner for checking multiple keys 

63 return required_keys.issubset(data.keys())