From 8169983074949e5418a259f92d98286cc536abff Mon Sep 17 00:00:00 2001 From: wordofglass Date: Sun, 17 Apr 2016 21:18:31 +0200 Subject: [PATCH] fix translation of the old remote_priority option for fetchart, add a test --- beetsplug/fetchart.py | 4 ++-- test/test_art.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 88c72cdbd..1f6605608 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -694,8 +694,8 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin): u'been deprecated, see the documentation.') if self.config['remote_priority'].get(bool): try: - self.sources_name.remove[u'filesystem'] - sources_name.append[u'filesystem'] + sources_name.remove(u'filesystem') + sources_name.append(u'filesystem') except ValueError: pass self.sources = [ART_SOURCES[s](self._log, self.config) diff --git a/test/test_art.py b/test/test_art.py index 033174db4..e52eb6772 100644 --- a/test/test_art.py +++ b/test/test_art.py @@ -27,6 +27,7 @@ from test import _common from test._common import unittest from beetsplug import fetchart from beets.autotag import AlbumInfo, AlbumMatch +from beets import config from beets import library from beets import importer from beets import logging @@ -540,6 +541,24 @@ class ArtForAlbumTest(UseThePlugin): self._assertImageResized(self.IMG_348x348, True) +class DeprecatedConfigTest(_common.TestCase): + """While refactoring the plugin, the remote_priority option was deprecated, + and a new codepath should translate its effect. Check that it actually does + so. + """ + + # If we subclassed UseThePlugin, the configuration change would either be + # overwritten by _common.TestCase or be set after constructing the + # plugin object + def setUp(self): + super(DeprecatedConfigTest, self).setUp() + config['fetchart']['remote_priority'] = True + self.plugin = fetchart.FetchArtPlugin() + + def test_moves_filesystem_to_end(self): + self.assertEqual(type(self.plugin.sources[-1]), fetchart.FileSystem) + + def suite(): return unittest.TestLoader().loadTestsFromName(__name__)