From 1fa3f324745053dce0bbfc29e6b090618c7f8515 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 1 Mar 2023 09:41:55 +0100 Subject: [PATCH] Add missing mock in notion tests (#88951) --- tests/components/notion/conftest.py | 10 ++++++++++ tests/components/notion/test_config_flow.py | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/components/notion/conftest.py b/tests/components/notion/conftest.py index a66d99d41ce..7484e8a997f 100644 --- a/tests/components/notion/conftest.py +++ b/tests/components/notion/conftest.py @@ -1,4 +1,5 @@ """Define fixtures for Notion tests.""" +from collections.abc import Generator import json from unittest.mock import AsyncMock, Mock, patch @@ -13,6 +14,15 @@ TEST_USERNAME = "user@host.com" 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") def client_fixture(data_bridge, data_sensor, data_task): """Define a fixture for an aionotion client.""" diff --git a/tests/components/notion/test_config_flow.py b/tests/components/notion/test_config_flow.py index d0d1cad0350..e9f340fae17 100644 --- a/tests/components/notion/test_config_flow.py +++ b/tests/components/notion/test_config_flow.py @@ -12,6 +12,8 @@ from homeassistant.core import HomeAssistant from .conftest import TEST_PASSWORD, TEST_USERNAME +pytestmark = pytest.mark.usefixtures("mock_setup_entry") + @pytest.mark.parametrize( ("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.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=config @@ -81,7 +83,7 @@ async def test_reauth( config_entry, errors, get_client_with_exception, - setup_config_entry, + mock_aionotion, ) -> None: """Test that re-auth works.""" result = await hass.config_entries.flow.async_init(