Legacy api fix (#18733)
* Set user for API password requests * Fix tests * Fix typing
This commit is contained in:
1 parent
9d7b1fc3a7
commit
c2f8dfcb9f
15 files changed
+148
-74
No files matched your search
@@ -23,7 +23,7 @@ NPR_NEWS_MP3_URL = "https://pd.npr.org/anon.npr-mp3/npr/news/newscast.mp3"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def alexa_client(loop, hass, aiohttp_client):
|
||||
def alexa_client(loop, hass, hass_client):
|
||||
"""Initialize a Home Assistant server for testing this module."""
|
||||
@callback
|
||||
def mock_service(call):
|
||||
@@ -95,7 +95,7 @@ def alexa_client(loop, hass, aiohttp_client):
|
||||
},
|
||||
}
|
||||
}))
|
||||
return loop.run_until_complete(aiohttp_client(hass.http.app))
|
||||
return loop.run_until_complete(hass_client())
|
||||
|
||||
|
||||
def _intent_req(client, data=None):
|
||||
|
||||
@@ -1437,10 +1437,10 @@ async def test_unsupported_domain(hass):
|
||||
assert not msg['payload']['endpoints']
|
||||
|
||||
|
||||
async def do_http_discovery(config, hass, aiohttp_client):
|
||||
async def do_http_discovery(config, hass, hass_client):
|
||||
"""Submit a request to the Smart Home HTTP API."""
|
||||
await async_setup_component(hass, alexa.DOMAIN, config)
|
||||
http_client = await aiohttp_client(hass.http.app)
|
||||
http_client = await hass_client()
|
||||
|
||||
request = get_new_request('Alexa.Discovery', 'Discover')
|
||||
response = await http_client.post(
|
||||
@@ -1450,7 +1450,7 @@ async def do_http_discovery(config, hass, aiohttp_client):
|
||||
return response
|
||||
|
||||
|
||||
async def test_http_api(hass, aiohttp_client):
|
||||
async def test_http_api(hass, hass_client):
|
||||
"""With `smart_home:` HTTP API is exposed."""
|
||||
config = {
|
||||
'alexa': {
|
||||
@@ -1458,7 +1458,7 @@ async def test_http_api(hass, aiohttp_client):
|
||||
}
|
||||
}
|
||||
|
||||
response = await do_http_discovery(config, hass, aiohttp_client)
|
||||
response = await do_http_discovery(config, hass, hass_client)
|
||||
response_data = await response.json()
|
||||
|
||||
# Here we're testing just the HTTP view glue -- details of discovery are
|
||||
@@ -1466,12 +1466,12 @@ async def test_http_api(hass, aiohttp_client):
|
||||
assert response_data['event']['header']['name'] == 'Discover.Response'
|
||||
|
||||
|
||||
async def test_http_api_disabled(hass, aiohttp_client):
|
||||
async def test_http_api_disabled(hass, hass_client):
|
||||
"""Without `smart_home:`, the HTTP API is disabled."""
|
||||
config = {
|
||||
'alexa': {}
|
||||
}
|
||||
response = await do_http_discovery(config, hass, aiohttp_client)
|
||||
response = await do_http_discovery(config, hass, hass_client)
|
||||
|
||||
assert response.status == 404
|
||||
|
||||
|
||||
Reference in new issue
Block a user