def test_equality(self, best):
        a = Suggestions(best, self.suggestions)
        b = Suggestions(None, self.suggestions)
        c = Suggestions(best, [])
        d = Suggestions(best, self.suggestions)

        assert a != b != c
        assert hash(a) != hash(b) != hash(c)
        assert a is not b is not c

        assert a == d
예제 #2
0
    def search_suggest(self, part: str, timeout=None, *args, **kwargs):
        url = f'{self.base_url}/search/suggest'

        result = self._request.get(url, {'part': part},
                                   timeout=timeout,
                                   *args,
                                   **kwargs)

        return Suggestions.de_json(result, self)
예제 #3
0
    def search_suggest(self, part: str, timeout=None, *args, **kwargs):
        """Получение подсказок по введенной части поискового запроса.

        Args:
            part (:obj:`str`): Часть поискового запроса.
            timeout (:obj:`int` | :obj:`float`, optional): Если это значение указано, используется как время ожидания
                ответа от сервера вместо указанного при создании пула.
            **kwargs (:obj:`dict`, optional): Произвольные аргументы (будут переданы в запрос).

        Returns:
            :obj:`yandex_music.Suggestions`: Объекта класса :class:`yandex_music.Suggestions`
            представляющий подсказки для запроса, иначе :obj:`None`.

        Raises:
            :class:`yandex_music.YandexMusicError`
        """

        url = f'{self.base_url}/search/suggest'

        result = self._request.get(url, {'part': part}, timeout=timeout, *args, **kwargs)

        return Suggestions.de_json(result, self)
def suggestions_with_best(request, results, types):
    best = Best(types[request.param], results[request.param], TestBest.text)
    return Suggestions(best, TestSuggestions.suggestions), best
    def test_de_json_all(self, client, best):
        json_dict = {'best': best.to_dict(), 'suggestions': self.suggestions}
        suggestions = Suggestions.de_json(json_dict, client)

        assert suggestions.best == best
        assert suggestions.suggestions == self.suggestions
 def test_de_json_none(self, client):
     assert Suggestions.de_json({}, client) is None