mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
Document "id" handling in test setup and add test to confirm
self.lib.add ignores the "id" field from the entry being added and overwrites it with the next free number. So remove the misleading id fields. Add a test to confirm that the album query response contains the expected album id number. Signed-off-by: Graham R. Cobb <g+beets@cobb.uk.net>
This commit is contained in:
parent
d226632eeb
commit
dc55480f51
1 changed files with 18 additions and 4 deletions
|
|
@ -22,10 +22,15 @@ class WebPluginTest(_common.LibTestCase):
|
||||||
# Add fixtures
|
# Add fixtures
|
||||||
for track in self.lib.items():
|
for track in self.lib.items():
|
||||||
track.remove()
|
track.remove()
|
||||||
self.lib.add(Item(title=u'title', path='/path_1', id=1))
|
|
||||||
self.lib.add(Item(title=u'another title', path='/path_2', id=2))
|
# Add library elements. Note that self.lib.add overrides any "id=<n>" and assigns
|
||||||
self.lib.add(Album(album=u'album', id=3))
|
# the next free id number.
|
||||||
self.lib.add(Album(album=u'another album', id=4))
|
# The following adds will create items #1 and #2
|
||||||
|
self.lib.add(Item(title=u'title', path='/path_1'))
|
||||||
|
self.lib.add(Item(title=u'another title', path='/path_2', album_id=2))
|
||||||
|
# The following adds will create albums #1 and #2
|
||||||
|
self.lib.add(Album(album=u'album'))
|
||||||
|
self.lib.add(Album(album=u'another album'))
|
||||||
|
|
||||||
web.app.config['TESTING'] = True
|
web.app.config['TESTING'] = True
|
||||||
web.app.config['lib'] = self.lib
|
web.app.config['lib'] = self.lib
|
||||||
|
|
@ -140,6 +145,15 @@ class WebPluginTest(_common.LibTestCase):
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(len(res_json['albums']), 2)
|
self.assertEqual(len(res_json['albums']), 2)
|
||||||
|
|
||||||
|
def test_get_simple_album_query(self):
|
||||||
|
response = self.client.get('/album/query/another')
|
||||||
|
res_json = json.loads(response.data.decode('utf-8'))
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertEqual(len(res_json['results']), 1)
|
||||||
|
self.assertEqual(res_json['results'][0]['album'],
|
||||||
|
u'another album')
|
||||||
|
self.assertEqual(res_json['results'][0]['id'], 2)
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
return unittest.TestLoader().loadTestsFromName(__name__)
|
return unittest.TestLoader().loadTestsFromName(__name__)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue