From 5f21bd3ccd232014cd604062071eb40bc442d1b1 Mon Sep 17 00:00:00 2001 From: wordofglass Date: Thu, 24 Aug 2017 14:52:41 +0200 Subject: [PATCH] test_edit: Add a test for retagging. --- test/test_edit.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/test_edit.py b/test/test_edit.py index 2900d092a..b4eea4abb 100644 --- a/test/test_edit.py +++ b/test/test_edit.py @@ -22,6 +22,7 @@ from test import _common from test.helper import TestHelper, control_stdin from test.test_ui_importer import TerminalImportSessionSetup from test.test_importer import ImportHelper, AutotagStub +from beets.dbcore.query import TrueQuery from beets.library import Item from beetsplug.edit import EditPlugin @@ -359,6 +360,34 @@ class EditDuringImporterTest(TerminalImportSessionSetup, unittest.TestCase, # Ensure album is fetched from a candidate. self.assertIn('albumid', self.lib.albums()[0].mb_albumid) + def test_edit_retag_apply(self): + """Import the album using a candidate, then retag and edit and apply + changes. + """ + self._setup_import_session() + self.run_mocked_interpreter({}, + # 1, Apply changes. + ['1', 'a']) + + # Retag and edit track titles. On retag, the importer will reset items + # ids but not the db connections. + self.importer.paths = [] + self.importer.query = TrueQuery() + self.run_mocked_interpreter({'replacements': {u'Applied Title': + u'Edited Title'}}, + # eDit, Apply changes. + ['d', 'a']) + + # Check that 'title' field is modified, and other fields come from + # the candidate. + self.assertTrue(all('Edited Title ' in i.title + for i in self.lib.items())) + self.assertTrue(all('match ' in i.mb_trackid + for i in self.lib.items())) + + # Ensure album is fetched from a candidate. + self.assertIn('albumid', self.lib.albums()[0].mb_albumid) + def test_edit_discard_candidate(self): """Edit the album field for all items in the library, discard changes, using a candidate.