test_brand.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. from yandex_music import Brand
  2. class TestBrand:
  3. image = 'https://avatars.mds.yandex.net/get-music-misc/2419084/img.5dbb0478e482b01822a89af8/%%'
  4. background = '#2A2A2A'
  5. reference = 'yandexmusic://post/5c94a7bf433f8221feac3fa6'
  6. pixels = [
  7. 'http://ads6.adfox.ru/256152/event?hash=84862c423eb&rand=eo=hdxqd&pr=deyq&p1=bwzel',
  8. 'http://banners.adfox.ru/transparent.gif',
  9. ]
  10. theme = 'dark'
  11. playlist_theme = ''
  12. button = 'Больше подкастов'
  13. def test_expected_values(self, brand):
  14. assert brand.image == self.image
  15. assert brand.background == self.background
  16. assert brand.reference == self.reference
  17. assert brand.pixels == self.pixels
  18. assert brand.theme == self.theme
  19. assert brand.playlist_theme == self.playlist_theme
  20. assert brand.button == self.button
  21. def test_de_json_none(self, client):
  22. assert Brand.de_json({}, client) is None
  23. def test_de_json_required(self, client):
  24. json_dict = {
  25. 'image': self.image,
  26. 'background': self.background,
  27. 'reference': self.reference,
  28. 'pixels': self.pixels,
  29. 'theme': self.theme,
  30. 'playlist_theme': self.playlist_theme,
  31. 'button': self.button,
  32. }
  33. brand = Brand.de_json(json_dict, client)
  34. assert brand.image == self.image
  35. assert brand.background == self.background
  36. assert brand.reference == self.reference
  37. assert brand.pixels == self.pixels
  38. assert brand.theme == self.theme
  39. assert brand.playlist_theme == self.playlist_theme
  40. assert brand.button == self.button
  41. def test_de_json_all(self, client):
  42. json_dict = {
  43. 'image': self.image,
  44. 'background': self.background,
  45. 'reference': self.reference,
  46. 'pixels': self.pixels,
  47. 'theme': self.theme,
  48. 'playlist_theme': self.playlist_theme,
  49. 'button': self.button,
  50. }
  51. brand = Brand.de_json(json_dict, client)
  52. assert brand.image == self.image
  53. assert brand.background == self.background
  54. assert brand.reference == self.reference
  55. assert brand.pixels == self.pixels
  56. assert brand.theme == self.theme
  57. assert brand.playlist_theme == self.playlist_theme
  58. assert brand.button == self.button
  59. def test_equality(self):
  60. a = Brand(
  61. self.image, self.background, self.reference, self.pixels, self.theme, self.playlist_theme, self.button
  62. )
  63. b = Brand('', self.background, self.reference, ['link'], self.theme, self.playlist_theme, self.button)
  64. c = Brand(
  65. self.image, self.background, self.reference, self.pixels, self.theme, self.playlist_theme, self.button
  66. )
  67. assert a != b
  68. assert hash(a) != hash(b)
  69. assert a is not b
  70. assert a == c