# Path: chirp/common/id3_header.py
# def _create_text_frame(frame_tag, value):
# def create(tag_list):
# def parse_size(data, offset=0):
# def find_size(data):
# def create_test_header(size):
# 
# Path: chirp/common/mp3_header_test.py
# VALID_MP3_HEADERS = {
#     '\xff\xfb\x90\x64':
#         mp3_header.MP3Header(bit_rate_kbps=128, sampling_rate_hz=44100,
#                              channels=mp3_header.JOINT_STEREO,
#                              padding=False, protected=False),
#     '\xff\xfb\xb0\x00': 
#         mp3_header.MP3Header(bit_rate_kbps=192, sampling_rate_hz=44100,
#                              channels=mp3_header.STEREO,
#                              padding=False, protected=False),
#     '\xff\xfb\xb2\x00': 
#         mp3_header.MP3Header(bit_rate_kbps=192, sampling_rate_hz=44100,
#                              channels=mp3_header.STEREO,
#                              padding=True, protected=False),
#     }
# INVALID_MP3_HEADERS = (
#     '',
#     'GARBAGE',
#     '\xff\xf0\0\0',
#     '\xff', '\xff' * 2, '\xff' * 3, '\xff' * 4,
#     )
# class ParseHeaderTest(unittest.TestCase):
#         class MockInfo(mutagen.mp3.MPEGInfo):
#     def test_is_complete(self):
#     def test_parse(self):
#     def test_match(self):
#     def test_find(self):
#     def test_from_mutagen(self):
#             def __init__(self):


import unittest
import mutagen.mp3
from chirp.common import id3_header
from chirp.common import mp3_header_test
#!/usr/bin/env python



class ID3HeaderTest(unittest.TestCase):

    # vmaj = 4, vrev = 0, flags = 0
    prefix = "ID3\x04\x00\x00"

    def test_create(self):
        # Construct a test ID3 header with a few text tags.
        tpe1_utf8 = "Von S\xc3\xbcdenfed"
        tpe1 = tpe1_utf8.decode("utf-8")
        tit2 = "Very Long String" * 100
        talb = "Bar"
        data = id3_header.create((("TPE1", tpe1),
                                  ("TIT2", tit2),
                                  ("TALB", talb)))
        # Make sure that it starts with the expected prefix.
        self.assertTrue(data.startswith(self.prefix))
        # Ensure that utf-8 encoding is used inside of our tag.
        self.assertTrue(tpe1_utf8 in data)

        # Write our header out to disk, along with some dummy MP3 frames.
        # (We need the extra frames because mutagen refuses to read an empty
        # MP3 file.)
        test_file = "/tmp/id3_header_test.data"
        fh = open(test_file, "w")
        fh.write(data)

# Path: chirp/common/id3_header.py
# def _create_text_frame(frame_tag, value):
# def create(tag_list):
# def parse_size(data, offset=0):
# def find_size(data):
# def create_test_header(size):
# 
# Path: chirp/common/mp3_header_test.py
# VALID_MP3_HEADERS = {
#     '\xff\xfb\x90\x64':
#         mp3_header.MP3Header(bit_rate_kbps=128, sampling_rate_hz=44100,
#                              channels=mp3_header.JOINT_STEREO,
#                              padding=False, protected=False),
#     '\xff\xfb\xb0\x00': 
#         mp3_header.MP3Header(bit_rate_kbps=192, sampling_rate_hz=44100,
#                              channels=mp3_header.STEREO,
#                              padding=False, protected=False),
#     '\xff\xfb\xb2\x00': 
#         mp3_header.MP3Header(bit_rate_kbps=192, sampling_rate_hz=44100,
#                              channels=mp3_header.STEREO,
#                              padding=True, protected=False),
#     }
# INVALID_MP3_HEADERS = (
#     '',
#     'GARBAGE',
#     '\xff\xf0\0\0',
#     '\xff', '\xff' * 2, '\xff' * 3, '\xff' * 4,
#     )
# class ParseHeaderTest(unittest.TestCase):
#         class MockInfo(mutagen.mp3.MPEGInfo):
#     def test_is_complete(self):
#     def test_parse(self):
#     def test_match(self):
#     def test_find(self):
#     def test_from_mutagen(self):
#             def __init__(self):


# Path: chirp/common/id3_header_test.py
import unittest
import mutagen.mp3
from chirp.common import id3_header
from chirp.common import mp3_header_test

#!/usr/bin/env python



class ID3HeaderTest(unittest.TestCase):

    # vmaj = 4, vrev = 0, flags = 0
    prefix = "ID3\x04\x00\x00"

    def test_create(self):
        # Construct a test ID3 header with a few text tags.
        tpe1_utf8 = "Von S\xc3\xbcdenfed"
        tpe1 = tpe1_utf8.decode("utf-8")
        tit2 = "Very Long String" * 100
        talb = "Bar"
        data = id3_header.create((("TPE1", tpe1),
                                  ("TIT2", tit2),
                                  ("TALB", talb)))
        # Make sure that it starts with the expected prefix.
        self.assertTrue(data.startswith(self.prefix))
        # Ensure that utf-8 encoding is used inside of our tag.
        self.assertTrue(tpe1_utf8 in data)

        # Write our header out to disk, along with some dummy MP3 frames.
        # (We need the extra frames because mutagen refuses to read an empty
        # MP3 file.)
        test_file = "/tmp/id3_header_test.data"
        fh = open(test_file, "w")
        fh.write(data)

        raw_hdr, hdr = mp3_header_test.VALID_MP3_HEADERS.items()[0]