Fix rename and add test

This commit is contained in:
Timmy Welch 2022-07-29 22:05:03 -07:00
parent 94be266e17
commit f2a68d6c8b
2 changed files with 9 additions and 1 deletions

View File

@ -750,7 +750,7 @@ class ComicArchive:
if new_path == self.path:
return
os.makedirs(new_path.parent, 0o777, True)
shutil.move(path, new_path)
shutil.move(self.path, new_path)
self.path = new_path
self.archiver.path = pathlib.Path(path)

View File

@ -88,3 +88,11 @@ def test_copy_from_archive(archiver, tmp_path, cbz):
md = comic_archive.read_cix()
assert md == comicapi.genericmetadata.md_test
def test_rename(tmp_comic, tmp_path):
old_path = tmp_comic.path
tmp_comic.rename(tmp_path / "test.cbz")
assert not old_path.exists()
assert tmp_comic.path.exists()
assert tmp_comic.path != old_path