mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use hass_client_no_auth test fixture in integrations a-g (#55581)
This commit is contained in:
parent
69aba2a6a1
commit
d5b6dc4f26
@ -382,11 +382,13 @@ def _listen_count(hass):
|
|||||||
return sum(hass.bus.async_listeners().values())
|
return sum(hass.bus.async_listeners().values())
|
||||||
|
|
||||||
|
|
||||||
async def test_api_error_log(hass, aiohttp_client, hass_access_token, hass_admin_user):
|
async def test_api_error_log(
|
||||||
|
hass, hass_client_no_auth, hass_access_token, hass_admin_user
|
||||||
|
):
|
||||||
"""Test if we can fetch the error log."""
|
"""Test if we can fetch the error log."""
|
||||||
hass.data[DATA_LOGGING] = "/some/path"
|
hass.data[DATA_LOGGING] = "/some/path"
|
||||||
await async_setup_component(hass, "api", {})
|
await async_setup_component(hass, "api", {})
|
||||||
client = await aiohttp_client(hass.http.app)
|
client = await hass_client_no_auth()
|
||||||
|
|
||||||
resp = await client.get(const.URL_API_ERROR_LOG)
|
resp = await client.get(const.URL_API_ERROR_LOG)
|
||||||
# Verify auth required
|
# Verify auth required
|
||||||
|
@ -10,7 +10,7 @@ from tests.components.august.mocks import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def test_create_doorbell(hass, aiohttp_client):
|
async def test_create_doorbell(hass, hass_client_no_auth):
|
||||||
"""Test creation of a doorbell."""
|
"""Test creation of a doorbell."""
|
||||||
doorbell_one = await _mock_doorbell_from_fixture(hass, "get_doorbell.json")
|
doorbell_one = await _mock_doorbell_from_fixture(hass, "get_doorbell.json")
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ async def test_create_doorbell(hass, aiohttp_client):
|
|||||||
"entity_picture"
|
"entity_picture"
|
||||||
]
|
]
|
||||||
|
|
||||||
client = await aiohttp_client(hass.http.app)
|
client = await hass_client_no_auth()
|
||||||
resp = await client.get(url)
|
resp = await client.get(url)
|
||||||
assert resp.status == 200
|
assert resp.status == 200
|
||||||
body = await resp.text()
|
body = await resp.text()
|
||||||
|
@ -34,7 +34,7 @@ async def calls(hass, fixture):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def fixture(hass, aiohttp_client):
|
async def fixture(hass, hass_client_no_auth):
|
||||||
"""Initialize a Home Assistant server for testing this module."""
|
"""Initialize a Home Assistant server for testing this module."""
|
||||||
await async_setup_component(hass, dialogflow.DOMAIN, {"dialogflow": {}})
|
await async_setup_component(hass, dialogflow.DOMAIN, {"dialogflow": {}})
|
||||||
await async_setup_component(
|
await async_setup_component(
|
||||||
@ -92,7 +92,7 @@ async def fixture(hass, aiohttp_client):
|
|||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
webhook_id = result["result"].data["webhook_id"]
|
webhook_id = result["result"].data["webhook_id"]
|
||||||
|
|
||||||
return await aiohttp_client(hass.http.app), webhook_id
|
return await hass_client_no_auth(), webhook_id
|
||||||
|
|
||||||
|
|
||||||
class _Data:
|
class _Data:
|
||||||
|
@ -209,7 +209,7 @@ def hass_hue(loop, hass):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def hue_client(loop, hass_hue, aiohttp_client):
|
def hue_client(loop, hass_hue, hass_client_no_auth):
|
||||||
"""Create web client for emulated hue api."""
|
"""Create web client for emulated hue api."""
|
||||||
web_app = hass_hue.http.app
|
web_app = hass_hue.http.app
|
||||||
config = Config(
|
config = Config(
|
||||||
@ -255,7 +255,7 @@ def hue_client(loop, hass_hue, aiohttp_client):
|
|||||||
HueFullStateView(config).register(web_app, web_app.router)
|
HueFullStateView(config).register(web_app, web_app.router)
|
||||||
HueConfigView(config).register(web_app, web_app.router)
|
HueConfigView(config).register(web_app, web_app.router)
|
||||||
|
|
||||||
return loop.run_until_complete(aiohttp_client(web_app))
|
return loop.run_until_complete(hass_client_no_auth())
|
||||||
|
|
||||||
|
|
||||||
async def test_discover_lights(hue_client):
|
async def test_discover_lights(hue_client):
|
||||||
@ -302,7 +302,7 @@ async def test_light_without_brightness_supported(hass_hue, hue_client):
|
|||||||
assert light_without_brightness_json["type"] == "On/Off light"
|
assert light_without_brightness_json["type"] == "On/Off light"
|
||||||
|
|
||||||
|
|
||||||
async def test_lights_all_dimmable(hass, aiohttp_client):
|
async def test_lights_all_dimmable(hass, hass_client_no_auth):
|
||||||
"""Test CONF_LIGHTS_ALL_DIMMABLE."""
|
"""Test CONF_LIGHTS_ALL_DIMMABLE."""
|
||||||
# create a lamp without brightness support
|
# create a lamp without brightness support
|
||||||
hass.states.async_set("light.no_brightness", "on", {})
|
hass.states.async_set("light.no_brightness", "on", {})
|
||||||
@ -326,7 +326,7 @@ async def test_lights_all_dimmable(hass, aiohttp_client):
|
|||||||
config.numbers = ENTITY_IDS_BY_NUMBER
|
config.numbers = ENTITY_IDS_BY_NUMBER
|
||||||
web_app = hass.http.app
|
web_app = hass.http.app
|
||||||
HueOneLightStateView(config).register(web_app, web_app.router)
|
HueOneLightStateView(config).register(web_app, web_app.router)
|
||||||
client = await aiohttp_client(web_app)
|
client = await hass_client_no_auth()
|
||||||
light_without_brightness_json = await perform_get_light_state(
|
light_without_brightness_json = await perform_get_light_state(
|
||||||
client, "light.no_brightness", HTTP_OK
|
client, "light.no_brightness", HTTP_OK
|
||||||
)
|
)
|
||||||
|
@ -118,7 +118,7 @@ def mock_dev_track(mock_device_tracker_conf):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def geofency_client(loop, hass, aiohttp_client):
|
async def geofency_client(loop, hass, hass_client_no_auth):
|
||||||
"""Geofency mock client (unauthenticated)."""
|
"""Geofency mock client (unauthenticated)."""
|
||||||
assert await async_setup_component(hass, "persistent_notification", {})
|
assert await async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ async def geofency_client(loop, hass, aiohttp_client):
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
with patch("homeassistant.components.device_tracker.legacy.update_config"):
|
with patch("homeassistant.components.device_tracker.legacy.update_config"):
|
||||||
return await aiohttp_client(hass.http.app)
|
return await hass_client_no_auth()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
|
@ -36,7 +36,7 @@ def auth_header(hass_access_token):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def assistant_client(loop, hass, aiohttp_client):
|
def assistant_client(loop, hass, hass_client_no_auth):
|
||||||
"""Create web client for the Google Assistant API."""
|
"""Create web client for the Google Assistant API."""
|
||||||
loop.run_until_complete(
|
loop.run_until_complete(
|
||||||
setup.async_setup_component(
|
setup.async_setup_component(
|
||||||
@ -56,7 +56,7 @@ def assistant_client(loop, hass, aiohttp_client):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return loop.run_until_complete(aiohttp_client(hass.http.app))
|
return loop.run_until_complete(hass_client_no_auth())
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -31,7 +31,7 @@ def mock_dev_track(mock_device_tracker_conf):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
async def gpslogger_client(loop, hass, aiohttp_client):
|
async def gpslogger_client(loop, hass, hass_client_no_auth):
|
||||||
"""Mock client for GPSLogger (unauthenticated)."""
|
"""Mock client for GPSLogger (unauthenticated)."""
|
||||||
assert await async_setup_component(hass, "persistent_notification", {})
|
assert await async_setup_component(hass, "persistent_notification", {})
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ async def gpslogger_client(loop, hass, aiohttp_client):
|
|||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
with patch("homeassistant.components.device_tracker.legacy.update_config"):
|
with patch("homeassistant.components.device_tracker.legacy.update_config"):
|
||||||
return await aiohttp_client(hass.http.app)
|
return await hass_client_no_auth()
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user