mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
Test and fix web /item/query/<query>
This commit is contained in:
parent
b392ff1c94
commit
75c3b82d88
2 changed files with 11 additions and 1 deletions
|
|
@ -107,7 +107,9 @@ def resource_query(name):
|
|||
def responder(query):
|
||||
parts = query.split('/')
|
||||
entities = query_func(parts)
|
||||
return flask.jsonify(results=[_rep(entities) for item in items])
|
||||
return app.response_class(
|
||||
json_generator(entities, root='results'),
|
||||
mimetype='application/json')
|
||||
responder.__name__ = 'query_%s' % name
|
||||
return responder
|
||||
return make_responder
|
||||
|
|
|
|||
|
|
@ -62,6 +62,14 @@ class WebPluginTest(_common.LibTestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(len(response.json['items']), 2)
|
||||
|
||||
def test_get_simple_item_query(self):
|
||||
response = self.client.get('/item/query/another')
|
||||
response.json = json.loads(response.data)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(len(response.json['results']), 1)
|
||||
self.assertEqual(response.json['results'][0]['title'], 'another title')
|
||||
|
||||
def test_get_all_albums(self):
|
||||
response = self.client.get('/album/')
|
||||
response.json = json.loads(response.data)
|
||||
|
|
|
|||
Loading…
Reference in a new issue