# Path: src/tests/common/unit/base.py
# class MercuryCommonUnitTest(unittest.TestCase):
#     """Base class for mercury-common unit tests."""
#     pass


import mock
import msgpack
import pytest
import zmq
from mercury.common.exceptions import MercuryClientException
from mercury.common import transport
from .base import MercuryCommonUnitTest

def test_get_ctx_and_connect_req_socket():
    with mock.patch('zmq.Context.socket') as mock_socket:
        ctx, socket = transport.get_ctx_and_connect_req_socket('zmq_url')

    assert isinstance(ctx, zmq.Context)
    mock_socket.assert_called_once()


def test_parse_multipart_message():
    """Test parse_multipart_message()"""
    message = ['addr', '', 'msg']
    parsed_message = transport.parse_multipart_message(message)
    assert parsed_message == {'address': ['addr', ''], 'message': 'msg'}


def test_parse_multipart_message_error():
    """Test parse_multipart_message() with a 2-parts message."""
    message = ['addr', '']
    parsed_message = transport.parse_multipart_message(message)
    assert parsed_message == {}


def test_serialize_addresses():
    """Test serialize_addresses()"""
    multipart_address = ['addr', 'addr2', '']
    addresses = transport.serialize_addresses(multipart_address)
    assert addresses == ['addr', 'addr2']



# Path: src/tests/common/unit/base.py
# class MercuryCommonUnitTest(unittest.TestCase):
#     """Base class for mercury-common unit tests."""
#     pass


# Path: src/tests/common/unit/test_transport.py
import mock
import msgpack
import pytest
import zmq
from mercury.common.exceptions import MercuryClientException
from mercury.common import transport
from .base import MercuryCommonUnitTest


def test_get_ctx_and_connect_req_socket():
    with mock.patch('zmq.Context.socket') as mock_socket:
        ctx, socket = transport.get_ctx_and_connect_req_socket('zmq_url')

    assert isinstance(ctx, zmq.Context)
    mock_socket.assert_called_once()


def test_parse_multipart_message():
    """Test parse_multipart_message()"""
    message = ['addr', '', 'msg']
    parsed_message = transport.parse_multipart_message(message)
    assert parsed_message == {'address': ['addr', ''], 'message': 'msg'}


def test_parse_multipart_message_error():
    """Test parse_multipart_message() with a 2-parts message."""
    message = ['addr', '']
    parsed_message = transport.parse_multipart_message(message)
    assert parsed_message == {}


def test_serialize_addresses():
    """Test serialize_addresses()"""
    multipart_address = ['addr', 'addr2', '']
    addresses = transport.serialize_addresses(multipart_address)
    assert addresses == ['addr', 'addr2']



class SimpleRouterReqServiceUnitTest(MercuryCommonUnitTest):