test(type_aliases): add red tests for 10 TypeAliases + FileItemsDiff NamedTuple
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
from __future__ import annotations
|
||||
from typing import Any, Callable, get_type_hints
|
||||
import pytest
|
||||
from src import type_aliases
|
||||
from src import result_types
|
||||
|
||||
|
||||
def test_metadata_alias_resolves_to_dict() -> None:
|
||||
hints = get_type_hints(type_aliases)
|
||||
assert hints["Metadata"] == dict[str, Any]
|
||||
|
||||
|
||||
def test_comms_log_entry_alias_resolves_to_metadata() -> None:
|
||||
hints = get_type_hints(type_aliases)
|
||||
assert hints["CommsLogEntry"] == dict[str, Any]
|
||||
|
||||
|
||||
def test_comms_log_alias_resolves_to_list_of_comms_log_entry() -> None:
|
||||
hints = get_type_hints(type_aliases)
|
||||
assert hints["CommsLog"] == list[dict[str, Any]]
|
||||
|
||||
|
||||
def test_history_alias_resolves_to_list_of_history_message() -> None:
|
||||
hints = get_type_hints(type_aliases)
|
||||
assert hints["History"] == list[dict[str, Any]]
|
||||
|
||||
|
||||
def test_file_items_alias_resolves_to_list_of_file_item() -> None:
|
||||
hints = get_type_hints(type_aliases)
|
||||
assert hints["FileItems"] == list[dict[str, Any]]
|
||||
|
||||
|
||||
def test_comms_log_callback_alias_resolves_to_callable() -> None:
|
||||
hints = get_type_hints(type_aliases)
|
||||
assert hints["CommsLogCallback"] == Callable[[dict[str, Any]], None]
|
||||
|
||||
|
||||
def test_file_items_diff_named_tuple_has_two_fields() -> None:
|
||||
assert hasattr(type_aliases, "FileItemsDiff")
|
||||
assert type_aliases.FileItemsDiff._fields == ("refreshed", "changed")
|
||||
hints = get_type_hints(type_aliases.FileItemsDiff)
|
||||
assert "refreshed" in hints
|
||||
assert "changed" in hints
|
||||
|
||||
|
||||
def test_result_with_file_items_alias_composes() -> None:
|
||||
r: result_types.Result[type_aliases.FileItems] = result_types.Result(data=[])
|
||||
assert r.ok is True
|
||||
assert isinstance(r.data, list)
|
||||
Reference in New Issue
Block a user