mirror of
https://github.com/home-assistant/core.git
synced 2025-12-25 05:26:47 +00:00
Black
This commit is contained in:
@@ -15,14 +15,13 @@ from . import API_PASSWORD, HASSIO_TOKEN
|
||||
@pytest.fixture
|
||||
def hassio_env():
|
||||
"""Fixture to inject hassio env."""
|
||||
with patch.dict(os.environ, {'HASSIO': "127.0.0.1"}), \
|
||||
patch('homeassistant.components.hassio.HassIO.is_connected',
|
||||
Mock(return_value=mock_coro(
|
||||
{"result": "ok", "data": {}}))), \
|
||||
patch.dict(os.environ, {'HASSIO_TOKEN': "123456"}), \
|
||||
patch('homeassistant.components.hassio.HassIO.'
|
||||
'get_homeassistant_info',
|
||||
Mock(side_effect=HassioAPIError())):
|
||||
with patch.dict(os.environ, {"HASSIO": "127.0.0.1"}), patch(
|
||||
"homeassistant.components.hassio.HassIO.is_connected",
|
||||
Mock(return_value=mock_coro({"result": "ok", "data": {}})),
|
||||
), patch.dict(os.environ, {"HASSIO_TOKEN": "123456"}), patch(
|
||||
"homeassistant.components.hassio.HassIO." "get_homeassistant_info",
|
||||
Mock(side_effect=HassioAPIError()),
|
||||
):
|
||||
yield
|
||||
|
||||
|
||||
@@ -30,21 +29,21 @@ def hassio_env():
|
||||
def hassio_stubs(hassio_env, hass, hass_client, aioclient_mock):
|
||||
"""Create mock hassio http client."""
|
||||
with patch(
|
||||
'homeassistant.components.hassio.HassIO.update_hass_api',
|
||||
return_value=mock_coro({"result": "ok"})
|
||||
"homeassistant.components.hassio.HassIO.update_hass_api",
|
||||
return_value=mock_coro({"result": "ok"}),
|
||||
), patch(
|
||||
'homeassistant.components.hassio.HassIO.update_hass_timezone',
|
||||
return_value=mock_coro({"result": "ok"})
|
||||
"homeassistant.components.hassio.HassIO.update_hass_timezone",
|
||||
return_value=mock_coro({"result": "ok"}),
|
||||
), patch(
|
||||
'homeassistant.components.hassio.HassIO.get_homeassistant_info',
|
||||
side_effect=HassioAPIError()
|
||||
"homeassistant.components.hassio.HassIO.get_homeassistant_info",
|
||||
side_effect=HassioAPIError(),
|
||||
):
|
||||
hass.state = CoreState.starting
|
||||
hass.loop.run_until_complete(async_setup_component(hass, 'hassio', {
|
||||
'http': {
|
||||
'api_password': API_PASSWORD
|
||||
}
|
||||
}))
|
||||
hass.loop.run_until_complete(
|
||||
async_setup_component(
|
||||
hass, "hassio", {"http": {"api_password": API_PASSWORD}}
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -62,10 +61,11 @@ def hassio_noauth_client(hassio_stubs, hass, aiohttp_client):
|
||||
@pytest.fixture
|
||||
def hassio_handler(hass, aioclient_mock):
|
||||
"""Create mock hassio handler."""
|
||||
|
||||
async def get_client_session():
|
||||
return hass.helpers.aiohttp_client.async_get_clientsession()
|
||||
|
||||
websession = hass.loop.run_until_complete(get_client_session())
|
||||
|
||||
with patch.dict(os.environ, {'HASSIO_TOKEN': HASSIO_TOKEN}):
|
||||
with patch.dict(os.environ, {"HASSIO_TOKEN": HASSIO_TOKEN}):
|
||||
yield HassIO(hass.loop, websession, "127.0.0.1")
|
||||
|
||||
Reference in New Issue
Block a user