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
+55 -24
View File
@@ -1,7 +1,7 @@
import json
from src.core.pool_index import PoolIndex, INDEX_FILENAME, INDEX_VERSION
from src.core.file import File
from src.core.pool_index import INDEX_FILENAME, INDEX_VERSION, PoolIndex
from src.core.tag_manager import TagManager
@@ -53,9 +53,13 @@ class TestPoolIndex:
def test_find_movie_by_media(self, tmp_path):
index = PoolIndex(tmp_path)
index.set_movie("tmdb-603", {
"title": "Matrix",
"media": [{"role": "video", "label": "", "file": "Filmy/Matrix.mkv"}]})
index.set_movie(
"tmdb-603",
{
"title": "Matrix",
"media": [{"role": "video", "label": "", "file": "Filmy/Matrix.mkv"}],
},
)
found = index.find_movie_by_media(tmp_path / "Filmy" / "Matrix.mkv")
assert found is not None
@@ -76,16 +80,23 @@ class TestV1Migration:
def _write_v1(self, tmp_path, movies: dict) -> None:
(tmp_path / INDEX_FILENAME).write_text(
json.dumps({"settings": {"tag_schema": []}, "movies": movies}),
encoding="utf-8")
encoding="utf-8",
)
def test_flat_movie_becomes_identity_keyed_record(self, tmp_path):
self._write_v1(tmp_path, {
"Filmy/Matrix (1999) [tmdbid-603].mkv": {
"title": "Matrix", "tags": ["Žánr/Akční"],
"csfd_url": "https://www.csfd.cz/film/9499/",
"date": "1999-03-31", "added": "2026-01-01T00:00:00",
"attributes": {"collection_sort": "01"},
}})
self._write_v1(
tmp_path,
{
"Filmy/Matrix (1999) [tmdbid-603].mkv": {
"title": "Matrix",
"tags": ["Žánr/Akční"],
"csfd_url": "https://www.csfd.cz/film/9499/",
"date": "1999-03-31",
"added": "2026-01-01T00:00:00",
"attributes": {"collection_sort": "01"},
}
},
)
index = PoolIndex(tmp_path)
@@ -96,18 +107,29 @@ class TestV1Migration:
assert record["tmdb_id"] == 603
assert record["library"] == "Filmy"
assert record["media"] == [
{"role": "video", "label": "",
"file": "Filmy/Matrix (1999) [tmdbid-603].mkv"}]
{
"role": "video",
"label": "",
"file": "Filmy/Matrix (1999) [tmdbid-603].mkv",
}
]
assert record["tags"] == ["Žánr/Akční"]
assert record["csfd_url"] == "https://www.csfd.cz/film/9499/"
assert record["attributes"] == {"collection_sort": "01"}
def test_grouped_versions_merge_into_one_record(self, tmp_path):
base = "Filmy/Avatar (2009) [tmdbid-19995]"
self._write_v1(tmp_path, {
f"{base}/Avatar (2009) [tmdbid-19995] - Výchozí.mkv": {"title": "Avatar"},
f"{base}/Avatar (2009) [tmdbid-19995] - 3D HSBS.mkv": {"title": "Avatar"},
})
self._write_v1(
tmp_path,
{
f"{base}/Avatar (2009) [tmdbid-19995] - Výchozí.mkv": {
"title": "Avatar"
},
f"{base}/Avatar (2009) [tmdbid-19995] - 3D HSBS.mkv": {
"title": "Avatar"
},
},
)
index = PoolIndex(tmp_path)
@@ -117,8 +139,7 @@ class TestV1Migration:
assert record["library"] == "Filmy"
def test_movie_without_tmdbid_gets_slug_key(self, tmp_path):
self._write_v1(tmp_path, {
"Filmy/Pelíšky (1999).mkv": {"title": "Pelíšky"}})
self._write_v1(tmp_path, {"Filmy/Pelíšky (1999).mkv": {"title": "Pelíšky"}})
index = PoolIndex(tmp_path)
@@ -131,7 +152,10 @@ class TestV1Migration:
backup = tmp_path / (INDEX_FILENAME + ".v1.bak")
assert backup.exists()
assert "Filmy/A (2000).mkv" in json.loads(backup.read_text(encoding="utf-8"))["movies"]
assert (
"Filmy/A (2000).mkv"
in json.loads(backup.read_text(encoding="utf-8"))["movies"]
)
on_disk = json.loads((tmp_path / INDEX_FILENAME).read_text(encoding="utf-8"))
assert on_disk["version"] == INDEX_VERSION
@@ -141,9 +165,16 @@ class TestV1Migration:
assert index.get_setting("tag_schema") == []
def test_v2_index_is_not_migrated_again(self, tmp_path):
(tmp_path / INDEX_FILENAME).write_text(json.dumps({
"version": INDEX_VERSION, "settings": {},
"movies": {"tmdb-1": {"title": "X", "media": []}}}), encoding="utf-8")
(tmp_path / INDEX_FILENAME).write_text(
json.dumps(
{
"version": INDEX_VERSION,
"settings": {},
"movies": {"tmdb-1": {"title": "X", "media": []}},
}
),
encoding="utf-8",
)
index = PoolIndex(tmp_path)