Auto-fill ČSFD links on import, rename in pool, multi-country tags, Filmotéka layout
This commit is contained in:
@@ -592,6 +592,73 @@ class TestPoolManagement:
|
||||
assert movie.csfd_link == "https://csfd.cz/film/1"
|
||||
assert file_manager.index.get(movie.file_path) is not None
|
||||
|
||||
def test_import_movie_move_removes_source(self, file_manager, tmp_path):
|
||||
file_manager.set_pool_dir(tmp_path / "pool")
|
||||
source = tmp_path / "raw.mkv"
|
||||
source.write_bytes(b"x" * 10)
|
||||
|
||||
movie = file_manager.import_movie(source, "Matrix", move=True)
|
||||
|
||||
assert movie.file_path == tmp_path / "pool" / "Filmy" / "Matrix.mkv"
|
||||
assert movie.file_path.exists()
|
||||
assert not source.exists() # moved, not copied
|
||||
|
||||
def test_rename_movie_renames_file_and_reindexes(self, file_manager, tmp_path):
|
||||
file_manager.set_pool_dir(tmp_path / "pool")
|
||||
source = tmp_path / "raw.mkv"
|
||||
source.write_bytes(b"x" * 10)
|
||||
movie = file_manager.import_movie(source, "Matrix")
|
||||
movie.add_tag("Žánr/Sci-Fi")
|
||||
old_path = movie.file_path
|
||||
|
||||
file_manager.rename_movie(movie, "Matrix Reloaded")
|
||||
|
||||
new_path = tmp_path / "pool" / "Filmy" / "Matrix Reloaded.mkv"
|
||||
assert movie.file_path == new_path
|
||||
assert new_path.exists()
|
||||
assert not old_path.exists()
|
||||
assert movie.title == "Matrix Reloaded"
|
||||
# metadata moved to the new key, old key gone, tags preserved
|
||||
assert file_manager.index.get(new_path) is not None
|
||||
assert file_manager.index.get(old_path) is None
|
||||
# a fresh manager reading the index sees the renamed file with its tags
|
||||
reloaded = FileManager(TagManager())
|
||||
reloaded.set_pool_dir(tmp_path / "pool")
|
||||
reloaded.load_pool_movies()
|
||||
assert [f.filename for f in reloaded.filelist] == ["Matrix Reloaded.mkv"]
|
||||
assert "Žánr/Sci-Fi" in {t.full_path for t in reloaded.filelist[0].tags}
|
||||
|
||||
def test_rename_movie_preserves_extension(self, file_manager, tmp_path):
|
||||
file_manager.set_pool_dir(tmp_path / "pool")
|
||||
source = tmp_path / "raw.mp4"
|
||||
source.write_bytes(b"x")
|
||||
movie = file_manager.import_movie(source, "Film")
|
||||
|
||||
file_manager.rename_movie(movie, "Jiný název")
|
||||
|
||||
assert movie.file_path.name == "Jiný název.mp4"
|
||||
|
||||
def test_rename_movie_rejects_existing_name(self, file_manager, tmp_path):
|
||||
file_manager.set_pool_dir(tmp_path / "pool")
|
||||
(tmp_path / "a.mkv").write_bytes(b"a")
|
||||
(tmp_path / "b.mkv").write_bytes(b"b")
|
||||
first = file_manager.import_movie(tmp_path / "a.mkv", "Already")
|
||||
second = file_manager.import_movie(tmp_path / "b.mkv", "Other")
|
||||
|
||||
with pytest.raises(FileExistsError):
|
||||
file_manager.rename_movie(second, "Already")
|
||||
# second movie is left untouched
|
||||
assert second.file_path.name == "Other.mkv"
|
||||
assert first.file_path.exists()
|
||||
|
||||
def test_rename_movie_rejects_empty_name(self, file_manager, tmp_path):
|
||||
file_manager.set_pool_dir(tmp_path / "pool")
|
||||
(tmp_path / "a.mkv").write_bytes(b"a")
|
||||
movie = file_manager.import_movie(tmp_path / "a.mkv", "Name")
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
file_manager.rename_movie(movie, " ")
|
||||
|
||||
def test_load_pool_movies_reads_from_index(self, file_manager, tmp_path):
|
||||
file_manager.set_pool_dir(tmp_path / "pool")
|
||||
source = tmp_path / "raw.mkv"
|
||||
|
||||
Reference in New Issue
Block a user