mirror of
https://github.com/beetbox/beets.git
synced 2026-01-17 05:34:23 +01:00
Maybe fix code and tests for Windows
This commit is contained in:
parent
e2be6ba781
commit
e3707e45f3
2 changed files with 9 additions and 4 deletions
|
|
@ -176,11 +176,16 @@ class QueryConverter(PathConverter):
|
|||
return ','.join(value)
|
||||
|
||||
|
||||
class EverythingConverter(PathConverter):
|
||||
regex = '.*?'
|
||||
|
||||
|
||||
# Flask setup.
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
app.url_map.converters['idlist'] = IdListConverter
|
||||
app.url_map.converters['query'] = QueryConverter
|
||||
app.url_map.converters['everything'] = EverythingConverter
|
||||
|
||||
|
||||
@app.before_request
|
||||
|
|
@ -221,9 +226,9 @@ def item_query(queries):
|
|||
return g.lib.items(queries)
|
||||
|
||||
|
||||
@app.route('/item/path/<path:path>')
|
||||
@app.route('/item/path/<everything:path>')
|
||||
def item_at_path(path):
|
||||
query = beets.library.PathQuery('path', b'/' + path.encode('utf-8'))
|
||||
query = beets.library.PathQuery('path', path.encode('utf-8'))
|
||||
item = g.lib.items(query).get()
|
||||
if item:
|
||||
return flask.jsonify(_rep(item))
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class WebPluginTest(_common.LibTestCase):
|
|||
def test_get_single_item_by_path(self):
|
||||
data_path = os.path.join(_common.RSRC, b'full.mp3')
|
||||
self.lib.add(Item.from_path(data_path))
|
||||
response = self.client.get('/item/path' + data_path.decode('utf-8'))
|
||||
response = self.client.get('/item/path/' + data_path.decode('utf-8'))
|
||||
response.json = json.loads(response.data.decode('utf-8'))
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
|
@ -89,7 +89,7 @@ class WebPluginTest(_common.LibTestCase):
|
|||
data_path = os.path.join(_common.RSRC, b'full.mp3')
|
||||
# data_path points to a valid file, but we have not added the file
|
||||
# to the library.
|
||||
response = self.client.get('/item/path' + data_path.decode('utf-8'))
|
||||
response = self.client.get('/item/path/' + data_path.decode('utf-8'))
|
||||
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue