Feature/advanced search

Some updates I've done to the default local backend / library to provide a single search/find_exact advanced_search method, with support for::

1)Passing a desired return type, so for example, the list_albums command now only returns the list of albums - fixes:
https://github.com/mopidy/mopidy/issues/913

2)Passing through the 'limit' and 'offset' parameters, so you potentially can page through things (and they're not ignored), fixes:
https://github.com/mopidy/mopidy/issues/917

3) Listing all types of thing in response to a search (album, artist and track), not just track. All things have a browse URI, so when you click on an album in musicbox, it lists that album. Fixes:
https://github.com/mopidy/mopidy/issues/920

For other backends, it drops through to the old search methods if advanced_search isn't implemented.

The json backend loads the tracklist into a memory sqlite database because the search for album/artist functions were becoming a bit convoluted, it has the bonus of being significantly faster.

On the down-side, this might need some consideration before merging in, in particular:
1) It currently (same as the sqlite backend) only supports a single artist field. I've currently left this just taking the first artist. 
Potentially it could 1)use a ; delimited list of artists, which would break exact search for multi-artist searches.
2) For browsing and URIs to work, for albums that don't have an albumartist listed, it chooses one from the song artists to put in the URI. Similarly, it takes date from songs for albums without a date.
3) I had to put more metadata in the test data in tests/local/test_library because of the way this code brings metadata across to make the URI browsing work (2).
I think these are correct, because library calls through to backend searches all go through advanced_search in the backend base class, this is only testing that it gets as far as that call from the core code. It's going through the core library search and find exact calls still in those tests.

I think it makes sense to route everything via advanced search because it ensures that the behaviour of the advanced and non advanced calls is consistent for the basic behaviour (and means that new backends only need to support one search call in future).



---- Lasse Bigum wrote ----


In tests/core/test_library.py<https://github.com/mopidy/mopidy/pull/921#discussion-diff-22253268>:

>
>          result = self.core.library.search(dict(any=['a']))
>
>          self.assertIn(result1, result)
>          self.assertIn(result2, result)
> -        self.library1.search.assert_called_once_with(
> -            query=dict(any=['a']), uris=None)
> -        self.library2.search.assert_called_once_with(
> -            query=dict(any=['a']), uris=None)
> +        self.library1.advanced_search.assert_called_once_with(
> +            query=dict(any=['a']), uris=None,exact=False,returnType=None,limit=0,offset=0)
> +        self.library2.advanced_search.assert_called_once_with(
> +            query=dict(any=['a']), uris=None,exact=False,returnType=None,limit=0,offset=0)


For all of these changes to test_library, I think we would want you to make new tests, not modify the old ones, to ensure we still have full test coverage of the API.
Right now you are removing all tests of .search()

—
Reply to this email directly or view it on GitHub<https://github.com/mopidy/mopidy/pull/921/files#r22253268>.




This message and any attachment are intended solely for the addressee
and may contain confidential information. If you have received this
message in error, please send it back to me, and immediately delete it. 

Please do not use, copy or disclose the information contained in this
message or in any attachment.  Any views or opinions expressed by the
author of this email do not necessarily reflect the views of the
University of Nottingham.

This message has been checked for viruses but the contents of an
attachment may still contain software viruses which could damage your
computer system, you are advised to perform your own checks. Email
communications with the University of Nottingham may be monitored as
permitted by UK legislation.