mirror of
https://github.com/beetbox/beets.git
synced 2026-02-23 07:44:38 +01:00
Fix verbose comments and add e,c test
This commit is contained in:
parent
b242e3d052
commit
cefb4bfe22
2 changed files with 17 additions and 17 deletions
|
|
@ -275,24 +275,17 @@ class EditPlugin(plugins.BeetsPlugin):
|
|||
ui.print_("No changes to apply.")
|
||||
return False
|
||||
|
||||
# Confirm the changes.
|
||||
# For cancel/keep-editing, restore objects to their original
|
||||
# in-memory state so temp edits don't leak into the session
|
||||
choice = ui.input_options(
|
||||
("continue Editing", "apply", "cancel")
|
||||
)
|
||||
if choice == "a": # Apply.
|
||||
return True
|
||||
elif choice == "c": # Cancel.
|
||||
# Revert all temporary changes made in this edit session
|
||||
# so that objects return to their original in-memory
|
||||
# state (including tags provided by other plugins such as
|
||||
# `fromfilename`).
|
||||
self.apply_data(objs, new_data, old_data)
|
||||
return False
|
||||
elif choice == "e": # Keep editing.
|
||||
# Revert changes on the objects, but keep the edited YAML
|
||||
# file so the user can continue editing from their last
|
||||
# version. On the next iteration, differences will again
|
||||
# be computed against the original state (`old_data`).
|
||||
self.apply_data(objs, new_data, old_data)
|
||||
continue
|
||||
|
||||
|
|
@ -382,10 +375,6 @@ class EditPlugin(plugins.BeetsPlugin):
|
|||
# to the files if needed without re-applying metadata.
|
||||
return Action.RETAG
|
||||
else:
|
||||
# Edit cancelled / no edits made. `edit_objects` has already
|
||||
# restored each object to its original in-memory state, so there
|
||||
# is nothing more to do here. Returning None lets the importer
|
||||
# resume the candidate prompt.
|
||||
return None
|
||||
|
||||
def importer_edit_candidate(self, session, task):
|
||||
|
|
|
|||
|
|
@ -178,23 +178,34 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
|||
|
||||
def test_title_edit_keep_editing_then_apply(self, mock_write):
|
||||
"""Edit titles, keep editing once, then apply changes."""
|
||||
# First, choose "keep editing" so changes are reverted in memory but
|
||||
# kept in the YAML file; then choose "apply" to commit them.
|
||||
self.run_mocked_command(
|
||||
{"replacements": {"t\u00eftle": "modified t\u00eftle"}},
|
||||
# keep Editing, then Apply
|
||||
["e", "a"],
|
||||
)
|
||||
|
||||
# Writes should only happen once per track, when we finally apply.
|
||||
assert mock_write.call_count == self.TRACK_COUNT
|
||||
# All item titles (and mtimes) should now reflect the modified values.
|
||||
self.assertItemFieldsModified(
|
||||
self.album.items(),
|
||||
self.items_orig,
|
||||
["title", "mtime"],
|
||||
)
|
||||
|
||||
def test_title_edit_keep_editing_then_cancel(self, mock_write):
|
||||
"""Edit titles, keep editing once, then cancel."""
|
||||
self.run_mocked_command(
|
||||
{"replacements": {"t\u00eftle": "modified t\u00eftle"}},
|
||||
# keep Editing, then Cancel
|
||||
["e", "c"],
|
||||
)
|
||||
|
||||
assert mock_write.call_count == 0
|
||||
self.assertItemFieldsModified(
|
||||
self.album.items(),
|
||||
self.items_orig,
|
||||
[],
|
||||
)
|
||||
|
||||
def test_noedit(self, mock_write):
|
||||
"""Do not edit anything."""
|
||||
# Do not edit anything.
|
||||
|
|
|
|||
Loading…
Reference in a new issue