def mock_session():
    """Mock aiohttp.ClientSession."""
    mocker = AiohttpClientMocker()

    with patch('aiohttp.ClientSession',
               side_effect=lambda *args, **kwargs:
                   mocker.create_session(asyncio.get_event_loop())):
        yield mocker
예제 #2
0
def mock_session():
    """Mock aiohttp.ClientSession."""
    mocker = AiohttpClientMocker()

    with patch('aiohttp.ClientSession',
               side_effect=lambda *args, **kwargs: mocker.create_session(
                   asyncio.get_event_loop())):
        yield mocker
예제 #3
0
파일: conftest.py 프로젝트: jcgoette/core
async def get_data_from_library(hass: HomeAssistant,
                                aioclient_mock: AiohttpClientMocker,
                                load_json: dict[str, Any]) -> SensiboData:
    """Retrieve data from upstream Sensibo library."""

    client = SensiboClient("123467890",
                           aioclient_mock.create_session(hass.loop))
    with patch("pysensibo.SensiboClient.async_get_devices",
               return_value=load_json):
        output = await client.async_get_devices_data()
    await client._session.close()  # pylint: disable=protected-access
    return output