~ubuntu-branches/ubuntu/raring/soundconverter/raring-201211220242

« back to all changes in this revision

Viewing changes to src/soundconverterTests.py

  • Committer: Bazaar Package Importer
  • Author(s): William Alexander Grant
  • Date: 2006-09-25 07:25:55 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060925072555-x4bd5pj4y6dhl86d
Tags: 0.9.1-0ubuntu1
* Preemptive fake sync from Sid. This is actually 0.9.1-1.
* New upstream release.
  - Change gstreamer0.8* dependencies to the equivalent gstreamer0.10 ones
    (Closes: #380473).
  - Drop the Debian .desktop, as there's now one included upstream.
  - Use CDBS, as the new upstream uses autotools.
  - Add python-gtk2 to Build-Depends-Indep, due to autotools detection.
* Bumped debhelper dependency to >= 5.
* New maintainer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import unittest
 
2
from soundconverter import *
 
3
 
 
4
class TargetNameGeneratorTestCases(unittest.TestCase):
 
5
 
 
6
    def setUp(self):
 
7
        self.g = TargetNameGenerator()
 
8
        self.g.set_exists(self.never_exists)
 
9
        self.g.set_replace_messy_chars(True)
 
10
 
 
11
        self.s = SoundFile("file:///path/to/file.flac")
 
12
        self.s.add_tags({
 
13
            "artist": "Foo Bar", 
 
14
            "title": "Hi Ho", 
 
15
            "album": "IS: TOO",
 
16
            "track-number": 1L,
 
17
            "track-count": 11L,
 
18
        })
 
19
        
 
20
    def tearDown(self):
 
21
        self.g = None
 
22
        self.s = None
 
23
 
 
24
    def never_exists(self, pathname):
 
25
        return False
 
26
        
 
27
    def always_exists(self, pathname):
 
28
        return True
 
29
        
 
30
    def testSuffix(self):
 
31
        self.g.set_target_suffix(".ogg")
 
32
        self.failUnlessEqual(self.g.get_target_name(self.s),
 
33
                             "file:///path/to/file.ogg")
 
34
 
 
35
    def testBasename(self):
 
36
        self.g.set_target_suffix(".ogg")
 
37
        self.g.set_basename_pattern("%(track-number)02d-%(title)s")
 
38
        self.failUnlessEqual(self.g.get_target_name(self.s),
 
39
                             "file:///path/to/01-Hi_Ho.ogg")
 
40
 
 
41
    def testLocation(self):
 
42
        self.g.set_target_suffix(".ogg")
 
43
        self.g.set_folder("/music")
 
44
        self.g.set_subfolder_pattern("%(artist)s/%(album)s")
 
45
        self.g.set_basename_pattern("%(track-number)02d-%(title)s")
 
46
        self.failUnlessEqual(self.g.get_target_name(self.s),
 
47
                             "file:///music/Foo_Bar/IS__TOO/01-Hi_Ho.ogg")
 
48
 
 
49
    def testTargetExists(self):
 
50
        self.g.set_exists(self.always_exists)
 
51
        self.g.set_target_suffix(".ogg")
 
52
        self.g.set_folder("/")
 
53
        self.failUnlessRaises(TargetNameCreationFailure,
 
54
                              self.g.get_target_name,
 
55
                              self.s)
 
56
 
 
57
 
 
58
if __name__ == "__main__":
 
59
    unittest.main()