def test_getters(self): sessions = cueify.Sessions() self.assertTrue( sessions.deserialize( struct.pack("B" * len(serialized_mock_sessions), *serialized_mock_sessions))) self.assertEqual(sessions.firstSession, 1) self.assertEqual(sessions.lastSession, 2) self.assertEqual(sessions.lastSessionControlFlags, cueify.TOC_TRACK_IS_DATA) self.assertEqual(sessions.lastSessionSubQChannelFormat, cueify.SUB_Q_POSITION) self.assertEqual(sessions.lastSessionTrackNumber, 13) self.assertEqual(sessions.lastSessionAddress, 244076)
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. sessions = cueify.Sessions() self.assertTrue( sessions.deserialize( struct.pack("B" * len(serialized_mock_sessions), *serialized_mock_sessions))) s = sessions.serialize() self.assertEqual(sessions.errorCode, cueify.OK) self.assertEqual(len(s), len(serialized_mock_sessions)) self.assertEqual( s, struct.pack("B" * len(serialized_mock_sessions), *serialized_mock_sessions))