From f41e3a2beb315f57a5c96201a86e5f4dea3f035c Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:52:43 +0200 Subject: [PATCH] Remove duplicate mobile_app client fixture (#100530) --- tests/components/mobile_app/conftest.py | 24 ++++++--------------- tests/components/mobile_app/test_webhook.py | 4 ++-- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/tests/components/mobile_app/conftest.py b/tests/components/mobile_app/conftest.py index e7c9ad4995a4f8..f69912f176c713 100644 --- a/tests/components/mobile_app/conftest.py +++ b/tests/components/mobile_app/conftest.py @@ -10,18 +10,16 @@ @pytest.fixture -async def create_registrations(hass, authed_api_client): +async def create_registrations(hass, webhook_client): """Return two new registrations.""" await async_setup_component(hass, DOMAIN, {DOMAIN: {}}) - enc_reg = await authed_api_client.post( - "/api/mobile_app/registrations", json=REGISTER - ) + enc_reg = await webhook_client.post("/api/mobile_app/registrations", json=REGISTER) assert enc_reg.status == HTTPStatus.CREATED enc_reg_json = await enc_reg.json() - clear_reg = await authed_api_client.post( + clear_reg = await webhook_client.post( "/api/mobile_app/registrations", json=REGISTER_CLEARTEXT ) @@ -34,11 +32,11 @@ async def create_registrations(hass, authed_api_client): @pytest.fixture -async def push_registration(hass, authed_api_client): +async def push_registration(hass, webhook_client): """Return registration with push notifications enabled.""" await async_setup_component(hass, DOMAIN, {DOMAIN: {}}) - enc_reg = await authed_api_client.post( + enc_reg = await webhook_client.post( "/api/mobile_app/registrations", json={ **REGISTER, @@ -54,17 +52,7 @@ async def push_registration(hass, authed_api_client): @pytest.fixture -async def webhook_client(hass, authed_api_client, aiohttp_client): - """mobile_app mock client.""" - # We pass in the authed_api_client server instance because - # it is used inside create_registrations and just passing in - # the app instance would cause the server to start twice, - # which caused deprecation warnings to be printed. - return await aiohttp_client(authed_api_client.server) - - -@pytest.fixture -async def authed_api_client(hass, hass_client): +async def webhook_client(hass, hass_client): """Provide an authenticated client for mobile_app to use.""" await async_setup_component(hass, DOMAIN, {DOMAIN: {}}) await hass.async_block_till_done() diff --git a/tests/components/mobile_app/test_webhook.py b/tests/components/mobile_app/test_webhook.py index 4faf48e2118a62..9f6aec404e2b37 100644 --- a/tests/components/mobile_app/test_webhook.py +++ b/tests/components/mobile_app/test_webhook.py @@ -196,9 +196,9 @@ def store_event(event): assert events[0].data["hello"] == "yo world" -async def test_webhook_update_registration(webhook_client, authed_api_client) -> None: +async def test_webhook_update_registration(webhook_client) -> None: """Test that a we can update an existing registration via webhook.""" - register_resp = await authed_api_client.post( + register_resp = await webhook_client.post( "/api/mobile_app/registrations", json=REGISTER_CLEARTEXT )