def test_equality(self, price):
        a = Product(self.product_id, self.type, self.common_period_duration, self.duration, self.trial_duration, price,
                    self.feature, self.debug)
        b = Product(10, self.type, self.common_period_duration, self.duration, self.trial_duration, price,
                    self.feature, self.debug)
        c = Product(self.product_id, self.type, self.common_period_duration, self.duration, self.trial_duration, price,
                    self.feature, self.debug)

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

        assert a == c
Example #2
0
def product(price, licence_text_part):
    return Product(
        TestProduct.product_id,
        TestProduct.type,
        TestProduct.common_period_duration,
        TestProduct.duration,
        TestProduct.trial_duration,
        price,
        TestProduct.feature,
        TestProduct.debug,
        TestProduct.plus,
        TestProduct.cheapest,
        TestProduct.title,
        TestProduct.family_sub,
        TestProduct.fb_image,
        TestProduct.fb_name,
        TestProduct.family,
        TestProduct.features,
        TestProduct.description,
        TestProduct.available,
        TestProduct.trial_available,
        TestProduct.trial_period_duration,
        TestProduct.intro_period_duration,
        price,
        TestProduct.start_period_duration,
        price,
        [licence_text_part],
        TestProduct.vendor_trial_available,
        TestProduct.button_text,
        TestProduct.button_additional_text,
        TestProduct.payment_method_types,
    )
    def test_de_json_all(self, client, price):
        json_dict = {'product_id': self.product_id, 'type': self.type,
                     'common_period_duration': self.common_period_duration, 'duration': self.duration,
                     'trial_duration': self.trial_duration, 'price': price.to_dict(), 'feature': self.feature,
                     'debug': self.debug, 'features': self.features, 'description': self.description,
                     'available': self.available, 'trial_available': self.trial_available,
                     'vendor_trial_available': self.vendor_trial_available, 'button_text': self.button_text,
                     'button_additional_text': self.button_additional_text,
                     'payment_method_types': self.payment_method_types}
        product = Product.de_json(json_dict, client)

        assert product.product_id == self.product_id
        assert product.type == self.type
        assert product.common_period_duration == self.common_period_duration
        assert product.duration == self.duration
        assert product.trial_duration == self.trial_duration
        assert product.price == price
        assert product.feature == self.feature
        assert product.debug == self.debug
        assert product.features == self.features
        assert product.description == self.description
        assert product.available == self.available
        assert product.trial_available == self.trial_available
        assert product.vendor_trial_available == self.vendor_trial_available
        assert product.button_text == self.button_text
        assert product.button_additional_text == self.button_additional_text
        assert product.payment_method_types == self.payment_method_types
Example #4
0
def product(price):
    return Product(TestProduct.product_id, TestProduct.type,
                   TestProduct.common_period_duration, TestProduct.duration,
                   TestProduct.trial_duration, price, TestProduct.feature,
                   TestProduct.debug, TestProduct.features,
                   TestProduct.description, TestProduct.available,
                   TestProduct.trial_available,
                   TestProduct.vendor_trial_available, TestProduct.button_text,
                   TestProduct.button_additional_text,
                   TestProduct.payment_method_types)
Example #5
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)
Example #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.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_required(self, client, price):
        json_dict = {'product_id': self.product_id, 'type': self.type,
                     'common_period_duration': self.common_period_duration, 'duration': self.duration,
                     'trial_duration': self.trial_duration, 'price': price.to_dict(), 'feature': self.feature,
                     'debug': self.debug}
        product = Product.de_json(json_dict, client)

        assert product.product_id == self.product_id
        assert product.type == self.type
        assert product.common_period_duration == self.common_period_duration
        assert product.duration == self.duration
        assert product.trial_duration == self.trial_duration
        assert product.price == price
        assert product.feature == self.feature
        assert product.debug == self.debug
    def de_json(cls, data: dict, client: 'Client') -> Optional['AutoRenewable']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.AutoRenewable`: Информация об автопродлении подписки.
        """
        if not data:
            return None

        data = super(AutoRenewable, cls).de_json(data, client)
        from yandex_music import Product
        data['product'] = Product.de_json(data.get('product'), client)

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

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

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

        data = super(AutoRenewable, cls).de_json(data, client)
        data['product'] = Product.de_json(data.get('product'), client)

        return cls(client=client, **data)
 def test_de_list_none(self, client):
     assert Product.de_list({}, client) == []
 def test_de_json_none(self, client):
     assert Product.de_json({}, client) is None
Example #12
0
    def test_de_json_all(self, client, price, licence_text_part):
        json_dict = {
            'product_id': self.product_id,
            'type_': self.type,
            'common_period_duration': self.common_period_duration,
            'duration': self.duration,
            'trial_duration': self.trial_duration,
            'price': price.to_dict(),
            'feature': self.feature,
            'debug': self.debug,
            'plus': self.plus,
            'features': self.features,
            'description': self.description,
            'available': self.available,
            'trial_available': self.trial_available,
            'vendor_trial_available': self.vendor_trial_available,
            'button_text': self.button_text,
            'button_additional_text': self.button_additional_text,
            'cheapest': self.cheapest,
            'payment_method_types': self.payment_method_types,
            'title': self.title,
            'family': self.family,
            'family_sub': self.family_sub,
            'fb_image': self.fb_image,
            'fb_name': self.fb_name,
            'trial_period_duration': self.trial_period_duration,
            'intro_period_duration': self.intro_period_duration,
            'intro_price': price.to_dict(),
            'start_period_duration': self.start_period_duration,
            'start_price': price.to_dict(),
            'licence_text_parts': [licence_text_part.to_dict()],
        }
        product = Product.de_json(json_dict, client)

        assert product.product_id == self.product_id
        assert product.type == self.type
        assert product.common_period_duration == self.common_period_duration
        assert product.duration == self.duration
        assert product.trial_duration == self.trial_duration
        assert product.price == price
        assert product.feature == self.feature
        assert product.debug == self.debug
        assert product.plus == self.plus
        assert product.cheapest == self.cheapest
        assert product.title == self.title
        assert product.family_sub == self.family_sub
        assert product.fb_image == self.fb_image
        assert product.fb_name == self.fb_name
        assert product.family == self.family
        assert product.features == self.features
        assert product.description == self.description
        assert product.available == self.available
        assert product.trial_available == self.trial_available
        assert product.trial_period_duration == self.trial_period_duration
        assert product.intro_period_duration == self.intro_period_duration
        assert product.intro_price == price
        assert product.start_period_duration == self.start_period_duration
        assert product.start_price == price
        assert product.licence_text_parts == [licence_text_part]
        assert product.vendor_trial_available == self.vendor_trial_available
        assert product.button_text == self.button_text
        assert product.button_additional_text == self.button_additional_text
        assert product.payment_method_types == self.payment_method_types