class TFLACFile(TVCFile, TVCFileMixin): def setUp(self): TVCFile.setUp(self) h, self.filename = mkstemp(".flac") os.close(h) shutil.copy(os.path.join(DATA_DIR, 'empty.flac'), self.filename) self.song = FLACFile(self.filename) def test_mime(self): self.failUnless(self.song.mimes) def test_save_empty(self): self.song.write() flac = FLAC(self.filename) self.failIf(flac.tags) self.failIf(flac.tags is None) def test_strip_id3(self): self.song["title"] = "Test" self.song.write() id3 = ID3() id3.add(TIT2(encoding=2, text=u"Test but differently")) id3.save(filename=self.filename) song2 = formats.MusicFile(self.filename) self.failUnlessEqual(type(self.song), type(song2)) self.failUnlessEqual(self.song["title"], song2["title"]) song2.write() self.assertRaises(ID3NoHeaderError, ID3, self.filename) def tearDown(self): os.unlink(self.filename) config.quit()
class TFLACFile(TVCFile): def setUp(self): TVCFile.setUp(self) self.filename = tempfile.mkstemp(".flac")[1] shutil.copy(os.path.join('tests', 'data', 'empty.flac'), self.filename) self.song = FLACFile(self.filename) def test_mime(self): self.failUnless(self.song.mimes) def test_save_empty(self): self.song.write() flac = FLAC(self.filename) self.failIf(flac.tags) self.failIf(flac.tags is None) def test_strip_id3(self): self.song["title"] = "Test" self.song.write() id3 = ID3() id3.add(TIT2(encoding=2, text=u"Test but differently")) id3.save(filename=self.filename) song2 = formats.MusicFile(self.filename) self.failUnlessEqual(type(self.song), type(song2)) self.failUnlessEqual(self.song["title"], song2["title"]) song2.write() self.assertRaises(ID3NoHeaderError, ID3, self.filename) def tearDown(self): os.unlink(self.filename) config.quit()
def test_get_images(self): pic = Picture() pic.data = _get_jpeg() pic.type = APICType.COVER_FRONT b64pic_cover = base64.b64encode(pic.write()).decode("ascii") # metadata_block_picture song = FLAC(self.filename) song["metadata_block_picture"] = [b64pic_cover] song.save() song = FLACFile(self.filename) self.assertEqual(len(song.get_images()), 1) self.assertEqual(song.get_images()[0].type, APICType.COVER_FRONT) # flac Picture song = FLAC(self.filename) pic = Picture() pic.data = _get_jpeg() pic.type = APICType.COVER_BACK song.add_picture(pic) song.save() song = FLACFile(self.filename) self.assertEqual(len(song.get_images()), 2) self.assertEqual(song.get_images()[-1].type, APICType.COVER_BACK)
def test_set_image(self): fileobj = StringIO.StringIO("foo") image = EmbeddedImage(fileobj, "image/jpeg", 10, 10, 8) song = FLACFile(self.filename) self.assertFalse(song.get_primary_image()) song.set_image(image) self.assertEqual(song.get_primary_image().width, 10)
def test_clear_images(self): data = b"abc" song = FLAC(self.filename) pic = Picture() pic.data = data song.add_picture(pic) song.save() song = FLACFile(self.filename) self.assertTrue(song.get_primary_image()) song.clear_images() song.clear_images() song = FLACFile(self.filename) self.assertFalse(song.get_primary_image())
class TFLACFile(TVCFile, TVCFileMixin): def setUp(self): TVCFile.setUp(self) self.filename = get_temp_copy(get_data_path('empty.flac')) self.song = FLACFile(self.filename) def test_format_codec(self): self.assertEqual(self.song("~format"), "FLAC") self.assertEqual(self.song("~codec"), "FLAC") self.assertEqual(self.song("~encoding"), "") def test_audio_props(self): assert self.song("~#channels") == 2 assert self.song("~#samplerate") == 44100 assert self.song("~#bitdepth") == 16 def test_mime(self): self.failUnless(self.song.mimes) def test_save_empty(self): self.song.write() flac = FLAC(self.filename) self.failIf(flac.tags) self.failIf(flac.tags is None) def test_strip_id3(self): self.song["title"] = "Test" self.song.write() id3 = ID3() id3.add(TIT2(encoding=2, text=u"Test but differently")) id3.save(filename=self.filename) song2 = formats.MusicFile(self.filename) self.failUnlessEqual(type(self.song), type(song2)) self.failUnlessEqual(self.song["title"], song2["title"]) song2.write() self.assertRaises(ID3NoHeaderError, ID3, self.filename) def tearDown(self): os.unlink(self.filename) config.quit()
def test_get_image(self): data = b"abc" song = FLAC(self.filename) pic = Picture() pic.data = data song.add_picture(pic) song.save() song = FLACFile(self.filename) self.failUnless(song("~picture")) fn = song.get_primary_image().file self.failUnlessEqual(fn.read(), pic.data)
def test_set_image(self): fileobj = cBytesIO(b"foo") image = EmbeddedImage(fileobj, "image/jpeg", 10, 10, 8) song = FLACFile(self.filename) self.assertFalse(song.get_primary_image()) song.set_image(image) self.assertEqual(song.get_primary_image().width, 10)
class TFLACFile(TVCFile, TVCFileMixin): def setUp(self): TVCFile.setUp(self) h, self.filename = mkstemp(".flac") os.close(h) shutil.copy(os.path.join(DATA_DIR, 'empty.flac'), self.filename) self.song = FLACFile(self.filename) def test_format_codec(self): self.assertEqual(self.song("~format"), "FLAC") self.assertEqual(self.song("~codec"), "FLAC") self.assertEqual(self.song("~encoding"), "") def test_mime(self): self.failUnless(self.song.mimes) def test_save_empty(self): self.song.write() flac = FLAC(self.filename) self.failIf(flac.tags) self.failIf(flac.tags is None) def test_strip_id3(self): self.song["title"] = "Test" self.song.write() id3 = ID3() id3.add(TIT2(encoding=2, text=u"Test but differently")) id3.save(filename=self.filename) song2 = formats.MusicFile(self.filename) self.failUnlessEqual(type(self.song), type(song2)) self.failUnlessEqual(self.song["title"], song2["title"]) song2.write() self.assertRaises(ID3NoHeaderError, ID3, self.filename) def tearDown(self): os.unlink(self.filename) config.quit()
def setUp(self): TVCFile.setUp(self) self.filename = tempfile.mkstemp(".flac")[1] shutil.copy(os.path.join('tests', 'data', 'empty.flac'), self.filename) self.song = FLACFile(self.filename)
def setUp(self): TVCFile.setUp(self) self.filename = get_temp_copy(os.path.join(DATA_DIR, 'empty.flac')) self.song = FLACFile(self.filename)
def setUp(self): TVCFile.setUp(self) h, self.filename = mkstemp(".flac") os.close(h) shutil.copy(os.path.join(DATA_DIR, 'empty.flac'), self.filename) self.song = FLACFile(self.filename)
def setUp(self): TVCFile.setUp(self) self.filename = get_temp_copy(get_data_path('empty.flac')) self.song = FLACFile(self.filename)
def setUp(self): TVCFile.setUp(self) self.filename = get_temp_copy(get_data_path("empty.flac")) self.song = FLACFile(self.filename)