|
8 | 8 | from contextlib import redirect_stdout |
9 | 9 |
|
10 | 10 | import pytest |
| 11 | +import typing_extensions as te |
11 | 12 |
|
12 | 13 | from vcspull.cli._colors import ColorMode, Colors |
13 | 14 | from vcspull.cli._output import ( |
|
21 | 22 | from vcspull.cli.sync import PlanProgressPrinter |
22 | 23 |
|
23 | 24 |
|
| 25 | +class PlanEntryKwargs(t.TypedDict): |
| 26 | + """Typed kwargs for PlanEntry construction in tests.""" |
| 27 | + |
| 28 | + name: str |
| 29 | + path: str |
| 30 | + workspace_root: str |
| 31 | + action: PlanAction |
| 32 | + detail: te.NotRequired[str] |
| 33 | + url: te.NotRequired[str] |
| 34 | + branch: te.NotRequired[str] |
| 35 | + remote_branch: te.NotRequired[str] |
| 36 | + current_rev: te.NotRequired[str] |
| 37 | + target_rev: te.NotRequired[str] |
| 38 | + ahead: te.NotRequired[int] |
| 39 | + behind: te.NotRequired[int] |
| 40 | + dirty: te.NotRequired[bool] |
| 41 | + error: te.NotRequired[str] |
| 42 | + diagnostics: te.NotRequired[list[str]] |
| 43 | + |
| 44 | + |
24 | 45 | class PlanEntryPayloadFixture(t.NamedTuple): |
25 | 46 | """Fixture for PlanEntry payload serialization.""" |
26 | 47 |
|
27 | 48 | test_id: str |
28 | | - kwargs: dict[str, t.Any] |
29 | | - expected_keys: dict[str, t.Any] |
| 49 | + kwargs: PlanEntryKwargs |
| 50 | + expected_keys: dict[str, object] |
30 | 51 | unexpected_keys: set[str] |
31 | 52 |
|
32 | 53 |
|
@@ -86,14 +107,14 @@ class PlanEntryPayloadFixture(t.NamedTuple): |
86 | 107 | ) |
87 | 108 | def test_plan_entry_to_payload( |
88 | 109 | test_id: str, |
89 | | - kwargs: dict[str, t.Any], |
90 | | - expected_keys: dict[str, t.Any], |
| 110 | + kwargs: PlanEntryKwargs, |
| 111 | + expected_keys: dict[str, object], |
91 | 112 | unexpected_keys: set[str], |
92 | 113 | ) -> None: |
93 | 114 | """Ensure PlanEntry serialises optional fields correctly.""" |
94 | 115 | entry = PlanEntry(**kwargs) |
95 | 116 | payload = entry.to_payload() |
96 | | - payload_map = t.cast(dict[str, t.Any], payload) |
| 117 | + payload_map = t.cast(dict[str, object], payload) |
97 | 118 |
|
98 | 119 | for key, value in expected_keys.items(): |
99 | 120 | assert payload_map[key] == value |
|
0 commit comments