Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_write_popm_long_counter(self):
from mutagen.id3 import POPM
f = ID3(self.newfilename)
f.add(POPM(email="foo@example.com", rating=125, count=2**32+1))
f.save()
f = ID3(self.newfilename)
self.failUnless("POPM:foo@example.com" in f)
self.failUnless("POPM:Windows Media Player 9 Series" in f)
popm = f["POPM:foo@example.com"]
self.assertEquals(popm.rating, 125)
self.assertEquals(popm.count, 2**32+1)
def _test_text_frame(self, short, longer, frame):
new_value = "TEST"
for arg in [short, longer]:
orig = ID3(self.filename)
frame_class = mutagen.id3.Frames[frame]
orig[frame] = frame_class(text=[u"BLAH"], encoding=3)
orig.save()
res, out = self.call(arg, new_value, self.filename)
self.failUnlessEqual(res, 0)
self.failIf(out)
self.failUnlessEqual(ID3(self.filename)[frame].text, [new_value])
def test_header_2_4_extended_unsynch_size(self):
id3 = ID3()
id3._fileobj = cBytesIO(
b'ID3\x04\x00\x40\x00\x00\x00\x00\x00\x00\x00\xFF\x5a')
self.assertRaises(ValueError, id3._load_header)
def test_header_2_4_allow_footer(self):
id3 = ID3()
id3._fileobj = cBytesIO(b'ID3\x04\x00\x10\x00\x00\x00\x00')
id3._load_header()
def _test_text_frame(self, short, longer, frame):
new_value = fsn(u"TEST")
for arg in [short, longer]:
orig = ID3(self.filename)
frame_class = mutagen.id3.Frames[frame]
orig[frame] = frame_class(text=[u"BLAH"], encoding=3)
orig.save()
res, out = self.call(arg, new_value, self.filename)
self.failUnlessEqual(res, 0)
self.failIf(out)
self.failUnlessEqual(ID3(self.filename)[frame].text, [new_value])
def test_write_popm_long_counter(self):
from mutagen.id3 import POPM
f = ID3(self.newfilename)
f.add(POPM(email="foo@example.com", rating=125, count=2**32+1))
f.save()
f = ID3(self.newfilename)
self.failUnless("POPM:foo@example.com" in f)
self.failUnless("POPM:Windows Media Player 9 Series" in f)
popm = f["POPM:foo@example.com"]
self.assertEquals(popm.rating, 125)
self.assertEquals(popm.count, 2**32+1)
def test_header_2_4_invalid_flags(self):
id3 = ID3()
id3._fileobj = cBytesIO(b'ID3\x04\x00\x1f\x00\x00\x00\x00')
self.assertRaises(ValueError, id3._load_header)
def setUp(self):
from tempfile import mkstemp
fd, self.filename = mkstemp(suffix='.mp3')
os.close(fd)
shutil.copy(self.SILENCE, self.filename)
self.audio = ID3(self.filename)
def _test_text_frame(self, short, longer, frame):
new_value = "TEST"
for arg in [short, longer]:
orig = ID3(self.filename)
frame_class = mutagen.id3.Frames[frame]
orig[frame] = frame_class(text=[u"BLAH"], encoding=3)
orig.save()
res, out = self.call(arg, new_value, self.filename)
self.failUnlessEqual(res, 0)
self.failIf(out)
self.failUnlessEqual(ID3(self.filename)[frame].text, [new_value])
def test_add_tags_already_there(self):
mp3 = MP3(os.path.join(DATA_DIR, "silence-44-s.mp3"))
self.failUnless(mp3.tags)
self.failUnlessRaises(Exception, mp3.add_tags)