# Path: pymco/listener.py
# LOG = logging.getLogger(__name__)
# class CurrentHostPortListener(listener.ConnectionListener):
# class ResponseListener(listener.ConnectionListener):
#     def __init__(self, *args, **kwargs):
#     def on_connecting(self, host_and_port):
#     def get_host(self):
#     def get_port(self):
#     def __init__(self, config, connector, count, timeout=30, condition=None,
#                  logger=LOG):
#     def security(self):
#     def on_message(self, headers, body):
#     def wait_on_message(self):
#     def _wait_loop(self, timeout):
# 
# Path: pymco/test/utils.py
# def get_template(name, package=__package__):
# def configfile(ctxt=None):


from yaml import scanner
from pymco import listener
from pymco.test.utils import mock
import pytest
        exc = scanner.ScannerError()
        get_security.return_value.decode.side_effect = exc
        result_listener.on_message(body='--- :this is not valid yaml:', headers={})

        logger.debug.assert_has_calls(
            [mock.call('Exception caught when decoding message body')]
        )
        logger.exception.assert_called_once_with(exc)


def test_wait_on_message__acquire_release_condition(result_listener, condition):
    result_listener.received = result_listener.count + 1
    assert result_listener.wait_on_message() == result_listener
    condition.acquire.assert_called_once_with()
    condition.release.assert_called_once_with()


def test_wait_on_message__reset_received_count(result_listener, condition):
    result_listener.received = result_listener.count + 1
    assert result_listener.wait_on_message().received == 0


def test_wait_on_message__runs_wait_loop(result_listener, condition):
    with mock.patch.object(result_listener, '_wait_loop') as wait_loop:
        result_listener.received = result_listener.count + 1
        result_listener.wait_on_message()
    wait_loop.assert_called_once_with(result_listener.timeout)


def test_wait_loop__exits_when_count_is_reached(result_listener, condition):

# Path: pymco/listener.py
# LOG = logging.getLogger(__name__)
# class CurrentHostPortListener(listener.ConnectionListener):
# class ResponseListener(listener.ConnectionListener):
#     def __init__(self, *args, **kwargs):
#     def on_connecting(self, host_and_port):
#     def get_host(self):
#     def get_port(self):
#     def __init__(self, config, connector, count, timeout=30, condition=None,
#                  logger=LOG):
#     def security(self):
#     def on_message(self, headers, body):
#     def wait_on_message(self):
#     def _wait_loop(self, timeout):
# 
# Path: pymco/test/utils.py
# def get_template(name, package=__package__):
# def configfile(ctxt=None):


# Path: tests/unit/test_listener.py
from yaml import scanner
from pymco import listener
from pymco.test.utils import mock
import pytest

        exc = scanner.ScannerError()
        get_security.return_value.decode.side_effect = exc
        result_listener.on_message(body='--- :this is not valid yaml:', headers={})

        logger.debug.assert_has_calls(
            [mock.call('Exception caught when decoding message body')]
        )
        logger.exception.assert_called_once_with(exc)


def test_wait_on_message__acquire_release_condition(result_listener, condition):
    result_listener.received = result_listener.count + 1
    assert result_listener.wait_on_message() == result_listener
    condition.acquire.assert_called_once_with()
    condition.release.assert_called_once_with()


def test_wait_on_message__reset_received_count(result_listener, condition):
    result_listener.received = result_listener.count + 1
    assert result_listener.wait_on_message().received == 0


def test_wait_on_message__runs_wait_loop(result_listener, condition):
    with mock.patch.object(result_listener, '_wait_loop') as wait_loop:
        result_listener.received = result_listener.count + 1
        result_listener.wait_on_message()
    wait_loop.assert_called_once_with(result_listener.timeout)


def test_wait_loop__exits_when_count_is_reached(result_listener, condition):

    type(result_listener).received = mock.PropertyMock(side_effect=(0, 3))