Make the codebase mypy-clean, drop dead media_utils and Pillow, rewrite README

This commit is contained in:
2026-10-17 09:17:37 +02:00
parent 4daf4e960d
commit 364b515e3c
14 changed files with 333 additions and 436 deletions
-76
View File
@@ -1,76 +0,0 @@
import tempfile
import tkinter as tk
from pathlib import Path
import pytest
from PIL import Image, ImageTk
from src.core.media_utils import load_icon
@pytest.fixture(scope="module")
def tk_root():
"""Fixture pro inicializaci Tkinteru (nutné pro ImageTk)."""
root = tk.Tk()
yield root
root.destroy()
def test_load_icon_returns_photoimage(tk_root):
"""Test že load_icon vrací PhotoImage"""
# vytvoříme dočasný obrázek
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp:
tmp_path = Path(tmp.name)
try:
# vytvoříme 100x100 červený obrázek
img = Image.new("RGB", (100, 100), color="red")
img.save(tmp_path)
icon = load_icon(tmp_path)
# musí být PhotoImage
assert isinstance(icon, ImageTk.PhotoImage)
# ověříme velikost 16x16
assert icon.width() == 16
assert icon.height() == 16
finally:
tmp_path.unlink(missing_ok=True)
def test_load_icon_resizes_image(tk_root):
"""Test že load_icon správně změní velikost obrázku"""
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp:
tmp_path = Path(tmp.name)
try:
# vytvoříme velký obrázek 500x500
img = Image.new("RGB", (500, 500), color="blue")
img.save(tmp_path)
icon = load_icon(tmp_path)
# i velký obrázek by měl být zmenšen na 16x16
assert icon.width() == 16
assert icon.height() == 16
finally:
tmp_path.unlink(missing_ok=True)
def test_load_icon_different_formats(tk_root):
"""Test načítání různých formátů obrázků"""
formats = [".png", ".jpg", ".bmp"]
for fmt in formats:
with tempfile.NamedTemporaryFile(suffix=fmt, delete=False) as tmp:
tmp_path = Path(tmp.name)
try:
img = Image.new("RGB", (32, 32), color="green")
img.save(tmp_path)
icon = load_icon(tmp_path)
assert isinstance(icon, ImageTk.PhotoImage)
assert icon.width() == 16
assert icon.height() == 16
finally:
tmp_path.unlink(missing_ok=True)
+3 -2
View File
@@ -1,6 +1,7 @@
"""Tests for the movie object and the pool layout it derives (src.core.movie)."""
from pathlib import Path
from typing import Any
import pytest
@@ -79,8 +80,8 @@ class TestIdentityKey:
assert identity_key(None, "Nějaký film", None) == "name-nejaky-film"
def _movie(**kwargs) -> Movie:
base = {
def _movie(**kwargs: Any) -> Movie:
base: dict[str, Any] = {
"key": "tmdb-19995",
"title": "Avatar",
"year": "2009",