test_cover.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. from yandex_music import Cover
  2. class TestCover:
  3. type = 'pic'
  4. uri = 'avatars.yandex.net/get-music-user-playlist/38125/q0ahkhfQE3neTk/%%?1572609906461'
  5. items_uri = [
  6. 'avatars.yandex.net/get-music-user-playlist/38125/q0ahkhfQE3neTk/%%?1572609906461',
  7. 'avatars.yandex.net/get-music-user-playlist/38125/q0ahkhfQE3neTk/%%?1572609906461',
  8. ]
  9. dir = '/get-music-user-playlist/34120/pvg900XixWaHcr/'
  10. version = '1572609906461'
  11. custom = True
  12. is_custom = True
  13. prefix = None
  14. copyright_name = 'ТАСС'
  15. copyright_cline = 'imago stock&people'
  16. error = None
  17. def test_expected_values(self, cover):
  18. assert cover.type == self.type
  19. assert cover.uri == self.uri
  20. assert cover.items_uri == self.items_uri
  21. assert cover.dir == self.dir
  22. assert cover.version == self.version
  23. assert cover.custom == self.custom
  24. assert cover.is_custom == self.is_custom
  25. assert cover.copyright_name == self.copyright_name
  26. assert cover.copyright_cline == self.copyright_cline
  27. assert cover.prefix == self.prefix
  28. assert cover.error == self.error
  29. def test_de_json_none(self, client):
  30. assert Cover.de_json({}, client) is None
  31. def test_de_list_none(self, client):
  32. assert Cover.de_list([], client) == []
  33. def test_de_json_required(self, client):
  34. json_dict = {}
  35. Cover.de_json(json_dict, client)
  36. def test_de_json_all(self, client):
  37. json_dict = {
  38. 'type': self.type,
  39. 'uri': self.uri,
  40. 'items_uri': self.items_uri,
  41. 'dir': self.dir,
  42. 'version': self.version,
  43. 'custom': self.custom,
  44. 'is_custom': self.is_custom,
  45. 'prefix': self.prefix,
  46. 'error': self.error,
  47. 'copyright_name': self.copyright_name,
  48. 'copyright_cline': self.copyright_cline,
  49. }
  50. cover = Cover.de_json(json_dict, client)
  51. assert cover.type == self.type
  52. assert cover.uri == self.uri
  53. assert cover.items_uri == self.items_uri
  54. assert cover.dir == self.dir
  55. assert cover.version == self.version
  56. assert cover.custom == self.custom
  57. assert cover.is_custom == self.is_custom
  58. assert cover.copyright_name == self.copyright_name
  59. assert cover.copyright_cline == self.copyright_cline
  60. assert cover.prefix == self.prefix
  61. assert cover.error == self.error
  62. def test_equality(self, images):
  63. a = Cover(self.type, self.uri, self.items_uri)
  64. assert a != images
  65. assert hash(a) != hash(images)
  66. assert a is not images