Files
whipper-gui/morituri/test/test_image_cue.py
Thomas Vander Stichele 2f464207db * morituri/image/table.py:
Add logging.
	  Add methods to clear a table of files, and to absolutize indexes
	  as long as the source is the same file, and to set a File on a
	  given index, adjusting all following indexes that match the
	  duration, and check if the IndexTable has all information for a TOC.
	* morituri/image/toc.py:
	  Add logging.
	  Use a counter for the source.
	  Fix up index offset calculation.
	* morituri/program/cdrdao.py:
	  Use a real IndexTable as the result, instead of a TocFile.
	* morituri/image/cue.py:
	  Use a real IndexTable to store tracks.
	* morituri/test/test_image_toc.py:
	  The toc file now has a table which has the tracks.
	  Fix the tests to adjust for wrong index calculations.
	* morituri/test/test_image_cue.py:
	* morituri/test/test_image_image.py:
	* morituri/image/image.py:
	  The cue file now has a table which has the tracks.
	* morituri/test/test_image_table.py:
	  Add assertions to make sure when the table can serve as a TOC.
	* examples/readdisc.py:
	  Adjust for changes.  Fix up to include AccurateRip results.
	  First time we can do a complete normal rip including verifying
	  against AccurateRip results!
2009-05-05 10:01:41 +00:00

79 lines
2.3 KiB
Python

# -*- Mode: Python; test-case-name: morituri.test.test_image_cue -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
import tempfile
import unittest
from morituri.test import common
from morituri.image import table, cue
class KingsSingleTestCase(unittest.TestCase):
def setUp(self):
self.cue = cue.CueFile(os.path.join(os.path.dirname(__file__),
'kings-single.cue'))
self.cue.parse()
self.assertEquals(len(self.cue.table.tracks), 11)
def testGetTrackLength(self):
t = self.cue.table.tracks[0]
self.assertEquals(self.cue.getTrackLength(t), 17811)
# last track has unknown length
t = self.cue.table.tracks[-1]
self.assertEquals(self.cue.getTrackLength(t), -1)
class KingsSeparateTestCase(unittest.TestCase):
def setUp(self):
self.cue = cue.CueFile(os.path.join(os.path.dirname(__file__),
'kings-separate.cue'))
self.cue.parse()
self.assertEquals(len(self.cue.table.tracks), 11)
def testGetTrackLength(self):
# all tracks have unknown length
t = self.cue.table.tracks[0]
self.assertEquals(self.cue.getTrackLength(t), -1)
t = self.cue.table.tracks[-1]
self.assertEquals(self.cue.getTrackLength(t), -1)
class KanyeMixedTestCase(unittest.TestCase):
def setUp(self):
self.cue = cue.CueFile(os.path.join(os.path.dirname(__file__),
'kanye.cue'))
self.cue.parse()
self.assertEquals(len(self.cue.table.tracks), 13)
def testGetTrackLength(self):
t = self.cue.table.tracks[0]
self.assertEquals(self.cue.getTrackLength(t), -1)
class WriteCueFileTestCase(unittest.TestCase):
def testWrite(self):
fd, path = tempfile.mkstemp(suffix='morituri.test.cue')
os.close(fd)
it = table.IndexTable()
t = table.ITTrack(1)
t.index(1, path='track01.wav', relative=0)
it.tracks.append(t)
t = table.ITTrack(2)
t.index(0, path='track01.wav', relative=1000)
t.index(1, path='track02.wav', relative=0)
it.tracks.append(t)
self.assertEquals(it.cue(), """FILE "track01.wav" WAVE
TRACK 01 AUDIO
INDEX 01 00:00:00
TRACK 02 AUDIO
INDEX 00 00:13:25
FILE "track02.wav" WAVE
INDEX 01 00:00:00
""")