diff --git a/tests/components/withings/common.py b/tests/components/withings/common.py index 9e6efeb37bf..847f482b6c5 100644 --- a/tests/components/withings/common.py +++ b/tests/components/withings/common.py @@ -103,13 +103,13 @@ class ComponentFactory: self, hass: HomeAssistant, api_class_mock: MagicMock, - aiohttp_client, + hass_client_no_auth, aioclient_mock: AiohttpClientMocker, ) -> None: """Initialize the object.""" self._hass = hass self._api_class_mock = api_class_mock - self._aiohttp_client = aiohttp_client + self._hass_client = hass_client_no_auth self._aioclient_mock = aioclient_mock self._client_id = None self._client_secret = None @@ -208,7 +208,7 @@ class ComponentFactory: ) # Simulate user being redirected from withings site. - client: TestClient = await self._aiohttp_client(self._hass.http.app) + client: TestClient = await self._hass_client() resp = await client.get(f"{AUTH_CALLBACK_PATH}?code=abcd&state={state}") assert resp.status == 200 assert resp.headers["content-type"] == "text/html; charset=utf-8" @@ -259,7 +259,7 @@ class ComponentFactory: async def call_webhook(self, user_id: int, appli: NotifyAppli) -> WebhookResponse: """Call the webhook to notify of data changes.""" - client: TestClient = await self._aiohttp_client(self._hass.http.app) + client: TestClient = await self._hass_client() data_manager = get_data_manager_by_user_id(self._hass, user_id) resp = await client.post( diff --git a/tests/components/withings/conftest.py b/tests/components/withings/conftest.py index c95abc8addd..787a2ee4cb0 100644 --- a/tests/components/withings/conftest.py +++ b/tests/components/withings/conftest.py @@ -13,10 +13,12 @@ from tests.test_util.aiohttp import AiohttpClientMocker @pytest.fixture() def component_factory( - hass: HomeAssistant, aiohttp_client, aioclient_mock: AiohttpClientMocker + hass: HomeAssistant, hass_client_no_auth, aioclient_mock: AiohttpClientMocker ): """Return a factory for initializing the withings component.""" with patch( "homeassistant.components.withings.common.ConfigEntryWithingsApi" ) as api_class_mock: - yield ComponentFactory(hass, api_class_mock, aiohttp_client, aioclient_mock) + yield ComponentFactory( + hass, api_class_mock, hass_client_no_auth, aioclient_mock + ) diff --git a/tests/components/withings/test_config_flow.py b/tests/components/withings/test_config_flow.py index 618dd19f80b..83368ed3fa1 100644 --- a/tests/components/withings/test_config_flow.py +++ b/tests/components/withings/test_config_flow.py @@ -35,7 +35,7 @@ async def test_config_non_unique_profile(hass: HomeAssistant) -> None: async def test_config_reauth_profile( - hass: HomeAssistant, aiohttp_client, aioclient_mock, current_request_with_host + hass: HomeAssistant, hass_client_no_auth, aioclient_mock, current_request_with_host ) -> None: """Test reauth an existing profile re-creates the config entry.""" hass_config = { @@ -81,7 +81,7 @@ async def test_config_reauth_profile( }, ) - client: TestClient = await aiohttp_client(hass.http.app) + client: TestClient = await hass_client_no_auth() resp = await client.get(f"{AUTH_CALLBACK_PATH}?code=abcd&state={state}") assert resp.status == 200 assert resp.headers["content-type"] == "text/html; charset=utf-8"