11from __future__ import annotations
22
33from datetime import UTC , datetime , timedelta , timezone
4+ from typing import TYPE_CHECKING
45
56import pytest
67from pydantic import ValidationError
1011except ImportError :
1112 pytest .skip ("files optional dependencies not installed" , allow_module_level = True )
1213
14+ if TYPE_CHECKING :
15+ from brussels .types .file .metadata import RemoteMetadataDict
16+
1317
1418def test_to_dict_and_from_dict_round_trip_with_aliases () -> None :
1519 created_at = datetime (2025 , 1 , 1 , 12 , 0 , tzinfo = UTC )
@@ -33,7 +37,7 @@ def test_to_dict_and_from_dict_round_trip_with_aliases() -> None:
3337
3438
3539def test_schema_alias_is_accepted_and_serialized () -> None :
36- data = {
40+ data : RemoteMetadataDict = {
3741 "schema" : 1 ,
3842 "key" : "alias/file.txt" ,
3943 "status" : "pending" ,
@@ -64,11 +68,13 @@ def test_datetime_fields_are_normalized_to_utc() -> None:
6468
6569def test_invalid_status_is_rejected () -> None :
6670 with pytest .raises (ValidationError , match = "status" ):
67- RemoteMetadata (
68- key = "example/file.txt" ,
69- status = "deleted" , # type: ignore[arg-type]
70- created_at = datetime (2025 , 1 , 1 , 12 , 0 , tzinfo = UTC ),
71- updated_at = datetime (2025 , 1 , 1 , 12 , 0 , tzinfo = UTC ),
71+ RemoteMetadata .model_validate (
72+ {
73+ "key" : "example/file.txt" ,
74+ "status" : "deleted" ,
75+ "created_at" : datetime (2025 , 1 , 1 , 12 , 0 , tzinfo = UTC ),
76+ "updated_at" : datetime (2025 , 1 , 1 , 12 , 0 , tzinfo = UTC ),
77+ },
7278 )
7379
7480
0 commit comments