From bb1a83b4ba9d7a494ec430a1277c36bd8b076dd0 Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Sun, 21 Jan 2024 14:01:11 -0800 Subject: [PATCH] Fix the rename command --- comictaggerlib/ctsettings/commandline.py | 2 +- tests/integration_test.py | 42 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/comictaggerlib/ctsettings/commandline.py b/comictaggerlib/ctsettings/commandline.py index 2800f91..ec74e06 100644 --- a/comictaggerlib/ctsettings/commandline.py +++ b/comictaggerlib/ctsettings/commandline.py @@ -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, ) diff --git a/tests/integration_test.py b/tests/integration_test.py index 62658c4..4d82a57 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -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