test: model StubDownloads state with a dataclass
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import Any, cast
|
||||||
|
|
||||||
from auditui import table_utils
|
from auditui import table_utils
|
||||||
|
|
||||||
|
|
||||||
@@ -25,9 +28,9 @@ class StubLibrary:
|
|||||||
return item.get("asin")
|
return item.get("asin")
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(slots=True)
|
||||||
class StubDownloads:
|
class StubDownloads:
|
||||||
def __init__(self, cached: set[str]) -> None:
|
_cached: set[str]
|
||||||
self._cached = cached
|
|
||||||
|
|
||||||
def is_cached(self, asin: str) -> bool:
|
def is_cached(self, asin: str) -> bool:
|
||||||
return asin in self._cached
|
return asin in self._cached
|
||||||
@@ -63,7 +66,7 @@ def test_format_item_as_row_with_downloaded() -> None:
|
|||||||
"asin": "ASIN123",
|
"asin": "ASIN123",
|
||||||
}
|
}
|
||||||
title, author, runtime, progress, downloaded = table_utils.format_item_as_row(
|
title, author, runtime, progress, downloaded = table_utils.format_item_as_row(
|
||||||
item, library, downloads
|
item, library, cast(Any, downloads)
|
||||||
)
|
)
|
||||||
assert title == "Title"
|
assert title == "Title"
|
||||||
assert author == "Author One"
|
assert author == "Author One"
|
||||||
|
|||||||
Reference in New Issue
Block a user