Beispiel #1
0
def mock_get_state_response() -> Generator[MagicMock, Any, None]:
    """Fixture for mocking the get_state response.

    Yields:
      Mocked ``SwitcherV2StateResponseMSG`` object.

    """
    mock_future_response = MagicMock(messages.SwitcherV2StateResponseMSG)
    mock_future_response.successful = True
    mock_future_response.state = STATE_ON
    mock_future_response.time_left = consts.DUMMY_TIME_LEFT
    mock_future_response.time_on = consts.DUMMY_TIME_ON
    mock_future_response.auto_off = consts.DUMMY_AUTO_OFF
    mock_future_response.power = consts.DUMMY_POWER_CONSUMPTION
    mock_future_response.current = consts.DUMMY_ELECTRIC_CURRENT
    mock_future_response.msg_type = messages.ResponseMessageType.STATE

    mock_initial_response = MagicMock(messages.SwitcherV2StateResponseMSG)
    mock_initial_response.init_future = Future()
    mock_initial_response.init_future.set_result(mock_future_response)

    with patch(
            "request_handlers.messages.SwitcherV2StateResponseMSG",
            new=mock_initial_response,
    ) as patcher:
        yield patcher