test_mix_link.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. from yandex_music import MixLink
  2. class TestMixLink:
  3. title = 'Беларусь'
  4. url = '/tag/belarus'
  5. url_scheme = 'yandexmusic://tag/belarus'
  6. text_color = '#6c65a9'
  7. background_color = 'transparent'
  8. background_image_uri = (
  9. 'avatars.yandex.net/get-music-misc/28592/mix.5cf0bd5e58ea3a1e70caa07b.background-image.1559281047248/%%'
  10. )
  11. cover_white = 'avatars.yandex.net/get-music-misc/28052/mix.5cf0bd5e58ea3a1e70caa07b.cover-white.1559281049219/%%'
  12. cover_uri = 'avatars.yandex.net/get-music-misc/34161/mix.57c6d15a2d3213a86ac653d2.cover.1555818786846/%%'
  13. def test_expected_values(self, mix_link):
  14. assert mix_link.title == self.title
  15. assert mix_link.url == self.url
  16. assert mix_link.url_scheme == self.url_scheme
  17. assert mix_link.text_color == self.text_color
  18. assert mix_link.background_color == self.background_color
  19. assert mix_link.background_image_uri == self.background_image_uri
  20. assert mix_link.cover_white == self.cover_white
  21. assert mix_link.cover_uri == self.cover_uri
  22. def test_de_json_none(self, client):
  23. assert MixLink.de_json({}, client) is None
  24. def test_de_list_none(self, client):
  25. assert MixLink.de_list([], client) == []
  26. def test_de_json_required(self, client):
  27. json_dict = {
  28. 'title': self.title,
  29. 'url': self.url,
  30. 'url_scheme': self.url_scheme,
  31. 'text_color': self.text_color,
  32. 'background_color': self.background_color,
  33. 'background_image_uri': self.background_image_uri,
  34. }
  35. mix_link = MixLink.de_json(json_dict, client)
  36. assert mix_link.title == self.title
  37. assert mix_link.url == self.url
  38. assert mix_link.url_scheme == self.url_scheme
  39. assert mix_link.text_color == self.text_color
  40. assert mix_link.background_color == self.background_color
  41. assert mix_link.background_image_uri == self.background_image_uri
  42. def test_de_json_all(self, client):
  43. json_dict = {
  44. 'title': self.title,
  45. 'url': self.url,
  46. 'url_scheme': self.url_scheme,
  47. 'text_color': self.text_color,
  48. 'background_color': self.background_color,
  49. 'background_image_uri': self.background_image_uri,
  50. 'cover_white': self.cover_white,
  51. 'cover_uri': self.cover_uri,
  52. }
  53. mix_link = MixLink.de_json(json_dict, client)
  54. assert mix_link.title == self.title
  55. assert mix_link.url == self.url
  56. assert mix_link.url_scheme == self.url_scheme
  57. assert mix_link.text_color == self.text_color
  58. assert mix_link.background_color == self.background_color
  59. assert mix_link.background_image_uri == self.background_image_uri
  60. assert mix_link.cover_white == self.cover_white
  61. assert mix_link.cover_uri == self.cover_uri
  62. def test_equality(self):
  63. a = MixLink(
  64. self.title,
  65. self.url,
  66. self.url_scheme,
  67. self.text_color,
  68. self.background_color,
  69. self.background_image_uri,
  70. )
  71. b = MixLink(
  72. self.title,
  73. self.url,
  74. '',
  75. self.text_color,
  76. self.background_color,
  77. self.background_image_uri,
  78. )
  79. c = MixLink(
  80. self.title,
  81. self.url,
  82. self.url_scheme,
  83. '#000000',
  84. self.background_color,
  85. self.background_image_uri,
  86. )
  87. d = MixLink(
  88. self.title,
  89. self.url,
  90. self.url_scheme,
  91. self.text_color,
  92. self.background_color,
  93. self.background_image_uri,
  94. )
  95. assert a != b != c
  96. assert hash(a) != hash(b) != hash(c)
  97. assert a is not b is not c
  98. assert a == d