2019-11-08 02:09:39 +09:00
|
|
|
from yandex_music import Product
|
|
|
|
|
|
|
|
|
|
|
|
class TestProduct:
|
2019-11-08 06:37:53 +09:00
|
|
|
product_id = 'ru.yandex.mobile.music.1month.autorenewable.native.web.notrial.restricted.cache.99'
|
|
|
|
type = 'subscription'
|
|
|
|
common_period_duration = 'P1M'
|
|
|
|
description = None
|
|
|
|
duration = 30
|
|
|
|
trial_duration = 0
|
2019-12-28 22:25:09 +09:00
|
|
|
feature = 'basic-music'
|
2019-11-08 06:37:53 +09:00
|
|
|
debug = False
|
2020-04-17 02:56:45 +09:00
|
|
|
plus = False
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
cheapest = True
|
|
|
|
title = 'КиноПоиск HD'
|
|
|
|
family_sub = False
|
|
|
|
fb_image = ''
|
|
|
|
fb_name = 'kinopoisk-plus'
|
|
|
|
family = False
|
2019-12-28 22:25:09 +09:00
|
|
|
features = ['basic-music']
|
2019-11-08 02:09:39 +09:00
|
|
|
available = None
|
|
|
|
trial_available = None
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
trial_period_duration = 'P1M'
|
|
|
|
intro_period_duration = 'P1Y'
|
|
|
|
start_period_duration = 'P1M'
|
2019-11-08 02:09:39 +09:00
|
|
|
vendor_trial_available = None
|
|
|
|
button_text = None
|
|
|
|
button_additional_text = None
|
|
|
|
payment_method_types = None
|
|
|
|
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
def test_expected_values(self, product, price, licence_text_part):
|
2019-11-08 02:09:39 +09:00
|
|
|
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
|
2020-04-17 02:56:45 +09:00
|
|
|
assert product.plus == self.plus
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
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
|
2019-11-08 02:09:39 +09:00
|
|
|
assert product.features == self.features
|
2019-11-08 06:37:53 +09:00
|
|
|
assert product.description == self.description
|
2019-11-08 02:09:39 +09:00
|
|
|
assert product.available == self.available
|
|
|
|
assert product.trial_available == self.trial_available
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
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]
|
2019-11-08 02:09:39 +09:00
|
|
|
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
|
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert Product.de_json({}, client) is None
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
def test_de_list_none(self, client):
|
|
|
|
assert Product.de_list({}, client) == []
|
|
|
|
|
2019-11-08 02:09:39 +09:00
|
|
|
def test_de_json_required(self, client, price):
|
2021-02-03 21:28:10 +09:00
|
|
|
json_dict = {
|
|
|
|
'product_id': self.product_id,
|
2021-09-19 22:47:19 +09:00
|
|
|
'type': self.type,
|
2021-02-03 21:28:10 +09:00
|
|
|
'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,
|
|
|
|
}
|
2019-11-08 02:09:39 +09:00
|
|
|
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
|
2020-04-17 02:56:45 +09:00
|
|
|
assert product.plus == self.plus
|
2019-11-08 02:09:39 +09:00
|
|
|
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
def test_de_json_all(self, client, price, licence_text_part):
|
2021-02-03 21:28:10 +09:00
|
|
|
json_dict = {
|
|
|
|
'product_id': self.product_id,
|
2021-09-19 22:47:19 +09:00
|
|
|
'type': self.type,
|
2021-02-03 21:28:10 +09:00
|
|
|
'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()],
|
|
|
|
}
|
2019-11-08 02:09:39 +09:00
|
|
|
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
|
2020-04-17 02:56:45 +09:00
|
|
|
assert product.plus == self.plus
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
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
|
2019-11-08 02:09:39 +09:00
|
|
|
assert product.features == self.features
|
2019-11-08 06:37:53 +09:00
|
|
|
assert product.description == self.description
|
2019-11-08 02:09:39 +09:00
|
|
|
assert product.available == self.available
|
|
|
|
assert product.trial_available == self.trial_available
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
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]
|
2019-11-08 02:09:39 +09:00
|
|
|
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
|
|
|
|
|
2019-11-08 06:37:53 +09:00
|
|
|
def test_equality(self, price):
|
2021-02-03 21:28:10 +09:00
|
|
|
a = Product(
|
|
|
|
self.product_id,
|
|
|
|
self.type,
|
|
|
|
self.common_period_duration,
|
|
|
|
self.duration,
|
|
|
|
self.trial_duration,
|
|
|
|
price,
|
|
|
|
self.feature,
|
|
|
|
self.debug,
|
|
|
|
self.plus,
|
|
|
|
)
|
|
|
|
b = Product(
|
|
|
|
'',
|
|
|
|
self.type,
|
|
|
|
self.common_period_duration,
|
|
|
|
self.duration,
|
|
|
|
self.trial_duration,
|
|
|
|
price,
|
|
|
|
self.feature,
|
|
|
|
self.debug,
|
|
|
|
self.plus,
|
|
|
|
)
|
|
|
|
c = Product(
|
|
|
|
self.product_id,
|
|
|
|
self.type,
|
|
|
|
self.common_period_duration,
|
|
|
|
self.duration,
|
|
|
|
self.trial_duration,
|
|
|
|
price,
|
|
|
|
self.feature,
|
|
|
|
self.debug,
|
|
|
|
self.plus,
|
|
|
|
)
|
2019-11-08 06:37:53 +09:00
|
|
|
|
|
|
|
assert a != b
|
|
|
|
assert hash(a) != hash(b)
|
|
|
|
|
|
|
|
assert a == c
|