def test_toc_musicbrainz_data_last(self): toc = cueify.TOC() self.assertTrue( toc.deserialize( struct.pack("B" * len(serialized_data_last_toc), *serialized_data_last_toc))) sessions = cueify.Sessions() self.assertTrue( sessions.deserialize( struct.pack("B" * len(serialized_data_last_sessions), *serialized_data_last_sessions))) self.assertEqual(toc.musicbrainzID(), DATA_LAST_MUSICBRAINZ_ID) self.assertEqual(toc.musicbrainzID(None), DATA_LAST_MUSICBRAINZ_ID) self.assertEqual(toc.musicbrainzID(sessions), DATA_LAST_MUSICBRAINZ_ID)
def test_toc_musicbrainz_cdda(self): toc = cueify.TOC() self.assertTrue( toc.deserialize( struct.pack("B" * len(serialized_cdda_toc), *serialized_cdda_toc))) sessions = cueify.Sessions() self.assertTrue( sessions.deserialize( struct.pack("B" * len(serialized_cdda_sessions), *serialized_cdda_sessions))) self.assertEqual(toc.musicbrainzID(), CDDA_MUSICBRAINZ_ID) self.assertEqual(toc.musicbrainzID(None), CDDA_MUSICBRAINZ_ID) self.assertEqual(toc.musicbrainzID(sessions), CDDA_MUSICBRAINZ_ID)
def test_toc_freedb_data_last(self): toc = cueify.TOC() self.assertTrue( toc.deserialize( struct.pack("B" * len(serialized_data_last_toc), *serialized_data_last_toc))) sessions = cueify.Sessions() self.assertTrue( sessions.deserialize( struct.pack("B" * len(serialized_data_last_sessions), *serialized_data_last_sessions))) self.assertEqual(toc.freedbID(), DATA_LAST_FREEDB_ID) self.assertEqual(toc.freedbID(None), DATA_LAST_FREEDB_ID) self.assertEqual(toc.freedbID(sessions), DATA_LAST_LIBDISCID_FREEDB_ID)
def test_toc_freedb_cdda(self): toc = cueify.TOC() self.assertTrue( toc.deserialize( struct.pack("B" * len(serialized_cdda_toc), *serialized_cdda_toc))) sessions = cueify.Sessions() self.assertTrue( sessions.deserialize( struct.pack("B" * len(serialized_cdda_sessions), *serialized_cdda_sessions))) self.assertEqual(toc.freedbID(), CDDA_FREEDB_ID) self.assertEqual(toc.freedbID(None), CDDA_FREEDB_ID) self.assertEqual(toc.freedbID(sessions), CDDA_FREEDB_ID)
def test_serialization(self): # Test both deserialization and serialization (since, unlike # in the C code, the Python library does not support directly # specifying the mock TOC. toc = cueify.TOC() self.assertTrue( toc.deserialize( struct.pack("B" * len(serialized_mock_toc), *serialized_mock_toc))) s = toc.serialize() self.assertEqual(toc.errorCode, cueify.OK) self.assertEqual(len(s), len(serialized_mock_toc)) self.assertEqual( s, struct.pack("B" * len(serialized_mock_toc), *serialized_mock_toc))
def test_getters(self): toc = cueify.TOC() self.assertTrue( toc.deserialize( struct.pack("B" * len(serialized_mock_toc), *serialized_mock_toc))) self.assertEqual(toc.firstTrack, 1) self.assertEqual(toc.lastTrack, 13) self.assertEqual(len(toc.tracks), 13) self.assertEqual(toc.tracks[12].controlFlags, cueify.TOC_TRACK_IS_DATA) self.assertEqual(toc.leadoutTrack.controlFlags, 0) self.assertEqual(toc.tracks[12].subQChannelFormat, cueify.SUB_Q_POSITION) self.assertEqual(toc.leadoutTrack.subQChannelFormat, cueify.SUB_Q_NOTHING) self.assertEqual(toc.tracks[12].address, 244076) self.assertEqual(toc.leadoutTrack.address, 258988) self.assertEqual(toc.discLength, 258988) self.assertEqual(toc.tracks[12].length, 258988 - 244076)