from unittest.mock import Mock
from unittest.mock import patch


def mock_gateway_fixture(gateway_id):
    """Mock a Tradfri gateway."""

    def get_devices():
        """Return mock devices."""
        return gateway.mock_devices

    def get_groups():
        """Return mock groups."""
        return gateway.mock_groups

    gateway_info = Mock(id=gateway_id, firmware_version="1.2.1234")

    def get_gateway_info():
        """Return mock gateway info."""
        return gateway_info

    gateway = Mock(
        get_devices=get_devices,
        get_groups=get_groups,
        get_gateway_info=get_gateway_info,
        mock_devices=[],
        mock_groups=[],
        mock_responses=[],
    )
    with patch("homeassistant.components.tradfri.Gateway", return_value=gateway), patch(
        "homeassistant.components.tradfri.config_flow.Gateway", return_value=gateway
    ):
        yield gateway