# 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
        # An ID3 header that claims to have size 0 is considered invalid.
        zero_hdr = id3_header.create_test_header(0)
        self.assertEqual(None, id3_header.parse_size(zero_hdr))

        for test_size in (1, 1<<7, 1<<14, 1<<21):
            test_hdr = id3_header.create_test_header(test_size)
            for offset in (0, 5):
                data = "x" * offset + test_hdr
                self.assertEqual(test_size,
                                 id3_header.parse_size(data, offset=offset))

    def test_find(self):
        test_raw_size, test_cooked_size = self.size_test_cases[-1]
        header = self.prefix + test_raw_size
        padding = "x" * 10

        self.assertEqual((None, 0), id3_header.find_size(""))
        self.assertEqual((None, 1), id3_header.find_size("x"))
        self.assertEqual((None, 1), id3_header.find_size("xI"))
        self.assertEqual((None, 12), id3_header.find_size("xI" + padding))
        self.assertEqual((test_cooked_size, 0),
                         id3_header.find_size(header))
        self.assertEqual((test_cooked_size, 0),
                         id3_header.find_size(header + padding))
        self.assertEqual((test_cooked_size, 3),
                         id3_header.find_size("xIx" + header))
        self.assertEqual((test_cooked_size, 3),
                         id3_header.find_size("xIx" + header + padding))



# 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

        # An ID3 header that claims to have size 0 is considered invalid.
        zero_hdr = id3_header.create_test_header(0)
        self.assertEqual(None, id3_header.parse_size(zero_hdr))

        for test_size in (1, 1<<7, 1<<14, 1<<21):
            test_hdr = id3_header.create_test_header(test_size)
            for offset in (0, 5):
                data = "x" * offset + test_hdr
                self.assertEqual(test_size,
                                 id3_header.parse_size(data, offset=offset))

    def test_find(self):
        test_raw_size, test_cooked_size = self.size_test_cases[-1]
        header = self.prefix + test_raw_size
        padding = "x" * 10

        self.assertEqual((None, 0), id3_header.find_size(""))
        self.assertEqual((None, 1), id3_header.find_size("x"))
        self.assertEqual((None, 1), id3_header.find_size("xI"))
        self.assertEqual((None, 12), id3_header.find_size("xI" + padding))
        self.assertEqual((test_cooked_size, 0),
                         id3_header.find_size(header))
        self.assertEqual((test_cooked_size, 0),
                         id3_header.find_size(header + padding))
        self.assertEqual((test_cooked_size, 3),
                         id3_header.find_size("xIx" + header))
        self.assertEqual((test_cooked_size, 3),
                         id3_header.find_size("xIx" + header + padding))



if __name__ == "__main__":