Migrate from Poetry and pyenv to uv
This commit is contained in:
+36
-15
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from src.core.file import File
|
||||
from src.core.pool_index import PoolIndex
|
||||
from src.core.tag import Tag
|
||||
@@ -130,7 +131,9 @@ class TestFile:
|
||||
file_obj.remove_tag("Video/HD")
|
||||
assert "Video/HD" not in {t.full_path for t in file_obj.tags}
|
||||
|
||||
def test_file_remove_tag_string_without_category(self, test_file, tag_manager, index):
|
||||
def test_file_remove_tag_string_without_category(
|
||||
self, test_file, tag_manager, index
|
||||
):
|
||||
file_obj = File(test_file, tag_manager, index=index)
|
||||
file_obj.add_tag("SimpleTag")
|
||||
file_obj.remove_tag("SimpleTag")
|
||||
@@ -227,8 +230,13 @@ class TestApplyNfoTags:
|
||||
def test_apply_nfo_assigns_expected_categories(self, movie_file):
|
||||
from src.core.nfo import NfoData
|
||||
|
||||
nfo = NfoData(title="Matrix", year="1999", genres=["Akční", "Sci-Fi"],
|
||||
countries=["USA"], rating=90)
|
||||
nfo = NfoData(
|
||||
title="Matrix",
|
||||
year="1999",
|
||||
genres=["Akční", "Sci-Fi"],
|
||||
countries=["USA"],
|
||||
rating=90,
|
||||
)
|
||||
result = movie_file.apply_nfo(nfo)
|
||||
|
||||
assert result["success"]
|
||||
@@ -263,12 +271,16 @@ class TestApplyNfoTags:
|
||||
def test_added_timestamp_uses_stored_added(self, movie_file):
|
||||
movie_file.added = "2026-06-16T12:00:00"
|
||||
from datetime import datetime
|
||||
assert movie_file.added_timestamp() == datetime.fromisoformat(
|
||||
"2026-06-16T12:00:00").timestamp()
|
||||
|
||||
assert (
|
||||
movie_file.added_timestamp()
|
||||
== datetime.fromisoformat("2026-06-16T12:00:00").timestamp()
|
||||
)
|
||||
|
||||
def test_added_timestamp_falls_back_to_mtime(self, movie_file):
|
||||
movie_file.added = None
|
||||
import os
|
||||
|
||||
expected = os.stat(movie_file.file_path).st_mtime
|
||||
assert movie_file.added_timestamp() == expected
|
||||
|
||||
@@ -277,8 +289,9 @@ class TestApplyNfoTags:
|
||||
assert movie_file.attributes["collection_sort"] == "03"
|
||||
assert movie_file.name_context()["collection_sort"] == "03"
|
||||
# reload (from index) keeps it
|
||||
reloaded = File(movie_file.file_path, movie_file.tagmanager,
|
||||
index=movie_file.index)
|
||||
reloaded = File(
|
||||
movie_file.file_path, movie_file.tagmanager, index=movie_file.index
|
||||
)
|
||||
assert reloaded.attributes["collection_sort"] == "03"
|
||||
|
||||
def test_set_attribute_empty_removes_it(self, movie_file):
|
||||
@@ -290,15 +303,23 @@ class TestApplyNfoTags:
|
||||
movie_file.title = "Dr. No"
|
||||
movie_file.set_attribute("collection_sort", "01")
|
||||
ctx = movie_file.name_context()
|
||||
assert "{collection_sort} - {title}{ext}".format(**ctx) == \
|
||||
f"01 - Dr. No{ctx['ext']}"
|
||||
assert (
|
||||
"{collection_sort} - {title}{ext}".format(**ctx)
|
||||
== f"01 - Dr. No{ctx['ext']}"
|
||||
)
|
||||
|
||||
def test_apply_nfo_honors_custom_schema(self, movie_file):
|
||||
"""A schema without the rating entry produces no Hodnocení tags."""
|
||||
from src.core.nfo import NfoData
|
||||
|
||||
schema = [{"category": "Žánr", "csfd_field": "genres",
|
||||
"transform": None, "filmoteka_root": ""}]
|
||||
schema = [
|
||||
{
|
||||
"category": "Žánr",
|
||||
"csfd_field": "genres",
|
||||
"transform": None,
|
||||
"filmoteka_root": "",
|
||||
}
|
||||
]
|
||||
movie_file.apply_nfo(NfoData(genres=["Drama"], rating=90), schema)
|
||||
|
||||
paths = {t.full_path for t in movie_file.tags}
|
||||
@@ -314,9 +335,9 @@ class TestApplyNfoTags:
|
||||
movie_file.apply_nfo(NfoData(year="2009", genres=["Drama"]))
|
||||
|
||||
paths = {t.full_path for t in movie_file.tags}
|
||||
assert "Sbírka/Oblíbené" in paths # user tag kept
|
||||
assert "Žánr/Drama" in paths # new NFO tag
|
||||
assert "Sbírka/Oblíbené" in paths # user tag kept
|
||||
assert "Žánr/Drama" in paths # new NFO tag
|
||||
assert "Rok/2009" in paths
|
||||
assert "Žánr/Akční" not in paths # old NFO tag regenerated away
|
||||
assert "Žánr/Akční" not in paths # stale ČSFD tag dropped
|
||||
assert "Žánr/Akční" not in paths # old NFO tag regenerated away
|
||||
assert "Žánr/Akční" not in paths # stale ČSFD tag dropped
|
||||
assert "Rok/1999" not in paths
|
||||
|
||||
Reference in New Issue
Block a user