def test_equality(self, station, rotor_settings, ad_params):
        a = StationResult(station, rotor_settings, rotor_settings, ad_params)
        b = StationResult(None, rotor_settings, rotor_settings, ad_params)
        c = StationResult(station, None, rotor_settings, ad_params)
        d = StationResult(station, rotor_settings, rotor_settings, ad_params)

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

        assert a == d
    def test_de_json_required(self, client, station, rotor_settings, ad_params):
        json_dict = {'station': station.to_dict(), 'settings': rotor_settings.to_dict(),
                     'settings2': rotor_settings.to_dict(), 'ad_params': ad_params.to_dict()}
        station_result = StationResult.de_json(json_dict, client)

        assert station_result.station == station
        assert station_result.settings == rotor_settings
        assert station_result.settings2 == rotor_settings
        assert station_result.ad_params == ad_params
Esempio n. 3
0
    def de_json(cls, data, client):
        if not data:
            return None

        data = super(Dashboard, cls).de_json(data, client)
        from yandex_music import StationResult
        data['stations'] = StationResult.de_list(data.get('stations'), client)

        return cls(client=client, **data)
Esempio n. 4
0
    def rotor_station_genre_info(self,
                                 genre: str,
                                 timeout=None,
                                 *args,
                                 **kwargs):
        url = f'{self.base_url}/rotor/station/genre:{genre}/info'

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

        return StationResult.de_list(result, self)
    def test_de_json_all(self, client, station, rotor_settings, ad_params):
        json_dict = {'station': station.to_dict(), 'settings': rotor_settings.to_dict(),
                     'settings2': rotor_settings.to_dict(), 'ad_params': ad_params.to_dict(),
                     'explanation': self.explanation, 'prerolls': self.prerolls}
        station_result = StationResult.de_json(json_dict, client)

        assert station_result.station == station
        assert station_result.settings == rotor_settings
        assert station_result.settings2 == rotor_settings
        assert station_result.ad_params == ad_params
        assert station_result.explanation == self.explanation
        assert station_result.prerolls == self.prerolls
Esempio n. 6
0
    def rotor_stations_list(self,
                            language: str = 'en',
                            timeout=None,
                            *args,
                            **kwargs):
        url = f'{self.base_url}/rotor/stations/list'

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

        return StationResult.de_list(result, self)
Esempio n. 7
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Dashboard']:
        """Десериализация объекта.

        Args:
            data (:obj:`dict`): Поля и значения десериализуемого объекта.
            client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.

        Returns:
            :obj:`yandex_music.Dashboard`: Рекомендованные станций пользователя.
        """
        if not data:
            return None

        data = super(Dashboard, cls).de_json(data, client)
        from yandex_music import StationResult
        data['stations'] = StationResult.de_list(data.get('stations'), client)

        return cls(client=client, **data)
Esempio n. 8
0
    def de_json(cls, data, client):
        """Десериализация объекта.

        Args:
            data (:obj:`dict`): Поля и значения десериализуемого объекта.
            client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client`, представляющий клиент
                Yandex Music.

        Returns:
            :obj:`yandex_music.Dashboard`: Объект класса :class:`yandex_music.Dashboard`.
        """
        if not data:
            return None

        data = super(Dashboard, cls).de_json(data, client)
        from yandex_music import StationResult
        data['stations'] = StationResult.de_list(data.get('stations'), client)

        return cls(client=client, **data)
Esempio n. 9
0
def station_result(station, rotor_settings, ad_params):
    return StationResult(station, rotor_settings, rotor_settings, ad_params, TestStationResult.explanation,
                         TestStationResult.prerolls)
Esempio n. 10
0
 def test_de_list_none(self, client):
     assert StationResult.de_list({}, client) == []
Esempio n. 11
0
 def test_de_json_none(self, client):
     assert StationResult.de_json({}, client) is None