Move imports to top for notion (#29539)

* Move imports to top for notion

* Fix mocking library in test_config_flow.py
This commit is contained in:
springstan 2019-12-06 20:40:00 +01:00 committed by Aaron Bach
parent 8afe13e818
commit 6af30bc232
3 changed files with 6 additions and 6 deletions

View file

@ -17,7 +17,6 @@ from . import (
SENSOR_WINDOW_HINGED_VERTICAL, SENSOR_WINDOW_HINGED_VERTICAL,
NotionEntity, NotionEntity,
) )
from .const import DATA_CLIENT, DOMAIN from .const import DATA_CLIENT, DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View file

@ -1,4 +1,6 @@
"""Config flow to configure the Notion integration.""" """Config flow to configure the Notion integration."""
from aionotion import async_get_client
from aionotion.errors import NotionError
import voluptuous as vol import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
@ -40,8 +42,6 @@ class NotionFlowHandler(config_entries.ConfigFlow):
async def async_step_user(self, user_input=None): async def async_step_user(self, user_input=None):
"""Handle the start of the config flow.""" """Handle the start of the config flow."""
from aionotion import async_get_client
from aionotion.errors import NotionError
if not user_input: if not user_input:
return await self._show_form() return await self._show_form()

View file

@ -1,12 +1,13 @@
"""Define tests for the Notion config flow.""" """Define tests for the Notion config flow."""
import aionotion import aionotion
from unittest.mock import patch
import pytest import pytest
from homeassistant import data_entry_flow from homeassistant import data_entry_flow
from homeassistant.components.notion import DOMAIN, config_flow from homeassistant.components.notion import DOMAIN, config_flow
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from tests.common import MockConfigEntry, MockDependency, mock_coro from tests.common import MockConfigEntry, mock_coro
@pytest.fixture @pytest.fixture
@ -18,8 +19,8 @@ def mock_client_coro():
@pytest.fixture @pytest.fixture
def mock_aionotion(mock_client_coro): def mock_aionotion(mock_client_coro):
"""Mock the aionotion library.""" """Mock the aionotion library."""
with MockDependency("aionotion") as mock_: with patch("homeassistant.components.notion.config_flow.async_get_client") as mock_:
mock_.async_get_client.return_value = mock_client_coro mock_.return_value = mock_client_coro
yield mock_ yield mock_