mirror of
https://github.com/beetbox/beets.git
synced 2026-01-05 15:33:15 +01:00
Fix bug where album artpath not returned when INCLUDE_PATHS is set
Track item paths and album artpaths should be removed from results unless INCLUDE_PATHS is set. This works for items but for albums the artpath is always removed. This patch makes the artpath removal conditional on INCLUDE_PATHS not being set and includes a regression test. Note: the default value for INCLUDE_PATHS is False so no changes will be seen by users unless they already have INCLUDE_PATHS set. Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
This commit is contained in:
parent
49c747d144
commit
9986b9892c
2 changed files with 21 additions and 2 deletions
|
|
@ -59,7 +59,10 @@ def _rep(obj, expand=False):
|
|||
return out
|
||||
|
||||
elif isinstance(obj, beets.library.Album):
|
||||
del out['artpath']
|
||||
if app.config.get('INCLUDE_PATHS', False):
|
||||
out['artpath'] = util.displayable_path(out['artpath'])
|
||||
else:
|
||||
del out['artpath']
|
||||
if expand:
|
||||
out['items'] = [_rep(item) for item in obj.items()]
|
||||
return out
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class WebPluginTest(_common.LibTestCase):
|
|||
self.lib.add(Item(title=u'and a third'))
|
||||
# The following adds will create albums #1 and #2
|
||||
self.lib.add(Album(album=u'album'))
|
||||
self.lib.add(Album(album=u'other album'))
|
||||
self.lib.add(Album(album=u'other album', artpath='/art_path_2'))
|
||||
|
||||
web.app.config['TESTING'] = True
|
||||
web.app.config['lib'] = self.lib
|
||||
|
|
@ -46,6 +46,14 @@ class WebPluginTest(_common.LibTestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(res_json['path'], u'/path_1')
|
||||
|
||||
def test_config_include_artpaths_true(self):
|
||||
web.app.config['INCLUDE_PATHS'] = True
|
||||
response = self.client.get('/album/2')
|
||||
res_json = json.loads(response.data.decode('utf-8'))
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(res_json['artpath'], u'/art_path_2')
|
||||
|
||||
def test_config_include_paths_false(self):
|
||||
web.app.config['INCLUDE_PATHS'] = False
|
||||
response = self.client.get('/item/1')
|
||||
|
|
@ -54,6 +62,14 @@ class WebPluginTest(_common.LibTestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertNotIn('path', res_json)
|
||||
|
||||
def test_config_include_artpaths_false(self):
|
||||
web.app.config['INCLUDE_PATHS'] = False
|
||||
response = self.client.get('/album/2')
|
||||
res_json = json.loads(response.data.decode('utf-8'))
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertNotIn('artpath', res_json)
|
||||
|
||||
def test_get_all_items(self):
|
||||
response = self.client.get('/item/')
|
||||
res_json = json.loads(response.data.decode('utf-8'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue