def test_equality(self):
        a = Price(self.amount, self.currency)
        b = Price(10, self.currency)
        c = Price(self.amount, 'USD')
        d = Price(self.amount, self.currency)

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

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

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

        Returns:
            :obj:`yandex_music.Product`: Продаваемый продукт.
        """
        if not data:
            return None

        data = super(Product, cls).de_json(data, client)
        from yandex_music import Price, LicenceTextPart

        data['price'] = Price.de_json(data.get('price'), client)
        data['intro_price'] = Price.de_json(data.get('intro_price'), client)
        data['start_price'] = Price.de_json(data.get('start_price'), client)
        data['licence_text_parts'] = LicenceTextPart.de_list(
            data.get('licence_text_parts'), client)

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

        data = super(Product, cls).de_json(data, client)
        data['price'] = Price.de_json(data.get('price'), client)

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

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

        Returns:
            :obj:`yandex_music.Settings`: Предложение по покупке.
        """
        if not data:
            return None

        data = super(Settings, cls).de_json(data, client)
        from yandex_music import Product, Price

        data['in_app_products'] = Product.de_list(data.get('in_app_products'), client)
        data['native_products'] = Product.de_list(data.get('native_products'), client)
        data['web_payment_month_product_price'] = Price.de_json(data.get('web_payment_month_product_price'), client)

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

        data = super(Settings, cls).de_json(data, client)
        from yandex_music import Product, Price
        data['in_app_products'] = Product.de_list(data.get('in_app_products'),
                                                  client)
        data['native_products'] = Product.de_list(data.get('native_products'),
                                                  client)
        data['web_payment_month_product_price'] = \
            Price.de_json(data.get('web_payment_month_product_price'), client)

        return cls(client=client, **data)
    def test_de_json_all(self, client):
        json_dict = {'amount': self.amount, 'currency': self.currency}
        price = Price.de_json(json_dict, client)

        assert price.amount == self.amount
        assert price.currency == self.currency
 def test_de_json_none(self, client):
     assert Price.de_json({}, client) is None
Beispiel #8
0
def price():
    return Price(TestPrice.amount, TestPrice.currency)