示例#1
0
    def test_update_v22_add(self):
        id3 = ID3Tags()
        tt1 = TT1(encoding=0, text=u'whatcha staring at?')
        id3.loaded_frame(tt1)
        tit1 = id3['TIT1']

        self.assertEquals(tt1.encoding, tit1.encoding)
        self.assertEquals(tt1.text, tit1.text)
        self.assert_('TT1' not in id3)
示例#2
0
    def test_read__ignore_CRM(self):
        tags = ID3Tags()
        header = ID3Header()
        header.version = ID3Header._V22

        framedata = CRM(owner="foo", desc="bar", data=b"bla")._writeData()
        datasize = BitPaddedInt.to_str(len(framedata), width=3, bits=8)
        tags._read(header, b"CRM" + datasize + framedata)
        self.assertEqual(len(tags), 0)
示例#3
0
    def test_apic_duplicate_hash(self):
        id3 = ID3Tags()
        for i in xrange(10):
            apic = APIC(encoding=0, mime=u"b", type=3, desc=u"", data=b"a")
            id3._add(apic, False)

        self.assertEqual(len(id3), 10)
        for key, value in id3.items():
            self.assertEqual(key, value.HashKey)
示例#4
0
 def setUp(self):
     self.frames = [
         TIT2(text=["1"]), TIT2(text=["2"]),
         TIT2(text=["3"]), TIT2(text=["4"])]
     self.i = ID3Tags()
     self.i["BLAH"] = self.frames[0]
     self.i["QUUX"] = self.frames[1]
     self.i["FOOB:ar"] = self.frames[2]
     self.i["FOOB:az"] = self.frames[3]
示例#5
0
    def test_text_duplicate_frame_different_encoding(self):
        id3 = ID3Tags()
        frame = TPE2(encoding=Encoding.LATIN1, text=[u"foo"])
        id3._add(frame, False)
        assert id3.getall("TPE2")[0].encoding == Encoding.LATIN1
        frame = TPE2(encoding=Encoding.LATIN1, text=[u"bar"])
        id3._add(frame, False)
        assert id3.getall("TPE2")[0].encoding == Encoding.LATIN1
        frame = TPE2(encoding=Encoding.UTF8, text=[u"baz\u0400"])
        id3._add(frame, False)
        assert id3.getall("TPE2")[0].encoding == Encoding.UTF8

        frames = id3.getall("TPE2")
        assert len(frames) == 1
        assert len(frames[0].text) == 3
示例#6
0
 def test_set_wrong_type(self):
     id3 = ID3Tags()
     self.assertRaises(TypeError, id3.__setitem__, "FOO", object())
示例#7
0
 def test_add_CRM(self):
     id3 = ID3Tags()
     self.assertRaises(TypeError, id3.add, CRM())