test_track_lyrics.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. from yandex_music import TrackLyrics
  2. class TestTrackLyrics:
  3. download_url = 'https://music-lyrics.s3-private.mds.yandex.net/8145339.f0f2e9e0/37320085?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20221113T085654Z&X-Amz-SignedHeaders=host&X-Amz-Expires=86400&X-Amz-Credential=B8LQDON9RSp6Pcbw1Hxz%2F20221113%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=148de126a9ca9a91cb157e6032d178c39bf604d2e4acec6155d81e51090533ac'
  4. lyric_id = 8145339
  5. external_lyric_id = '8638863'
  6. writer = ['Mother Mother']
  7. def test_expected_values(self, track_lyrics, lyrics_major):
  8. assert track_lyrics.download_url == self.download_url
  9. assert track_lyrics.lyric_id == self.lyric_id
  10. assert track_lyrics.external_lyric_id == self.external_lyric_id
  11. assert track_lyrics.writers == self.writer
  12. assert track_lyrics.major == lyrics_major
  13. def test_de_json_none(self, client):
  14. assert TrackLyrics.de_json({}, client) is None
  15. def test_de_json_required(self, client, lyrics_major):
  16. json_dict = {
  17. 'download_url': self.download_url,
  18. 'lyric_id': self.lyric_id,
  19. 'external_lyric_id': self.external_lyric_id,
  20. 'writers': self.writer,
  21. 'major': lyrics_major.to_dict(),
  22. }
  23. track_lyrics = TrackLyrics.de_json(json_dict, client)
  24. assert track_lyrics.download_url == self.download_url
  25. assert track_lyrics.lyric_id == self.lyric_id
  26. assert track_lyrics.external_lyric_id == self.external_lyric_id
  27. assert track_lyrics.writers == self.writer
  28. assert track_lyrics.major == lyrics_major
  29. def test_de_json_all(self, client, lyrics_major):
  30. json_dict = {
  31. 'download_url': self.download_url,
  32. 'lyric_id': self.lyric_id,
  33. 'external_lyric_id': self.external_lyric_id,
  34. 'writers': self.writer,
  35. 'major': lyrics_major.to_dict(),
  36. }
  37. track_lyrics = TrackLyrics.de_json(json_dict, client)
  38. assert track_lyrics.download_url == self.download_url
  39. assert track_lyrics.lyric_id == self.lyric_id
  40. assert track_lyrics.external_lyric_id == self.external_lyric_id
  41. assert track_lyrics.writers == self.writer
  42. assert track_lyrics.major == lyrics_major
  43. def test_equality(self, lyrics_major):
  44. a = TrackLyrics(self.download_url, self.lyric_id, self.external_lyric_id, self.writer, lyrics_major)
  45. b = TrackLyrics(self.download_url, 50, self.external_lyric_id, self.writer, lyrics_major)
  46. c = TrackLyrics(self.download_url, self.lyric_id, self.external_lyric_id, self.writer, lyrics_major)
  47. assert a != b
  48. assert hash(a) != hash(b)
  49. assert a is not b
  50. assert a == c