From 90d8c57a0fc142e3df2363735762f48373640d47 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 21 Jun 2026 12:21:28 -0400 Subject: [PATCH] test(type_aliases): add red tests for 10 TypeAliases + FileItemsDiff NamedTuple --- tests/test_type_aliases.py | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/test_type_aliases.py diff --git a/tests/test_type_aliases.py b/tests/test_type_aliases.py new file mode 100644 index 00000000..67188949 --- /dev/null +++ b/tests/test_type_aliases.py @@ -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) \ No newline at end of file