Use constants for HTTP headers (#10313)

* Use constants for HTTP headers

* Fix ordering

* Move 'no-cache' to platform
This commit is contained in:
Fabian Affolter 2017-11-04 20:04:05 +01:00 committed by Paulus Schoutsen
parent e64803e701
commit de9d19d6f4
36 changed files with 408 additions and 444 deletions

View file

@ -1,18 +1,18 @@
"""The tests for the Google Actions component."""
"""The tests for the Google Assistant component."""
# pylint: disable=protected-access
import json
import asyncio
import pytest
import json
from homeassistant import setup, const, core
from homeassistant.components import (
http, async_setup, light, cover, media_player, fan, switch, climate
)
from homeassistant.components import google_assistant as ga
from aiohttp.hdrs import CONTENT_TYPE, AUTHORIZATION
import pytest
from tests.common import get_test_instance_port
from . import DEMO_DEVICES
from homeassistant import core, const, setup
from homeassistant.components import (
fan, http, cover, light, switch, climate, async_setup, media_player)
from homeassistant.components import google_assistant as ga
from . import DEMO_DEVICES
API_PASSWORD = "test1234"
SERVER_PORT = get_test_instance_port()
@ -20,7 +20,7 @@ BASE_API_URL = "http://127.0.0.1:{}".format(SERVER_PORT)
HA_HEADERS = {
const.HTTP_HEADER_HA_AUTH: API_PASSWORD,
const.HTTP_HEADER_CONTENT_TYPE: const.CONTENT_TYPE_JSON,
CONTENT_TYPE: const.CONTENT_TYPE_JSON,
}
AUTHCFG = {
@ -28,12 +28,12 @@ AUTHCFG = {
'client_id': 'helloworld',
'access_token': 'superdoublesecret'
}
AUTH_HEADER = {'Authorization': 'Bearer {}'.format(AUTHCFG['access_token'])}
AUTH_HEADER = {AUTHORIZATION: 'Bearer {}'.format(AUTHCFG['access_token'])}
@pytest.fixture
def assistant_client(loop, hass_fixture, test_client):
"""Create web client for emulated hue api."""
"""Create web client for the Google Assistant API."""
hass = hass_fixture
web_app = hass.http.app
@ -45,7 +45,7 @@ def assistant_client(loop, hass_fixture, test_client):
@pytest.fixture
def hass_fixture(loop, hass):
"""Set up a hass instance for these tests."""
"""Set up a HOme Assistant instance for these tests."""
# We need to do this to get access to homeassistant/turn_(on,off)
loop.run_until_complete(async_setup(hass, {core.DOMAIN: {}}))