Ejemplo n.º 1
0
    def de_json(cls, data, client):
        if not data:
            return None

        data = super(StationResult, cls).de_json(data, client)
        from yandex_music import Station, RotorSettings, AdParams
        data['station'] = Station.de_json(data.get('station'), client)
        data['settings'] = RotorSettings.de_json(data.get('settings'), client)
        data['settings2'] = RotorSettings.de_json(data.get('settings2'), client)
        data['ad_params'] = AdParams.de_json(data.get('ad_params'), client)

        return cls(client=client, **data)
Ejemplo n.º 2
0
    def test_de_json_all(self, client):
        json_dict = {'language': self.language, 'diversity': self.diversity, 'mood': self.mood, 'energy': self.energy,
                     'mood_energy': self.mood_energy}
        rotor_settings = RotorSettings.de_json(json_dict, client)

        assert rotor_settings.language == self.language
        assert rotor_settings.diversity == self.diversity
        assert rotor_settings.mood == self.mood
        assert rotor_settings.energy == self.energy
        assert rotor_settings.mood_energy == self.mood_energy
Ejemplo n.º 3
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['StationResult']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.StationResult`: Радиостанция с настройками.
        """
        if not data:
            return None

        data = super(StationResult, cls).de_json(data, client)
        from yandex_music import Station, RotorSettings, AdParams

        data['station'] = Station.de_json(data.get('station'), client)
        data['settings'] = RotorSettings.de_json(data.get('settings'), client)
        data['settings2'] = RotorSettings.de_json(data.get('settings2'), client)
        data['ad_params'] = AdParams.de_json(data.get('ad_params'), client)

        return cls(client=client, **data)
Ejemplo n.º 4
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.StationResult`: Объект класса :class:`yandex_music.StationResult`.
        """
        if not data:
            return None

        data = super(StationResult, cls).de_json(data, client)
        from yandex_music import Station, RotorSettings, AdParams
        data['station'] = Station.de_json(data.get('station'), client)
        data['settings'] = RotorSettings.de_json(data.get('settings'), client)
        data['settings2'] = RotorSettings.de_json(data.get('settings2'),
                                                  client)
        data['ad_params'] = AdParams.de_json(data.get('ad_params'), client)

        return cls(client=client, **data)
    def test_de_json_required(self, client):
        json_dict = {'language': self.language, 'diversity': self.diversity}
        rotor_settings = RotorSettings.de_json(json_dict, client)

        assert rotor_settings.language == self.language
        assert rotor_settings.diversity == self.diversity
 def test_de_json_none(self, client):
     assert RotorSettings.de_json({}, client) is None