mirror of
https://github.com/home-assistant/core.git
synced 2025-04-29 11:47:50 +00:00
Remove duplicate mobile_app client fixture (#100530)
This commit is contained in:
parent
276d245409
commit
f41e3a2beb
@ -10,18 +10,16 @@ from .const import REGISTER, REGISTER_CLEARTEXT
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def create_registrations(hass, authed_api_client):
|
async def create_registrations(hass, webhook_client):
|
||||||
"""Return two new registrations."""
|
"""Return two new registrations."""
|
||||||
await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
|
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)
|
||||||
"/api/mobile_app/registrations", json=REGISTER
|
|
||||||
)
|
|
||||||
|
|
||||||
assert enc_reg.status == HTTPStatus.CREATED
|
assert enc_reg.status == HTTPStatus.CREATED
|
||||||
enc_reg_json = await enc_reg.json()
|
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
|
"/api/mobile_app/registrations", json=REGISTER_CLEARTEXT
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,11 +32,11 @@ async def create_registrations(hass, authed_api_client):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def push_registration(hass, authed_api_client):
|
async def push_registration(hass, webhook_client):
|
||||||
"""Return registration with push notifications enabled."""
|
"""Return registration with push notifications enabled."""
|
||||||
await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
|
await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
|
||||||
|
|
||||||
enc_reg = await authed_api_client.post(
|
enc_reg = await webhook_client.post(
|
||||||
"/api/mobile_app/registrations",
|
"/api/mobile_app/registrations",
|
||||||
json={
|
json={
|
||||||
**REGISTER,
|
**REGISTER,
|
||||||
@ -54,17 +52,7 @@ async def push_registration(hass, authed_api_client):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def webhook_client(hass, authed_api_client, aiohttp_client):
|
async def webhook_client(hass, hass_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):
|
|
||||||
"""Provide an authenticated client for mobile_app to use."""
|
"""Provide an authenticated client for mobile_app to use."""
|
||||||
await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
|
await async_setup_component(hass, DOMAIN, {DOMAIN: {}})
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -196,9 +196,9 @@ async def test_webhook_handle_fire_event(
|
|||||||
assert events[0].data["hello"] == "yo world"
|
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."""
|
"""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
|
"/api/mobile_app/registrations", json=REGISTER_CLEARTEXT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user