Use hass_client_no_auth test fixture in nest tests (#56326)

pull/56409/head
Erik Montnemery 2021-09-18 23:17:09 +02:00 committed by GitHub
parent 8b64cd7e7d
commit f6526de7b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -37,10 +37,10 @@ def get_config_entry(hass):
class OAuthFixture: class OAuthFixture:
"""Simulate the oauth flow used by the config flow.""" """Simulate the oauth flow used by the config flow."""
def __init__(self, hass, aiohttp_client, aioclient_mock): def __init__(self, hass, hass_client_no_auth, aioclient_mock):
"""Initialize OAuthFixture.""" """Initialize OAuthFixture."""
self.hass = hass self.hass = hass
self.aiohttp_client = aiohttp_client self.hass_client = hass_client_no_auth
self.aioclient_mock = aioclient_mock self.aioclient_mock = aioclient_mock
async def async_oauth_flow(self, result): async def async_oauth_flow(self, result):
@ -63,7 +63,7 @@ class OAuthFixture:
"&access_type=offline&prompt=consent" "&access_type=offline&prompt=consent"
) )
client = await self.aiohttp_client(self.hass.http.app) client = await self.hass_client()
resp = await client.get(f"/auth/external/callback?code=abcd&state={state}") resp = await client.get(f"/auth/external/callback?code=abcd&state={state}")
assert resp.status == 200 assert resp.status == 200
assert resp.headers["content-type"] == "text/html; charset=utf-8" assert resp.headers["content-type"] == "text/html; charset=utf-8"
@ -86,9 +86,9 @@ class OAuthFixture:
@pytest.fixture @pytest.fixture
async def oauth(hass, aiohttp_client, aioclient_mock, current_request_with_host): async def oauth(hass, hass_client_no_auth, aioclient_mock, current_request_with_host):
"""Create the simulated oauth flow.""" """Create the simulated oauth flow."""
return OAuthFixture(hass, aiohttp_client, aioclient_mock) return OAuthFixture(hass, hass_client_no_auth, aioclient_mock)
async def test_full_flow(hass, oauth): async def test_full_flow(hass, oauth):