Esempio n. 1
0
 def testGetLyricsXML(self):
     '''testGetLyricsXML - Ensures the lyrics are fetched correctly'''
     lyrics = LyricsDownloader('On A Plain', 'Nirvana', False)
     lyrics._clean_up_artist_title()
     test_xml = urllib.urlopen(THIS_DIR +
                               '/data/LyricsDownloader/lyrics_xml').read()
     self.assertEqual(lyrics._get_lyrics_xml(), test_xml)
Esempio n. 2
0
 def testCleanUpArtistTitle(self):
     '''testCleanUpArtistTitle - Ensures the artist is converted for use in
     the url'''
     callback = False
     lyrics = LyricsDownloader('Foo', "Test 123 ()$^*=:;|#@}{][!,.-_\\&'",
                               callback)
     lyrics._clean_up_artist_title()
     self.assertEqual(lyrics.artist,
                      'test%20123%20()$^*=:;|#@}{][!,.-_\\%%')
Esempio n. 3
0
 def testParseLyricsXML(self):
     '''testParseLyricsXML - Ensures the lyrics are parsed correctly'''
     callback = False
     lyrics = LyricsDownloader('On A Plain', 'Nirvana', callback)
     test_xml = urllib.urlopen(THIS_DIR +
                               '/data/LyricsDownloader/lyrics_xml').read()
     final_lyrics = lyrics._parse_lyrics_xml(test_xml)
     temp = open(THIS_DIR + '/data/LyricsDownloader/final_lyrics')
     final_lyrics_from_file = temp.read()
     self.assertEqual(final_lyrics, final_lyrics_from_file)
Esempio n. 4
0
 def fetch_lyrics(self, callback=False):
     '''Fetch lyrics from the Internet using the LyricsDownloader, use a
     callback function to indicate completion since LyricsDownloader is
     asynchronous. Callback function must take lyrics as only input
     parameter.'''
     if not callback:
         callback = self.set_lyrics
     if not self.has_lyrics():
         self.ld = LyricsDownloader(self.title, self.artist, callback)
         self.ld.search()
Esempio n. 5
0
 def testLyricsConstructor(self):
     '''testMetadataConstructor - Ensures instantiation of Lyric Downloader
     class'''
     callback = False
     lyrics = LyricsDownloader('Foo', 'Bar', callback)
     self.assertTrue(isinstance(lyrics, LyricsDownloader))