Esempio n. 1
0
    def test_equality(self, generated_playlist, day):
        a = Feed(
            self.can_get_more_events,
            self.pumpkin,
            self.is_wizard_passed,
            [generated_playlist],
            self.headlines,
            self.today,
            [day],
        )
        b = Feed(False, self.pumpkin, self.is_wizard_passed, [], self.headlines, self.today, [day])
        c = Feed(
            self.can_get_more_events,
            self.pumpkin,
            self.is_wizard_passed,
            [generated_playlist],
            self.headlines,
            self.today,
            [day],
        )

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

        assert a == c
Esempio n. 2
0
def feed(generated_playlist, day):
    return Feed(
        TestFeed.can_get_more_events,
        TestFeed.pumpkin,
        TestFeed.is_wizard_passed,
        [generated_playlist],
        TestFeed.headlines,
        TestFeed.today,
        [day],
        TestFeed.next_revision,
    )
    def test_de_json_required(self, client, generated_playlist, day):
        json_dict = {
            'can_get_more_events': self.can_get_more_events,
            'pumpkin': self.pumpkin,
            'is_wizard_passed': self.is_wizard_passed,
            'generated_playlists': [generated_playlist.to_dict()],
            'headlines': self.headlines,
            'today': self.today,
            'days': [day.to_dict()]
        }
        feed = Feed.de_json(json_dict, client)

        assert feed.can_get_more_events == self.can_get_more_events
        assert feed.pumpkin == self.pumpkin
        assert feed.is_wizard_passed == self.is_wizard_passed
        assert feed.generated_playlists == [generated_playlist]
        assert feed.headlines == self.headlines
        assert feed.today == self.today
        assert feed.days == [day]
Esempio n. 4
0
    def feed(self, timeout=None, *args, **kwargs):
        """Получение потока информации (фида) подобранного под пользователя. Содержит умные плейлисты.

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

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

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

        url = f'{self.base_url}/feed'

        result = self._request.get(url, timeout=timeout, *args, **kwargs)

        return Feed.de_json(result, self)
Esempio n. 5
0
    def feed(self, timeout=None, *args, **kwargs):
        url = f'{self.base_url}/feed'

        result = self._request.get(url, timeout=timeout, *args, **kwargs)

        return Feed.de_json(result, self)
Esempio n. 6
0
 def test_de_json_none(self, client):
     assert Feed.de_json({}, client) is None