Fix the rename command

This commit is contained in:
Timmy Welch 2024-01-21 14:01:11 -08:00
parent f34e8200dd
commit bb1a83b4ba
2 changed files with 43 additions and 1 deletions

View File

@ -225,7 +225,7 @@ def register_commands(parser: settngs.Manager) -> None:
"--rename",
dest="command",
action="store_const",
const=Action.print,
const=Action.rename,
help="Rename the file based on specified tag style.",
file=False,
)

View File

@ -90,3 +90,45 @@ def test_delete(
# Validate that we got an empty metadata back
assert md == empty_md
def test_rename(
plugin_config: tuple[settngs.Config[ctsettings.ct_ns], dict[str, ComicTalker]],
tmp_comic,
comicvine_api,
md_saved,
mock_now,
) -> None:
md = tmp_comic.read_metadata("cr")
# Check that the metadata starts correct
assert md == md_saved
# Clear the cached metadata
tmp_comic.reset_cache()
# Setup the app
config = plugin_config[0]
talkers = plugin_config[1]
# Delete
config[0].Commands__command = comictaggerlib.resulttypes.Action.rename
# Use the temporary comic we created
config[0].Runtime_Options__files = [tmp_comic.path]
# Set the template
config[0].File_Rename__template = "{series}"
# Use the current directory
config[0].File_Rename__dir = ""
# Run ComicTagger
CLI(config[0], talkers).run()
# Update the comic path
tmp_comic.path = tmp_comic.path.parent / (md.series + ".cbz")
# Read the CBZ
md = tmp_comic.read_metadata("cr")
# Validate that we got the correct metadata back
assert md == md_saved