def search(self, query=None, limit=100, offset=0, uris=None, exact=False): tracks = self._tracks.values() # TODO: pass limit and offset into search helpers if exact: return search.find_exact(tracks, query=query, uris=uris) else: return search.search(tracks, query=query, uris=uris)
def test_find_exact_with_album_query(self): expected_tracks = [Track(album=Album(name="foo"))] tracks = [Track(), Track(album=Album(name="bar"))] + expected_tracks search_result = search.find_exact(tracks, {"album": ["foo"]}) self.assertEqual(search_result.tracks, tuple(expected_tracks))
def test_find_exact_with_album_query(self): expected_tracks = [Track(album=Album(name='foo'))] tracks = [Track(), Track(album=Album(name='bar'))] + expected_tracks search_result = search.find_exact(tracks, {'album': ['foo']}) self.assertEqual(search_result.tracks, tuple(expected_tracks))
def search(self, query=None, limit=100, offset=0, uris=None, exact=False): tracks = self._tracks.values() if exact: return search.find_exact( tracks, query=query, limit=limit, offset=offset, uris=uris) else: return search.search( tracks, query=query, limit=limit, offset=offset, uris=uris)
def find_exact(self, query=None, uris=None): try: log.debug("banshee::find_exact(%s,%s)" % (repr(query), uris)) if query is None: return None if self._tracks is None: self._tracks = self.banshee_db.get_tracks() return search.find_exact(self._tracks, query, uris) except Exception as e: traceback.print_exc() raise e