~andrewsomething/exaile/karmic

« back to all changes in this revision

Viewing changes to tests/lyrics.py

  • Committer: Aren Olson
  • Date: 2009-09-12 00:36:59 UTC
  • Revision ID: reacocard@gmail.com-20090912003659-w373sg0n04uoa8op
remove useless files, add soem of the fixes from lp bug 420019

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from tests.base import BaseTestCase
2
 
import unittest, time, shutil, sys
3
 
from xl.lyrics import LyricsManager
4
 
from xl.lyrics import LyricsNotFoundException
5
 
from xl.track import Track
6
 
 
7
 
import os, imp
8
 
 
9
 
class LyricsBaseTestCase(BaseTestCase):
10
 
    """
11
 
        Test loading lyrics from various plugins and saving
12
 
        embedded lyrics to supported formats
13
 
    """
14
 
    
15
 
    def setUp(self):
16
 
        BaseTestCase.setUp(self)
17
 
        self.plugindirs = 'plugins'
18
 
        self.lyrics = LyricsManager()
19
 
        # Create a track object
20
 
        # (copying the file here so that it doesn't keep updating in bzr when
21
 
        # the lyrics manager finds the lyrics and changes the file)
22
 
        shutil.copyfile('tests/data/music/delerium/chimera/05 - Truly.mp3', 
23
 
            '.testtemp/truly.mp3')
24
 
        self.track = Track(".testtemp/truly.mp3")
25
 
        self.fail_track = Track("tests/data/music/testartist/first/1-black.ogg")
26
 
        # Setup plugins
27
 
        self.lyricsfly_plugin =  self.load_plugin("lyricsfly")
28
 
        self.lyricsfly_plugin.enable(self)
29
 
        # Remove all existing methods from lyrics manager
30
 
        for method in self.lyrics.get_providers():
31
 
            self.lyrics.remove_search_method(method)
32
 
 
33
 
 
34
 
class LyricsTestCase(LyricsBaseTestCase):
35
 
    def setUp(self):
36
 
        LyricsBaseTestCase.setUp(self)
37
 
        
38
 
    
39
 
    def testFetchLyricsMp3(self):
40
 
        """
41
 
            Test fetching lyrics from the file itself
42
 
        """
43
 
        #Local searching is added by default
44
 
        self.lyrics.add_defaults()
45
 
        (lyrics, source, url) = self.lyrics.find_lyrics(self.track)
46
 
        assert(len(lyrics) > 0), "Lyrics search failed"
47
 
        assert(source == "file"), "Lyrics came from wrong source"
48
 
        
49
 
    def testFetchLyricsFail(self):
50
 
        """
51
 
            Test the failing when not finding lyrics works
52
 
            correctly
53
 
        """
54
 
        #Local searching is added by default
55
 
        self.lyrics.add_defaults()
56
 
        self.failUnlessRaises(LyricsNotFoundException, self.lyrics.find_lyrics,self.fail_track)
57
 
        
58
 
    def testSaveLyricsMp3(self):
59
 
        """
60
 
            Test saving lyrics to an mp3 file (ID3 tags)
61
 
        """
62
 
        # Enable plugins to get the track data
63
 
        self.lyrics.add_defaults()
64
 
        self.lyricsfly_plugin = self.load_plugin('lyricsfly')
65
 
        self.lyricsfly_plugin.enable(self)
66
 
        # Update the track with new lyrics
67
 
        # Get the lyrics from online by forcing, and update the track
68
 
        (lyrics, source, url) = self.lyrics.find_lyrics(self.track, True)
69
 
        # Load the track to see if it saved
70
 
        track = Track("tests/data/music/delerium/chimera/05 - Truly.mp3")
71
 
 
72
 
        assert(track["lyrics"][0] == self.track["lyrics"][0]), "Lyrics not saved to track"
73
 
        
74
 
    def testSaveLyricsOgg(self):
75
 
        """
76
 
            Test saving lyrics to an ogg file 
77
 
        """
78
 
        # TODO find out how ogg/vorbis do their lyrics
79
 
        assert(True)