Files
whipper-gui/morituri/test/test_image_toc.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

100 lines
3.4 KiB
Python

# -*- Mode: Python; test-case-name: morituri.test.test_image_cue -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
import unittest
from morituri.image import toc
class CureTestCase(unittest.TestCase):
def setUp(self):
self.toc = toc.TocFile(os.path.join(os.path.dirname(__file__),
'cure.toc'))
self.toc.parse()
self.assertEquals(len(self.toc.table.tracks), 13)
def testGetTrackLength(self):
t = self.toc.table.tracks[0]
# first track has known length because the .toc is a single file
self.assertEquals(self.toc.getTrackLength(t), 28324)
# last track has unknown length
t = self.toc.table.tracks[-1]
self.assertEquals(self.toc.getTrackLength(t), -1)
def testIndexes(self):
# track 2, index 0 is at 06:16:45
# FIXME: cdrdao seems to get length of FILE 1 frame too many,
# and START value one frame less
t = self.toc.table.tracks[1]
self.assertEquals(t.getIndex(0).relative, 28245)
self.assertEquals(t.getIndex(1).relative, 28324)
def _getIndex(self, t, i):
track = self.toc.table.tracks[t - 1]
return track.getIndex(i)
def _assertAbsolute(self, t, i, value):
index = self._getIndex(t, i)
self.assertEquals(index.absolute, value)
def _assertPath(self, t, i, value):
index = self._getIndex(t, i)
self.assertEquals(index.path, value)
def _assertRelative(self, t, i, value):
index = self._getIndex(t, i)
self.assertEquals(index.relative, value)
def testSetFile(self):
self._assertAbsolute(1, 1, None)
self._assertAbsolute(2, 0, None)
self._assertAbsolute(2, 1, None)
self._assertPath(1, 1, "data.wav")
def dump():
for t in self.toc.table.tracks:
print t
print t.indexes.values()
self.toc.table.absolutize()
self.toc.table.clearFiles()
self._assertAbsolute(1, 1, 0)
self._assertAbsolute(2, 0, 28166)
self._assertAbsolute(2, 1, 28324)
self._assertAbsolute(3, 1, 46110)
self._assertAbsolute(4, 1, 66767)
self._assertPath(1, 1, None)
self._assertRelative(1, 1, None)
# adding a file to the table should fix up to including 2, 0
self.toc.table.setFile(1, 1, 'track01.wav', 28245)
self._assertPath(1, 1, 'track01.wav')
self._assertRelative(1, 1, 0)
self._assertPath(2, 0, 'track01.wav')
self._assertAbsolute(2, 0, 28166)
self._assertPath(2, 1, None)
self._assertRelative(2, 1, None)
# Bloc Party - Silent Alarm has a Hidden Track One Audio
class BlocTestCase(unittest.TestCase):
def setUp(self):
self.toc = toc.TocFile(os.path.join(os.path.dirname(__file__),
'bloc.toc'))
self.toc.parse()
self.assertEquals(len(self.toc.table.tracks), 13)
def testGetTrackLength(self):
t = self.toc.table.tracks[0]
# first track has known length because the .toc is a single file
self.assertEquals(self.toc.getTrackLength(t), 50089)
# last track has unknown length
t = self.toc.table.tracks[-1]
self.assertEquals(self.toc.getTrackLength(t), -1)
def testIndexes(self):
t = self.toc.table.tracks[0]
self.assertEquals(t.getIndex(0).relative, 0)
self.assertEquals(t.getIndex(1).relative, 15220)