# Path: chirp/stream/message.py
# CONNECTED = "Connected"        # New connection initiated.
# RESPONSE = "Response"          # HTTP response received.
# BLOCK = "Block"                # A chunk of raw data.
# FRAME = "Frame"                # An MP3 frame.
# ERROR = "Error"                # An error.
# CONNECT_TIMEOUT_ERROR = "Connect Timeout Error"
# CONNECT_ERROR = "Connect Error"
# REQUEST_ERROR = "Request Error"
# READ_TIMEOUT_ERROR = "Read Timeout Error"
# READ_ERROR = "Read Error"
# MISSING_HEADERS_ERROR = "Missing HTTP Headers Error"
# MALFORMED_HEADERS_ERROR = "Malformed HTTP Headers Error"
# BAD_REDIRECT_ERROR = "Bad Redirect Error"
# END_OF_STREAM_ERROR = "End of Stream Error"
# class Message(object):
# class MessageSource(object):
# class MessageConsumer(looper.Looper):
# class MessageTee(MessageConsumer):
#     def payload_sha1(self):
#     def payload_hex_sha1(self):
#     def __str__(self):
#     def set_error(self, error_type, err):
#     def is_error(self):
#     def is_end_of_stream(self):
#     def __init__(self):
#     def _add_message(self, msg):
#     def _add_stop_message(self):
#     def get_next_message(self, timeout=None):
#     def get_all_messages(self):
#     def wait_until_empty(self):
#     def __init__(self, src):
#     def _process_message(self, msg):
#     def _loop_once(self):
#     def __init__(self, input_src, num_outputs):
#     def _process_message(self, msg):


import unittest
from chirp.stream import message
        self.assertTrue(src.get_next_message(timeout=0.01) is None)

        # Check that we can add a stop message, then get it back out.
        src._add_stop_message()
        msg = src.get_next_message()
        self.assertTrue(msg.is_end_of_stream())
        # The queue should now be empty.
        self.assertTrue(src.get_next_message(timeout=0.01) is None)


class TestMessageConsumer(message.MessageConsumer):
    """A test message consumer that simply appends all consumed messages
    to a list."""

    all_messages = []

    def _process_message(self, msg):
        self.all_messages.append(msg)


class MessageConsumerTestCase(unittest.TestCase):

    def test_basics(self):
        # Construct a source and connect it to our test consumer.
        src = message.MessageSource()
        con = TestMessageConsumer(src)
        # Run the consumer in a separate thread.
        con.loop_in_thread()

        # Add a test message and a stop message to our source.

# Path: chirp/stream/message.py
# CONNECTED = "Connected"        # New connection initiated.
# RESPONSE = "Response"          # HTTP response received.
# BLOCK = "Block"                # A chunk of raw data.
# FRAME = "Frame"                # An MP3 frame.
# ERROR = "Error"                # An error.
# CONNECT_TIMEOUT_ERROR = "Connect Timeout Error"
# CONNECT_ERROR = "Connect Error"
# REQUEST_ERROR = "Request Error"
# READ_TIMEOUT_ERROR = "Read Timeout Error"
# READ_ERROR = "Read Error"
# MISSING_HEADERS_ERROR = "Missing HTTP Headers Error"
# MALFORMED_HEADERS_ERROR = "Malformed HTTP Headers Error"
# BAD_REDIRECT_ERROR = "Bad Redirect Error"
# END_OF_STREAM_ERROR = "End of Stream Error"
# class Message(object):
# class MessageSource(object):
# class MessageConsumer(looper.Looper):
# class MessageTee(MessageConsumer):
#     def payload_sha1(self):
#     def payload_hex_sha1(self):
#     def __str__(self):
#     def set_error(self, error_type, err):
#     def is_error(self):
#     def is_end_of_stream(self):
#     def __init__(self):
#     def _add_message(self, msg):
#     def _add_stop_message(self):
#     def get_next_message(self, timeout=None):
#     def get_all_messages(self):
#     def wait_until_empty(self):
#     def __init__(self, src):
#     def _process_message(self, msg):
#     def _loop_once(self):
#     def __init__(self, input_src, num_outputs):
#     def _process_message(self, msg):


# Path: chirp/stream/message_test.py
import unittest
from chirp.stream import message

        self.assertTrue(src.get_next_message(timeout=0.01) is None)

        # Check that we can add a stop message, then get it back out.
        src._add_stop_message()
        msg = src.get_next_message()
        self.assertTrue(msg.is_end_of_stream())
        # The queue should now be empty.
        self.assertTrue(src.get_next_message(timeout=0.01) is None)


class TestMessageConsumer(message.MessageConsumer):
    """A test message consumer that simply appends all consumed messages
    to a list."""

    all_messages = []

    def _process_message(self, msg):
        self.all_messages.append(msg)


class MessageConsumerTestCase(unittest.TestCase):

    def test_basics(self):
        # Construct a source and connect it to our test consumer.
        src = message.MessageSource()
        con = TestMessageConsumer(src)
        # Run the consumer in a separate thread.
        con.loop_in_thread()

        # Add a test message and a stop message to our source.

        msg = message.Message()