# 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
        # Everything should be encoded as utf-8.
        for val in mp3.values():
            self.assertEqual(3, val.encoding)
        # All tags should have the expected values.
        self.assertEqual([tpe1], mp3["TPE1"].text)
        self.assertEqual([tit2], mp3["TIT2"].text)
        self.assertEqual([talb], mp3["TALB"].text)

    size_test_cases = (("\x00\x00\x00\x00", 0),
                       ("\x00\x00\x00\x01", 1),
                       ("\x00\x00\x01\x00", 1<<7),
                       ("\x00\x01\x00\x00", 1<<14),
                       ("\x01\x00\x00\x00", 1<<21),
                       )

    def test_test_header(self):
        for raw_size, cooked_size in self.size_test_cases:
            self.assertEqual(self.prefix + raw_size,
                             id3_header.create_test_header(cooked_size))

    def test_parse(self):
        self.assertEqual(None, id3_header.parse_size(""))
        self.assertEqual(None, id3_header.parse_size("short"))
        self.assertEqual(None, id3_header.parse_size("1234567890"))

        # 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):

# 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

        # Everything should be encoded as utf-8.
        for val in mp3.values():
            self.assertEqual(3, val.encoding)
        # All tags should have the expected values.
        self.assertEqual([tpe1], mp3["TPE1"].text)
        self.assertEqual([tit2], mp3["TIT2"].text)
        self.assertEqual([talb], mp3["TALB"].text)

    size_test_cases = (("\x00\x00\x00\x00", 0),
                       ("\x00\x00\x00\x01", 1),
                       ("\x00\x00\x01\x00", 1<<7),
                       ("\x00\x01\x00\x00", 1<<14),
                       ("\x01\x00\x00\x00", 1<<21),
                       )

    def test_test_header(self):
        for raw_size, cooked_size in self.size_test_cases:
            self.assertEqual(self.prefix + raw_size,
                             id3_header.create_test_header(cooked_size))

    def test_parse(self):
        self.assertEqual(None, id3_header.parse_size(""))
        self.assertEqual(None, id3_header.parse_size("short"))
        self.assertEqual(None, id3_header.parse_size("1234567890"))

        # 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)