mirror of
https://github.com/home-assistant/core.git
synced 2025-12-27 06:28:31 +00:00
Cleanup hass.io component (#12556)
* Cleanup hass.io component * fix lint * Fix all tests * Fix lint * fix lint * fix doc lint
This commit is contained in:
committed by
Paulus Schoutsen
parent
316eb59de2
commit
4f96eeb06e
40
tests/components/hassio/conftest.py
Normal file
40
tests/components/hassio/conftest.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Fixtures for Hass.io."""
|
||||
import os
|
||||
from unittest.mock import patch, Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.common import mock_coro
|
||||
from . import API_PASSWORD
|
||||
|
||||
|
||||
@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(return_value=mock_coro(None))):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def hassio_client(hassio_env, hass, test_client):
|
||||
"""Create mock hassio http client."""
|
||||
with patch('homeassistant.components.hassio.HassIO.update_hass_api',
|
||||
Mock(return_value=mock_coro({"result": "ok"}))), \
|
||||
patch('homeassistant.components.hassio.HassIO.'
|
||||
'get_homeassistant_info',
|
||||
Mock(return_value=mock_coro(None))):
|
||||
hass.loop.run_until_complete(async_setup_component(hass, 'hassio', {
|
||||
'http': {
|
||||
'api_password': API_PASSWORD
|
||||
}
|
||||
}))
|
||||
yield hass.loop.run_until_complete(test_client(hass.http.app))
|
||||
Reference in New Issue
Block a user