Migrate from Poetry and pyenv to uv

This commit is contained in:
2026-10-12 15:48:26 +02:00
parent c399a6aed3
commit c69f5f9166
93 changed files with 13068 additions and 2401 deletions
+30 -14
View File
@@ -1,4 +1,5 @@
"""Tests for the Jellyfin client + pool verification. Network is monkeypatched."""
from types import SimpleNamespace
import pytest
@@ -14,8 +15,9 @@ def _configured(monkeypatch):
def _resp(status=200, payload=None):
return SimpleNamespace(status_code=status, ok=(200 <= status < 300),
json=lambda: (payload or {}))
return SimpleNamespace(
status_code=status, ok=(200 <= status < 300), json=lambda: payload or {}
)
def test_base_url_strips_trailing_slash():
@@ -29,8 +31,9 @@ def test_api_available(monkeypatch):
def test_server_version(monkeypatch):
monkeypatch.setattr(jellyfin.requests, "request",
lambda *a, **k: _resp(200, {"Version": "10.9.11"}))
monkeypatch.setattr(
jellyfin.requests, "request", lambda *a, **k: _resp(200, {"Version": "10.9.11"})
)
assert jellyfin.server_version() == "10.9.11"
@@ -40,21 +43,32 @@ def test_scan_all_posts_refresh(monkeypatch):
def fake(method, url, **k):
seen["method"], seen["url"] = method, url
return _resp(200, {})
monkeypatch.setattr(jellyfin.requests, "request", fake)
jellyfin.scan_all()
assert seen["method"] == "POST" and seen["url"].endswith("/Library/Refresh")
def test_fetch_movies_maps_tmdb_id(monkeypatch):
payload = {"Items": [
{"Id": "a1", "Name": "Matrix", "ProductionYear": 1999,
"ProviderIds": {"Tmdb": "603"}, "Path": "/m/Matrix (1999) [tmdbid-603].mkv"},
{"Id": "a2", "Name": "Bez ID", "ProductionYear": 2000, "ProviderIds": {}},
]}
monkeypatch.setattr(jellyfin.requests, "request", lambda *a, **k: _resp(200, payload))
payload = {
"Items": [
{
"Id": "a1",
"Name": "Matrix",
"ProductionYear": 1999,
"ProviderIds": {"Tmdb": "603"},
"Path": "/m/Matrix (1999) [tmdbid-603].mkv",
},
{"Id": "a2", "Name": "Bez ID", "ProductionYear": 2000, "ProviderIds": {}},
]
}
monkeypatch.setattr(
jellyfin.requests, "request", lambda *a, **k: _resp(200, payload)
)
movies = jellyfin.fetch_movies()
assert movies[0] == JellyfinMovie("a1", "Matrix", 1999, 603,
"/m/Matrix (1999) [tmdbid-603].mkv")
assert movies[0] == JellyfinMovie(
"a1", "Matrix", 1999, 603, "/m/Matrix (1999) [tmdbid-603].mkv"
)
assert movies[1].tmdb_id is None
@@ -74,9 +88,11 @@ class TestVerifyAgainstJellyfin:
@pytest.fixture
def file_manager(self, tmp_path, monkeypatch):
import src.core.config as config_module
monkeypatch.setattr(config_module, "GLOBAL_CONFIG_FILE", tmp_path / ".gtag")
from src.core.tag_manager import TagManager
from src.core.file_manager import FileManager
from src.core.tag_manager import TagManager
fm = FileManager(TagManager())
fm.set_pool_dir(tmp_path / "pool")
return fm
@@ -88,7 +104,7 @@ class TestVerifyAgainstJellyfin:
file_manager.import_movie(tmp_path / "b.mkv", "Neznámý", year=2020) # no id
jf = [
JellyfinMovie("j1", "Matrix", 1999, 603, None), # matches a by tmdb
JellyfinMovie("j1", "Matrix", 1999, 603, None), # matches a by tmdb
JellyfinMovie("j2", "Cizí film", 2011, 999, None), # jellyfin-only
]
result = file_manager.verify_against_jellyfin(jf)