Add missing mock in notion tests (#88951)
This commit is contained in:
parent
853bd52a22
commit
1fa3f32474
2 changed files with 14 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
"""Define fixtures for Notion tests."""
|
"""Define fixtures for Notion tests."""
|
||||||
|
from collections.abc import Generator
|
||||||
import json
|
import json
|
||||||
from unittest.mock import AsyncMock, Mock, patch
|
from unittest.mock import AsyncMock, Mock, patch
|
||||||
|
|
||||||
|
@ -13,6 +14,15 @@ TEST_USERNAME = "user@host.com"
|
||||||
TEST_PASSWORD = "password123"
|
TEST_PASSWORD = "password123"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
|
||||||
|
"""Override async_setup_entry."""
|
||||||
|
with patch(
|
||||||
|
"homeassistant.components.notion.async_setup_entry", return_value=True
|
||||||
|
) as mock_setup_entry:
|
||||||
|
yield mock_setup_entry
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name="client")
|
@pytest.fixture(name="client")
|
||||||
def client_fixture(data_bridge, data_sensor, data_task):
|
def client_fixture(data_bridge, data_sensor, data_task):
|
||||||
"""Define a fixture for an aionotion client."""
|
"""Define a fixture for an aionotion client."""
|
||||||
|
|
|
@ -12,6 +12,8 @@ from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .conftest import TEST_PASSWORD, TEST_USERNAME
|
from .conftest import TEST_PASSWORD, TEST_USERNAME
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("get_client_with_exception", "errors"),
|
("get_client_with_exception", "errors"),
|
||||||
|
@ -58,7 +60,7 @@ async def test_create_entry(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async def test_duplicate_error(hass: HomeAssistant, config, setup_config_entry) -> None:
|
async def test_duplicate_error(hass: HomeAssistant, config, config_entry) -> None:
|
||||||
"""Test that errors are shown when duplicates are added."""
|
"""Test that errors are shown when duplicates are added."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=config
|
DOMAIN, context={"source": SOURCE_USER}, data=config
|
||||||
|
@ -81,7 +83,7 @@ async def test_reauth(
|
||||||
config_entry,
|
config_entry,
|
||||||
errors,
|
errors,
|
||||||
get_client_with_exception,
|
get_client_with_exception,
|
||||||
setup_config_entry,
|
mock_aionotion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test that re-auth works."""
|
"""Test that re-auth works."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
|
Loading…
Add table
Reference in a new issue