mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
parent
0f1b5b2ca5
commit
2e1b0d589d
2 changed files with 16 additions and 9 deletions
|
|
@ -207,7 +207,8 @@ def art_in_path(path, cover_names, cautious):
|
||||||
images = []
|
images = []
|
||||||
for fn in os.listdir(path):
|
for fn in os.listdir(path):
|
||||||
for ext in IMAGE_EXTENSIONS:
|
for ext in IMAGE_EXTENSIONS:
|
||||||
if fn.lower().endswith('.' + ext):
|
if fn.lower().endswith('.' + ext) and \
|
||||||
|
os.path.isfile(os.path.join(path, fn)):
|
||||||
images.append(fn)
|
images.append(fn)
|
||||||
|
|
||||||
# Look for "preferred" filenames.
|
# Look for "preferred" filenames.
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
# The above copyright notice and this permission notice shall be
|
# The above copyright notice and this permission notice shall be
|
||||||
# included in all copies or substantial portions of the Software.
|
# included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
import os.path
|
import os
|
||||||
from _common import unittest
|
from _common import unittest
|
||||||
from helper import TestHelper
|
from helper import TestHelper
|
||||||
|
|
||||||
|
|
@ -22,25 +22,31 @@ class FetchartCliTest(unittest.TestCase, TestHelper):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.setup_beets()
|
self.setup_beets()
|
||||||
self.load_plugins('fetchart')
|
self.load_plugins('fetchart')
|
||||||
|
self.config['fetchart']['cover_names'] = 'c\xc3\xb6ver.jpg'
|
||||||
|
self.config['art_filename'] = 'mycover'
|
||||||
|
self.album = self.add_album()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.unload_plugins()
|
self.unload_plugins()
|
||||||
self.teardown_beets()
|
self.teardown_beets()
|
||||||
|
|
||||||
def test_set_art_from_folder(self):
|
def test_set_art_from_folder(self):
|
||||||
self.config['fetchart']['cover_names'] = 'c\xc3\xb6ver.jpg'
|
self.touch('c\xc3\xb6ver.jpg', dir=self.album.path, content='IMAGE')
|
||||||
self.config['art_filename'] = 'mycover'
|
|
||||||
album = self.add_album()
|
|
||||||
self.touch('c\xc3\xb6ver.jpg', dir=album.path, content='IMAGE')
|
|
||||||
|
|
||||||
self.run_command('fetchart')
|
self.run_command('fetchart')
|
||||||
cover_path = os.path.join(album.path, 'mycover.jpg')
|
cover_path = os.path.join(self.album.path, 'mycover.jpg')
|
||||||
|
|
||||||
album.load()
|
self.album.load()
|
||||||
self.assertEqual(album['artpath'], cover_path)
|
self.assertEqual(self.album['artpath'], cover_path)
|
||||||
with open(cover_path, 'r') as f:
|
with open(cover_path, 'r') as f:
|
||||||
self.assertEqual(f.read(), 'IMAGE')
|
self.assertEqual(f.read(), 'IMAGE')
|
||||||
|
|
||||||
|
def test_filesystem_does_not_pick_up_folder(self):
|
||||||
|
os.makedirs(os.path.join(self.album.path, 'mycover.jpg'))
|
||||||
|
self.run_command('fetchart')
|
||||||
|
self.album.load()
|
||||||
|
self.assertEqual(self.album['artpath'], None)
|
||||||
|
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue