2019-11-08 02:09:39 +09:00
|
|
|
from yandex_music import AutoRenewable
|
|
|
|
|
|
|
|
|
|
|
|
class TestAutoRenewable:
|
2019-11-08 06:37:53 +09:00
|
|
|
expires = '2019-11-30T23:59:59+03:00'
|
|
|
|
vendor = 'Yandex'
|
|
|
|
vendor_help_url = 'https://www.yandex.ru/support/music-app/subscription.xml'
|
|
|
|
product_id = 'ru.yandex.mobile.music.1month.autorenewable.native.web.notrial.restricted.cache.99'
|
|
|
|
finished = False
|
|
|
|
order_id = 39385401
|
2019-11-08 02:09:39 +09:00
|
|
|
|
|
|
|
def test_expected_values(self, auto_renewable, product):
|
|
|
|
assert auto_renewable.expires == self.expires
|
|
|
|
assert auto_renewable.vendor == self.vendor
|
|
|
|
assert auto_renewable.vendor_help_url == self.vendor_help_url
|
|
|
|
assert auto_renewable.product_id == self.product_id
|
|
|
|
assert auto_renewable.product == product
|
|
|
|
assert auto_renewable.finished == self.finished
|
|
|
|
assert auto_renewable.order_id == self.order_id
|
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert AutoRenewable.de_json({}, client) is None
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
def test_de_list_none(self, client):
|
|
|
|
assert AutoRenewable.de_list({}, client) == []
|
|
|
|
|
2019-11-08 02:09:39 +09:00
|
|
|
def test_de_json_required(self, client, product):
|
|
|
|
json_dict = {'expires': self.expires, 'vendor': self.vendor, 'vendor_help_url': self.vendor_help_url,
|
2020-01-26 09:49:35 +09:00
|
|
|
'product': product.to_dict(), 'finished': self.finished}
|
2019-11-08 02:09:39 +09:00
|
|
|
auto_renewable = AutoRenewable.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert auto_renewable.expires == self.expires
|
|
|
|
assert auto_renewable.vendor == self.vendor
|
|
|
|
assert auto_renewable.vendor_help_url == self.vendor_help_url
|
|
|
|
assert auto_renewable.product == product
|
|
|
|
assert auto_renewable.finished == self.finished
|
|
|
|
|
|
|
|
def test_de_json_all(self, client, product):
|
|
|
|
json_dict = {'expires': self.expires, 'vendor': self.vendor, 'vendor_help_url': self.vendor_help_url,
|
2019-11-08 06:37:53 +09:00
|
|
|
'product_id': self.product_id, 'product': product.to_dict(), 'finished': self.finished,
|
2019-11-08 02:09:39 +09:00
|
|
|
'order_id': self.order_id}
|
|
|
|
auto_renewable = AutoRenewable.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert auto_renewable.expires == self.expires
|
|
|
|
assert auto_renewable.vendor == self.vendor
|
|
|
|
assert auto_renewable.vendor_help_url == self.vendor_help_url
|
|
|
|
assert auto_renewable.product_id == self.product_id
|
|
|
|
assert auto_renewable.product == product
|
|
|
|
assert auto_renewable.finished == self.finished
|
|
|
|
assert auto_renewable.order_id == self.order_id
|
|
|
|
|
2019-11-08 06:37:53 +09:00
|
|
|
def test_equality(self, product):
|
2020-01-26 09:49:35 +09:00
|
|
|
a = AutoRenewable(self.expires, self.vendor, self.vendor_help_url, product, self.finished)
|
|
|
|
b = AutoRenewable(self.expires, '', self.vendor_help_url, None, self.finished)
|
|
|
|
c = AutoRenewable(self.expires, self.vendor, self.vendor_help_url, product, self.finished)
|
2019-11-08 06:37:53 +09:00
|
|
|
|
|
|
|
assert a != b
|
|
|
|
assert hash(a) != hash(b)
|
|
|
|
assert a is not b
|
|
|
|
|
|
|
|
assert a == c
|