Fix tests

pull/19395/head
Paulus Schoutsen 2019-01-11 10:10:36 -08:00
parent 7be197b845
commit b81260e912
2 changed files with 6 additions and 11 deletions

View File

@ -44,18 +44,23 @@ def hassio_stubs(hassio_env, hass, hass_client, aioclient_mock):
@pytest.fixture
def hassio_client(hassio_stubs, hass, hass_client):
"""Return a Hass.io HTTP client."""
yield hass.loop.run_until_complete(hass_client())
@pytest.fixture
def hassio_noauth_client(hassio_stubs, hass, aiohttp_client):
"""Return a Hass.io HTTP client without auth."""
yield hass.loop.run_until_complete(aiohttp_client(hass.http.app))
@pytest.fixture
def hassio_handler(hass, aioclient_mock):
"""Create mock hassio handler."""
websession = hass.helpers.aiohttp_client.async_get_clientsession()
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}):
yield HassIO(hass.loop, websession, "127.0.0.1")

View File

@ -10,8 +10,6 @@ from . import API_PASSWORD
async def test_login_success(hass, hassio_client):
"""Test no auth needed for ."""
await register_auth_provider(hass, {'type': 'homeassistant'})
with patch('homeassistant.auth.providers.homeassistant.'
'HassAuthProvider.async_validate_login',
Mock(return_value=mock_coro())) as mock_login:
@ -34,8 +32,6 @@ async def test_login_success(hass, hassio_client):
async def test_login_error(hass, hassio_client):
"""Test no auth needed for error."""
await register_auth_provider(hass, {'type': 'homeassistant'})
with patch('homeassistant.auth.providers.homeassistant.'
'HassAuthProvider.async_validate_login',
Mock(side_effect=HomeAssistantError())) as mock_login:
@ -58,8 +54,6 @@ async def test_login_error(hass, hassio_client):
async def test_login_no_data(hass, hassio_client):
"""Test auth with no data -> error."""
await register_auth_provider(hass, {'type': 'homeassistant'})
with patch('homeassistant.auth.providers.homeassistant.'
'HassAuthProvider.async_validate_login',
Mock(side_effect=HomeAssistantError())) as mock_login:
@ -77,8 +71,6 @@ async def test_login_no_data(hass, hassio_client):
async def test_login_no_username(hass, hassio_client):
"""Test auth with no username in data -> error."""
await register_auth_provider(hass, {'type': 'homeassistant'})
with patch('homeassistant.auth.providers.homeassistant.'
'HassAuthProvider.async_validate_login',
Mock(side_effect=HomeAssistantError())) as mock_login:
@ -100,8 +92,6 @@ async def test_login_no_username(hass, hassio_client):
async def test_login_success_extra(hass, hassio_client):
"""Test auth with extra data."""
await register_auth_provider(hass, {'type': 'homeassistant'})
with patch('homeassistant.auth.providers.homeassistant.'
'HassAuthProvider.async_validate_login',
Mock(return_value=mock_coro())) as mock_login: