def playlists(self): if not self.__playlists: resp = self.__a_request("playlists 0 255", raw=True) self.__playlists = [v for k, v in self.__pairs_from(resp) if k == 'playlist'] print_d(with_example("Loaded %d LMS playlists", self.__playlists)) return self.__playlists
def genres(self): if not self.__genres: resp = self.__a_request("genres 0 255", raw=True) self.__genres = [v for k, v in self.__pairs_from(resp) if k == 'genre'] print_d(with_example("Loaded %d LMS genres", self.__genres)) return self.__genres
def favorites(self): if not self.__favorites: resp = self.__a_request("favorites items 0 255 want_url:1", raw=True) self.__favorites = {d['name']: d for d in self._groups(resp, 'name') if d['isaudio']} print_d(with_example("Loaded %d LMS faves", self.__favorites)) return self.__favorites
def test_with_example_dict(self): assert with_example("%d words", {1: 'one'}) == '1 words (e.g. "1")'
def test_with_example(self): assert with_example("%d words", ['one']) == '1 words (e.g. "one")'
def test_with_example_zero(self): assert with_example("%d words", []) == "0 words"
def test_with_example_dict(self): assert with_example("{num} words", {1: 'one'}) == '1 words ("1")'
def test_with_example(self): output = with_example("{num} words", ['one', 'two']) assert output.startswith('2 words (e.g. "')
def test_missing_num_raises(self): with raises(ValueError): with_example("Nothing {there}", [2])