Exemplo n.º 1
0
 def test_mdhd_version_1(self, soun="soun"):
     mdhd = Atom.render("mdhd", ("\x01\x00\x00\x00" + "\x00" * 16 +
                                 "\x00\x00\x00\x02" + # 2 Hz
                                 "\x00\x00\x00\x00\x00\x00\x00\x10"))
     hdlr = Atom.render("hdlr", soun)
     mdia = Atom.render("mdia", mdhd + hdlr)
     trak = Atom.render("trak", mdia)
     moov = Atom.render("moov", trak)
     fileobj = StringIO(moov)
     atoms = Atoms(fileobj)
     info = M4AInfo(atoms, fileobj)
     self.failUnlessEqual(info.length, 8)
Exemplo n.º 2
0
 def test_render_too_big(self):
     class TooBig(str):
         def __len__(self):
             return 1L << 32
     data = TooBig("test")
     try: len(data)
     except OverflowError:
         # Py_ssize_t is still only 32 bits on this system.
         self.failUnlessRaises(OverflowError, Atom.render, "data", data)
     else:
         data = Atom.render("data", data)
         self.failUnlessEqual(len(data), 4 + 4 + 8 + 4)
Exemplo n.º 3
0
 def wrap_ilst(self, data):
     ilst = Atom.render("ilst", data)
     meta = Atom.render("meta", "\x00" * 4 + ilst)
     data = Atom.render("moov", Atom.render("udta", meta))
     fileobj = StringIO(data)
     return M4ATags(Atoms(fileobj), fileobj)
Exemplo n.º 4
0
 def test_length_0(self):
     fileobj = StringIO("\x00\x00\x00\x00atom")
     Atom(fileobj)
     self.failUnlessEqual(fileobj.tell(), 8)
Exemplo n.º 5
0
 def test_bad_covr(self):
     data = Atom.render("foob", "\x00\x00\x00\x0E" + "\x00" * 4 + "whee")
     covr = Atom.render("covr", data)
     self.failUnlessRaises(M4AMetadataError, self.wrap_ilst, covr)
Exemplo n.º 6
0
 def test_no_children(self):
     fileobj = StringIO("\x00\x00\x00\x08atom")
     atom = Atom(fileobj)
     self.failUnlessRaises(KeyError, atom.__getitem__, "test")
Exemplo n.º 7
0
 def test_strips_unknown_types(self):
     data = Atom.render("data", "\x00" * 8 + "whee")
     foob = Atom.render("foob", data)
     tags = self.wrap_ilst(foob)
     self.failIf(tags)
Exemplo n.º 8
0
 def test_genre_too_big(self):
     data = Atom.render("data", "\x00" * 8 + "\x01\x00")
     genre = Atom.render("gnre", data)
     tags = self.wrap_ilst(genre)
     self.failIf("gnre" in tags)
     self.failIf("\xa9gen" in tags)
Exemplo n.º 9
0
 def test_empty_cpil(self):
     cpil = Atom.render("cpil", Atom.render("data", "\x00" * 8))
     tags = self.wrap_ilst(cpil)
     self.failUnless("cpil" in tags)
     self.failIf(tags["cpil"])
Exemplo n.º 10
0
 def test_genre(self):
     data = Atom.render("data", "\x00" * 8 + "\x00\x01")
     genre = Atom.render("gnre", data)
     tags = self.wrap_ilst(genre)
     self.failIf("gnre" in tags)
     self.failUnlessEqual(tags.get("\xa9gen"), "Blues")
Exemplo n.º 11
0
 def test_bad_freeform(self):
     mean = Atom.render("mean", "net.sacredchao.Mutagen")
     name = Atom.render("name", "empty test key")
     bad_freeform = Atom.render("----", "\x00" * 4 + mean + name)
     self.failIf(self.wrap_ilst(bad_freeform))