Use hass_client_no_auth test fixture in integrations a-g ()

pull/55594/head
Erik Montnemery 2021-09-02 14:49:20 +02:00 committed by GitHub
parent 69aba2a6a1
commit d5b6dc4f26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 18 additions and 16 deletions
tests/components

View File

@ -382,11 +382,13 @@ def _listen_count(hass):
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."""
hass.data[DATA_LOGGING] = "/some/path"
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)
# Verify auth required

View File

@ -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."""
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"
]
client = await aiohttp_client(hass.http.app)
client = await hass_client_no_auth()
resp = await client.get(url)
assert resp.status == 200
body = await resp.text()

View File

@ -34,7 +34,7 @@ async def calls(hass, 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."""
await async_setup_component(hass, dialogflow.DOMAIN, {"dialogflow": {}})
await async_setup_component(
@ -92,7 +92,7 @@ async def fixture(hass, aiohttp_client):
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
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:

View File

@ -209,7 +209,7 @@ def hass_hue(loop, hass):
@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."""
web_app = hass_hue.http.app
config = Config(
@ -255,7 +255,7 @@ def hue_client(loop, hass_hue, aiohttp_client):
HueFullStateView(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):
@ -302,7 +302,7 @@ async def test_light_without_brightness_supported(hass_hue, hue_client):
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."""
# create a lamp without brightness support
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
web_app = hass.http.app
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(
client, "light.no_brightness", HTTP_OK
)

View File

@ -118,7 +118,7 @@ def mock_dev_track(mock_device_tracker_conf):
@pytest.fixture
async def geofency_client(loop, hass, aiohttp_client):
async def geofency_client(loop, hass, hass_client_no_auth):
"""Geofency mock client (unauthenticated)."""
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()
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)

View File

@ -36,7 +36,7 @@ def auth_header(hass_access_token):
@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."""
loop.run_until_complete(
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

View File

@ -31,7 +31,7 @@ def mock_dev_track(mock_device_tracker_conf):
@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)."""
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()
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)