예제 #1
0
파일: test_frames.py 프로젝트: haojp/eyeD3
def test_compression():
    f = open(__file__, "rb")
    try:
        data = f.read()
        compressed = Frame.compress(data)
        assert data == Frame.decompress(compressed)
    finally:
        f.close()
예제 #2
0
파일: test_frames.py 프로젝트: nicfit/eyed3
def test_compression():
    f = open(__file__, "rb")
    try:
        data = f.read()
        compressed = Frame.compress(data)
        assert data == Frame.decompress(compressed)
    finally:
        f.close()
예제 #3
0
파일: test_frames.py 프로젝트: nicfit/eyed3
 def testTextDelim(self):
     for enc in [LATIN1_ENCODING, UTF_16BE_ENCODING, UTF_16_ENCODING,
                 UTF_8_ENCODING]:
         f = Frame(b"XXXX")
         f.encoding = enc
         if enc in [LATIN1_ENCODING, UTF_8_ENCODING]:
             assert (f.text_delim == b"\x00")
         else:
             assert (f.text_delim == b"\x00\x00")
예제 #4
0
파일: test_frames.py 프로젝트: haojp/eyeD3
 def testTextDelim(self):
     for enc in [
             LATIN1_ENCODING, UTF_16BE_ENCODING, UTF_16_ENCODING,
             UTF_8_ENCODING
     ]:
         f = Frame(b"XXXX")
         f.encoding = enc
         if enc in [LATIN1_ENCODING, UTF_8_ENCODING]:
             assert (f.text_delim == b"\x00")
         else:
             assert (f.text_delim == b"\x00\x00")
예제 #5
0
파일: test_frames.py 프로젝트: haojp/eyeD3
    def testCtor(self):
        f = Frame(b"ABCD")
        assert f.id == b"ABCD"
        assert f.header is None
        assert f.decompressed_size == 0
        assert f.group_id is None
        assert f.encrypt_method is None
        assert f.data is None
        assert f.data_len == 0
        assert f.encoding is None

        f = Frame(b"EFGH")
        assert f.id == b"EFGH"
        assert f.header is None
        assert f.decompressed_size == 0
        assert f.group_id is None
        assert f.encrypt_method is None
        assert f.data is None
        assert f.data_len == 0
        assert f.encoding is None
예제 #6
0
파일: test_frames.py 프로젝트: nicfit/eyed3
    def testInitEncoding(self):
        # Default encodings per version
        for ver in [ID3_V1_0, ID3_V1_1, ID3_V2_3, ID3_V2_4]:
            f = Frame(b"XXXX")
            f.header = FrameHeader(f.id, ver)
            f._initEncoding()
            if ver[0] == 1:
                assert (f.encoding == LATIN1_ENCODING)
            elif ver[:2] == (2, 3):
                assert (f.encoding == UTF_16_ENCODING)
            else:
                assert (f.encoding == UTF_8_ENCODING)

        # Invalid encoding for a version is coerced
        for ver in [ID3_V1_0, ID3_V1_1]:
            for enc in [UTF_8_ENCODING, UTF_16_ENCODING, UTF_16BE_ENCODING]:
                f = Frame(b"XXXX")
                f.header = FrameHeader(f.id, ver)
                f.encoding = enc
                f._initEncoding()
                assert (f.encoding == LATIN1_ENCODING)

        for ver in [ID3_V2_3]:
            for enc in [UTF_8_ENCODING, UTF_16BE_ENCODING]:
                f = Frame(b"XXXX")
                f.header = FrameHeader(f.id, ver)
                f.encoding = enc
                f._initEncoding()
                assert (f.encoding == UTF_16_ENCODING)

        # No coersion for v2.4
        for ver in [ID3_V2_4]:
            for enc in [LATIN1_ENCODING, UTF_8_ENCODING, UTF_16BE_ENCODING,
                        UTF_16_ENCODING]:
                f = Frame(b"XXXX")
                f.header = FrameHeader(f.id, ver)
                f.encoding = enc
                f._initEncoding()
                assert (f.encoding == enc)
예제 #7
0
파일: test_frames.py 프로젝트: nicfit/eyed3
def test_encryption():
    with pytest.raises(NotImplementedError):
        Frame.encrypt("Iceburn")
    with pytest.raises(NotImplementedError):
        Frame.decrypt("Iceburn")
예제 #8
0
파일: test_frames.py 프로젝트: haojp/eyeD3
    def testInitEncoding(self):
        # Default encodings per version
        for ver in [ID3_V1_0, ID3_V1_1, ID3_V2_3, ID3_V2_4]:
            f = Frame(b"XXXX")
            f.header = FrameHeader(f.id, ver)
            f._initEncoding()
            if ver[0] == 1:
                assert (f.encoding == LATIN1_ENCODING)
            elif ver[:2] == (2, 3):
                assert (f.encoding == UTF_16_ENCODING)
            else:
                assert (f.encoding == UTF_8_ENCODING)

        # Invalid encoding for a version is coerced
        for ver in [ID3_V1_0, ID3_V1_1]:
            for enc in [UTF_8_ENCODING, UTF_16_ENCODING, UTF_16BE_ENCODING]:
                f = Frame(b"XXXX")
                f.header = FrameHeader(f.id, ver)
                f.encoding = enc
                f._initEncoding()
                assert (f.encoding == LATIN1_ENCODING)

        for ver in [ID3_V2_3]:
            for enc in [UTF_8_ENCODING, UTF_16BE_ENCODING]:
                f = Frame(b"XXXX")
                f.header = FrameHeader(f.id, ver)
                f.encoding = enc
                f._initEncoding()
                assert (f.encoding == UTF_16_ENCODING)

        # No coersion for v2.4
        for ver in [ID3_V2_4]:
            for enc in [
                    LATIN1_ENCODING, UTF_8_ENCODING, UTF_16BE_ENCODING,
                    UTF_16_ENCODING
            ]:
                f = Frame(b"XXXX")
                f.header = FrameHeader(f.id, ver)
                f.encoding = enc
                f._initEncoding()
                assert (f.encoding == enc)
예제 #9
0
파일: test_frames.py 프로젝트: haojp/eyeD3
def test_encryption():
    assert "Iceburn" == Frame.encrypt("Iceburn")
    assert "Iceburn" == Frame.decrypt("Iceburn")
예제 #10
0
def test_encryption():
    with pytest.raises(NotImplementedError):
        Frame.encrypt("Iceburn")
    with pytest.raises(NotImplementedError):
        Frame.decrypt("Iceburn")