def test_equality(self):
        a = Normalization(self.gain, self.peak)
        b = Normalization(10, self.peak)
        c = Normalization(self.gain, 10)
        d = Normalization(10, 10)
        e = Normalization(self.gain, self.peak)

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

        assert a == e
예제 #2
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Track']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.Track`: Трек.
        """
        if not data:
            return None

        data = super(Track, cls).de_json(data, client)
        from yandex_music import Normalization, Major, Album, Artist, User, MetaData, PoetryLoverMatch

        data['albums'] = Album.de_list(data.get('albums'), client)
        data['artists'] = Artist.de_list(data.get('artists'), client)
        data['normalization'] = Normalization.de_json(
            data.get('normalization'), client)
        data['major'] = Major.de_json(data.get('major'), client)
        data['substituted'] = Track.de_json(data.get('substituted'), client)
        data['matched_track'] = Track.de_json(data.get('matched_track'),
                                              client)
        data['user_info'] = User.de_json(data.get('user_info'), client)
        data['meta_data'] = MetaData.de_json(data.get('meta_data'), client)
        data['poetry_lover_matches'] = PoetryLoverMatch.de_list(
            data.get('poetry_lover_matches'), client)

        return cls(client=client, **data)
예제 #3
0
    def de_json(cls, data, client):
        if not data:
            return None

        data = super(Track, cls).de_json(data, client)
        from yandex_music import Normalization, Major
        data['normalization'] = Normalization.de_json(data.get('normalization'), client)
        data['major'] = Major.de_json(data.get('major'), client)

        return cls(client=client, **data)
예제 #4
0
    def de_json(cls, data, client):
        if not data:
            return None

        data = super(Track, cls).de_json(data, client)
        from yandex_music import Normalization, Major, Album, Artist
        data['albums'] = Album.de_list(data.get('albums'), client)
        data['artists'] = Artist.de_list(data.get('artists'), client)
        data['normalization'] = Normalization.de_json(
            data.get('normalization'), client)
        data['major'] = Major.de_json(data.get('major'), client)

        return cls(client=client, **data)
예제 #5
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Track']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.Track`: Трек.
        """
        if not data:
            return None

        data = super(Track, cls).de_json(data, client)
        from yandex_music import Normalization, Major, Album, Artist
        data['albums'] = Album.de_list(data.get('albums'), client)
        data['artists'] = Artist.de_list(data.get('artists'), client)
        data['normalization'] = Normalization.de_json(
            data.get('normalization'), client)
        data['major'] = Major.de_json(data.get('major'), client)

        return cls(client=client, **data)
예제 #6
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.Track`: Объект класса :class:`yandex_music.Track`.
		"""
        if not data:
            return None

        data = super(Track, cls).de_json(data, client)
        from yandex_music import Normalization, Major, Album, Artist
        data['albums'] = Album.de_list(data.get('albums'), client)
        data['artists'] = Artist.de_list(data.get('artists'), client)
        data['normalization'] = Normalization.de_json(
            data.get('normalization'), client)
        data['major'] = Major.de_json(data.get('major'), client)

        return cls(client=client, **data)
예제 #7
0
def normalization():
    return Normalization(TestNormalization.gain, TestNormalization.peak)
    def test_de_json_all(self, client):
        json_dict = {'gain': self.gain, 'peak': self.peak}
        normalization = Normalization.de_json(json_dict, client)

        assert normalization.gain == self.gain
        assert normalization.peak == self.peak
예제 #9
0
 def test_de_json_none(self, client):
     assert Normalization.de_json({}, client) is None