Skip to content

Commit

Permalink
Remove duplicate mobile_app client fixture (#100530)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Sep 18, 2023
1 parent 276d245 commit f41e3a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
24 changes: 6 additions & 18 deletions tests/components/mobile_app/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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,
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/components/mobile_app/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit f41e3a2

Please sign in to comment.