Yading/musixmatch-master/tests/apikey.py
Go to the documentation of this file.
1 import unittest
2 from musixmatch import *
3 
4 class TestArtist(unittest.TestCase):
5  def test_Artist(self):
6  a1 = artist.Artist(artist_id=378462)
7  a2 = artist.Artist(artist_mbid='650e7db6-b795-4eb5-a702-5ea2fc46c848')
8  self.assertEqual(a1,a2)
9 
10 class TestArtistsCollection(unittest.TestCase):
11  def test_fromChart(self):
12  c = artist.ArtistsCollection.fromChart(page=1, page_size=10)
13  self.assertEqual(len(c), 10)
14  for i in c:
15  self.assertEqual(type(i), artist.Artist)
16 
17  def test_fromSearch(self):
18  c = artist.ArtistsCollection.fromSearch(
19  q='madonna', page=1, page_size=10)
20  self.assertEqual(len(c), 10)
21  for i in c:
22  self.assertEqual(type(i), artist.Artist)
23 
24 class TestTrack(unittest.TestCase):
25  def test_Track(self):
26  t1 = track.Track(track_id=7176425)
27  t2 = track.Track(track_mbid='a5424f77-42d9-428c-9c6f-3f06ff19d756')
28  self.assertEqual(t1,t2)
29 
30  def test_fromMatcher(self):
31  t = track.Track.fromMatcher(
32  q_track='lose yourself (album version)', q_artist='eminem')
33  self.assertEqual(bool(t), True)
34 
35  def test_get(self):
36  t = track.Track(track_id=6593495)
37  l = t['lyrics']
38  self.assertEqual(bool(l), True)
39  self.assertEqual(type(l), lyrics.Lyrics)
40  s = t.get('subtitle')
41  self.assertEqual(bool(s), True)
42  self.assertEqual(type(s), subtitle.Subtitle)
43 
44 
45 class TestTracksCollection(unittest.TestCase):
46  def test_fromChart(self):
47  c = track.TracksCollection.fromChart(page=1, page_size=10)
48  self.assertEqual(len(c), 10)
49  for i in c:
50  self.assertEqual(type(i), track.Track)
51 
52  def test_fromSearch(self):
53  c = track.TracksCollection.fromSearch(q_track='Cotton eye Joe')
54  self.assertEqual(len(c), 10)
55  for i in c:
56  self.assertEqual(type(i), track.Track)
57 
58 class TestLyrics(unittest.TestCase):
59  def test_Lyrics(self):
60  l = lyrics.Lyrics(track_id='4559887')
61  self.assertEqual(bool(l), True)
62 
63 class TestSubtitle(unittest.TestCase):
64  def test_Subtitle(self):
65  s = subtitle.Subtitle(track_id='6593495')
66  self.assertEqual(bool(s), True)
67 
int len