diff --git a/test/test_web.py b/test/test_web.py index e7d1f334f..e0022e60f 100644 --- a/test/test_web.py +++ b/test/test_web.py @@ -22,10 +22,15 @@ class WebPluginTest(_common.LibTestCase): # Add fixtures for track in self.lib.items(): 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)) - self.lib.add(Album(album=u'album', id=3)) - self.lib.add(Album(album=u'another album', id=4)) + + # Add library elements. Note that self.lib.add overrides any "id=" and assigns + # the next free id number. + # 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['lib'] = self.lib @@ -140,6 +145,15 @@ class WebPluginTest(_common.LibTestCase): self.assertEqual(response.status_code, 200) 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(): return unittest.TestLoader().loadTestsFromName(__name__)