mirror of
https://github.com/home-assistant/core.git
synced 2025-04-27 18:57:57 +00:00
Fix more deprecation warnings (#7778)
* Remove setting up an hbmqtt broker * Don't pass loop to web.Application in tests * Use .query instead of deprecated .GET for aiohttp requests * Fix closing file resource * Do not use asyncio mark * Notify.html5 - PyJWT: Use options to disable verify * Yamaha: Test was still using deprecated ip * Remove pytest-asyncio
This commit is contained in:
parent
910020bc5f
commit
e68bd0457c
@ -83,7 +83,7 @@ class APIEventStream(HomeAssistantView):
|
|||||||
stop_obj = object()
|
stop_obj = object()
|
||||||
to_write = asyncio.Queue(loop=hass.loop)
|
to_write = asyncio.Queue(loop=hass.loop)
|
||||||
|
|
||||||
restrict = request.GET.get('restrict')
|
restrict = request.query.get('restrict')
|
||||||
if restrict:
|
if restrict:
|
||||||
restrict = restrict.split(',') + [EVENT_HOMEASSISTANT_STOP]
|
restrict = restrict.split(',') + [EVENT_HOMEASSISTANT_STOP]
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class MyStromView(HomeAssistantView):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""The GET request received from a myStrom button."""
|
"""The GET request received from a myStrom button."""
|
||||||
res = yield from self._handle(request.app['hass'], request.GET)
|
res = yield from self._handle(request.app['hass'], request.query)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -241,7 +241,7 @@ class CameraView(HomeAssistantView):
|
|||||||
return web.Response(status=status)
|
return web.Response(status=status)
|
||||||
|
|
||||||
authenticated = (request[KEY_AUTHENTICATED] or
|
authenticated = (request[KEY_AUTHENTICATED] or
|
||||||
request.GET.get('token') in camera.access_tokens)
|
request.query.get('token') in camera.access_tokens)
|
||||||
|
|
||||||
if not authenticated:
|
if not authenticated:
|
||||||
return web.Response(status=401)
|
return web.Response(status=401)
|
||||||
|
@ -39,7 +39,7 @@ class GPSLoggerView(HomeAssistantView):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""Handle for GPSLogger message received as GET."""
|
"""Handle for GPSLogger message received as GET."""
|
||||||
res = yield from self._handle(request.app['hass'], request.GET)
|
res = yield from self._handle(request.app['hass'], request.query)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -41,7 +41,7 @@ class LocativeView(HomeAssistantView):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""Locative message received as GET."""
|
"""Locative message received as GET."""
|
||||||
res = yield from self._handle(request.app['hass'], request.GET)
|
res = yield from self._handle(request.app['hass'], request.query)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -223,7 +223,7 @@ class HistoryPeriodView(HomeAssistantView):
|
|||||||
if start_time > now:
|
if start_time > now:
|
||||||
return self.json([])
|
return self.json([])
|
||||||
|
|
||||||
end_time = request.GET.get('end_time')
|
end_time = request.query.get('end_time')
|
||||||
if end_time:
|
if end_time:
|
||||||
end_time = dt_util.as_utc(
|
end_time = dt_util.as_utc(
|
||||||
dt_util.parse_datetime(end_time))
|
dt_util.parse_datetime(end_time))
|
||||||
@ -231,7 +231,7 @@ class HistoryPeriodView(HomeAssistantView):
|
|||||||
return self.json_message('Invalid end_time', HTTP_BAD_REQUEST)
|
return self.json_message('Invalid end_time', HTTP_BAD_REQUEST)
|
||||||
else:
|
else:
|
||||||
end_time = start_time + one_day
|
end_time = start_time + one_day
|
||||||
entity_id = request.GET.get('filter_entity_id')
|
entity_id = request.query.get('filter_entity_id')
|
||||||
|
|
||||||
result = yield from request.app['hass'].async_add_job(
|
result = yield from request.app['hass'].async_add_job(
|
||||||
get_significant_states, request.app['hass'], start_time, end_time,
|
get_significant_states, request.app['hass'], start_time, end_time,
|
||||||
|
@ -37,8 +37,8 @@ def auth_middleware(app, handler):
|
|||||||
# A valid auth header has been set
|
# A valid auth header has been set
|
||||||
authenticated = True
|
authenticated = True
|
||||||
|
|
||||||
elif (DATA_API_PASSWORD in request.GET and
|
elif (DATA_API_PASSWORD in request.query and
|
||||||
validate_password(request, request.GET[DATA_API_PASSWORD])):
|
validate_password(request, request.query[DATA_API_PASSWORD])):
|
||||||
authenticated = True
|
authenticated = True
|
||||||
|
|
||||||
elif is_trusted_ip(request):
|
elif is_trusted_ip(request):
|
||||||
|
@ -947,7 +947,7 @@ class MediaPlayerImageView(HomeAssistantView):
|
|||||||
return web.Response(status=status)
|
return web.Response(status=status)
|
||||||
|
|
||||||
authenticated = (request[KEY_AUTHENTICATED] or
|
authenticated = (request[KEY_AUTHENTICATED] or
|
||||||
request.GET.get('token') == player.access_token)
|
request.query.get('token') == player.access_token)
|
||||||
|
|
||||||
if not authenticated:
|
if not authenticated:
|
||||||
return web.Response(status=401)
|
return web.Response(status=401)
|
||||||
|
@ -110,7 +110,7 @@ class SpotifyAuthCallbackView(HomeAssistantView):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""Receive authorization token."""
|
"""Receive authorization token."""
|
||||||
hass = request.app['hass']
|
hass = request.app['hass']
|
||||||
self.oauth.get_access_token(request.GET['code'])
|
self.oauth.get_access_token(request.query['code'])
|
||||||
hass.async_add_job(setup_platform, hass, self.config, self.add_devices)
|
hass.async_add_job(setup_platform, hass, self.config, self.add_devices)
|
||||||
|
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ class HTML5PushCallbackView(HomeAssistantView):
|
|||||||
# 2a. If decode is successful, return the payload.
|
# 2a. If decode is successful, return the payload.
|
||||||
# 2b. If decode is unsuccessful, return a 401.
|
# 2b. If decode is unsuccessful, return a 401.
|
||||||
|
|
||||||
target_check = jwt.decode(token, verify=False)
|
target_check = jwt.decode(token, options={'verify_signature': False})
|
||||||
if target_check[ATTR_TARGET] in self.registrations:
|
if target_check[ATTR_TARGET] in self.registrations:
|
||||||
possible_target = self.registrations[target_check[ATTR_TARGET]]
|
possible_target = self.registrations[target_check[ATTR_TARGET]]
|
||||||
key = possible_target[ATTR_SUBSCRIPTION][ATTR_KEYS][ATTR_AUTH]
|
key = possible_target[ATTR_SUBSCRIPTION][ATTR_KEYS][ATTR_AUTH]
|
||||||
|
@ -299,7 +299,7 @@ class FitbitAuthCallbackView(HomeAssistantView):
|
|||||||
from oauthlib.oauth2.rfc6749.errors import MissingTokenError
|
from oauthlib.oauth2.rfc6749.errors import MissingTokenError
|
||||||
|
|
||||||
hass = request.app['hass']
|
hass = request.app['hass']
|
||||||
data = request.GET
|
data = request.query
|
||||||
|
|
||||||
response_message = """Fitbit has been successfully authorized!
|
response_message = """Fitbit has been successfully authorized!
|
||||||
You can close this window now!"""
|
You can close this window now!"""
|
||||||
|
@ -75,7 +75,7 @@ class TorqueReceiveDataView(HomeAssistantView):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""Handle Torque data request."""
|
"""Handle Torque data request."""
|
||||||
hass = request.app['hass']
|
hass = request.app['hass']
|
||||||
data = request.GET
|
data = request.query
|
||||||
|
|
||||||
if self.email is not None and self.email != data[SENSOR_EMAIL_FIELD]:
|
if self.email is not None and self.email != data[SENSOR_EMAIL_FIELD]:
|
||||||
return
|
return
|
||||||
|
@ -95,7 +95,7 @@ class NetioApiView(HomeAssistantView):
|
|||||||
def get(self, request, host):
|
def get(self, request, host):
|
||||||
"""Request handler."""
|
"""Request handler."""
|
||||||
hass = request.app['hass']
|
hass = request.app['hass']
|
||||||
data = request.GET
|
data = request.query
|
||||||
states, consumptions, cumulated_consumptions, start_dates = \
|
states, consumptions, cumulated_consumptions, start_dates = \
|
||||||
[], [], [], []
|
[], [], [], []
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ pydocstyle==1.1.1
|
|||||||
coveralls>=1.1
|
coveralls>=1.1
|
||||||
pytest>=2.9.2
|
pytest>=2.9.2
|
||||||
pytest-aiohttp>=0.1.3
|
pytest-aiohttp>=0.1.3
|
||||||
pytest-asyncio>=0.5.0
|
|
||||||
pytest-cov>=2.3.1
|
pytest-cov>=2.3.1
|
||||||
pytest-timeout>=1.2.0
|
pytest-timeout>=1.2.0
|
||||||
pytest-catchlog>=1.2.2
|
pytest-catchlog>=1.2.2
|
||||||
|
@ -9,7 +9,6 @@ pydocstyle==1.1.1
|
|||||||
coveralls>=1.1
|
coveralls>=1.1
|
||||||
pytest>=2.9.2
|
pytest>=2.9.2
|
||||||
pytest-aiohttp>=0.1.3
|
pytest-aiohttp>=0.1.3
|
||||||
pytest-asyncio>=0.5.0
|
|
||||||
pytest-cov>=2.3.1
|
pytest-cov>=2.3.1
|
||||||
pytest-timeout>=1.2.0
|
pytest-timeout>=1.2.0
|
||||||
pytest-catchlog>=1.2.2
|
pytest-catchlog>=1.2.2
|
||||||
|
@ -250,7 +250,7 @@ def mock_http_component_app(hass, api_password=None):
|
|||||||
"""Create an aiohttp.web.Application instance for testing."""
|
"""Create an aiohttp.web.Application instance for testing."""
|
||||||
if 'http' not in hass.config.components:
|
if 'http' not in hass.config.components:
|
||||||
mock_http_component(hass, api_password)
|
mock_http_component(hass, api_password)
|
||||||
app = web.Application(middlewares=[auth_middleware], loop=hass.loop)
|
app = web.Application(middlewares=[auth_middleware])
|
||||||
app['hass'] = hass
|
app['hass'] = hass
|
||||||
app[KEY_USE_X_FORWARDED_FOR] = False
|
app[KEY_USE_X_FORWARDED_FOR] = False
|
||||||
app[KEY_BANS_ENABLED] = False
|
app[KEY_BANS_ENABLED] = False
|
||||||
|
@ -69,7 +69,6 @@ class TestComponentsDeviceTrackerJSONMQTT(unittest.TestCase):
|
|||||||
topic = 'location/zanzito'
|
topic = 'location/zanzito'
|
||||||
location = json.dumps(LOCATION_MESSAGE)
|
location = json.dumps(LOCATION_MESSAGE)
|
||||||
|
|
||||||
self.hass.config.components = set(['mqtt_json', 'zone'])
|
|
||||||
assert setup_component(self.hass, device_tracker.DOMAIN, {
|
assert setup_component(self.hass, device_tracker.DOMAIN, {
|
||||||
device_tracker.DOMAIN: {
|
device_tracker.DOMAIN: {
|
||||||
CONF_PLATFORM: 'mqtt_json',
|
CONF_PLATFORM: 'mqtt_json',
|
||||||
@ -88,7 +87,6 @@ class TestComponentsDeviceTrackerJSONMQTT(unittest.TestCase):
|
|||||||
topic = 'location/zanzito'
|
topic = 'location/zanzito'
|
||||||
location = 'home'
|
location = 'home'
|
||||||
|
|
||||||
self.hass.config.components = set(['mqtt_json'])
|
|
||||||
assert setup_component(self.hass, device_tracker.DOMAIN, {
|
assert setup_component(self.hass, device_tracker.DOMAIN, {
|
||||||
device_tracker.DOMAIN: {
|
device_tracker.DOMAIN: {
|
||||||
CONF_PLATFORM: 'mqtt_json',
|
CONF_PLATFORM: 'mqtt_json',
|
||||||
@ -110,7 +108,6 @@ class TestComponentsDeviceTrackerJSONMQTT(unittest.TestCase):
|
|||||||
topic = 'location/zanzito'
|
topic = 'location/zanzito'
|
||||||
location = json.dumps(LOCATION_MESSAGE_INCOMPLETE)
|
location = json.dumps(LOCATION_MESSAGE_INCOMPLETE)
|
||||||
|
|
||||||
self.hass.config.components = set(['mqtt_json'])
|
|
||||||
assert setup_component(self.hass, device_tracker.DOMAIN, {
|
assert setup_component(self.hass, device_tracker.DOMAIN, {
|
||||||
device_tracker.DOMAIN: {
|
device_tracker.DOMAIN: {
|
||||||
CONF_PLATFORM: 'mqtt_json',
|
CONF_PLATFORM: 'mqtt_json',
|
||||||
|
@ -73,7 +73,7 @@ class TestYamaha(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Setup things to be run when tests are started."""
|
"""Setup things to be run when tests are started."""
|
||||||
super(TestYamaha, self).setUp()
|
super(TestYamaha, self).setUp()
|
||||||
self.rec = FakeYamaha('10.0.0.0')
|
self.rec = FakeYamaha("http://10.0.0.0:80/YamahaRemoteControl/ctrl")
|
||||||
|
|
||||||
def test_get_playback_support(self):
|
def test_get_playback_support(self):
|
||||||
"""Test the playback."""
|
"""Test the playback."""
|
||||||
|
@ -63,9 +63,9 @@ class TestCommandLine(unittest.TestCase):
|
|||||||
blocking=True)
|
blocking=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
result = open(filename).read()
|
with open(filename) as fil:
|
||||||
# the echo command adds a line break
|
# the echo command adds a line break
|
||||||
self.assertEqual(result, "{}\n".format(message))
|
self.assertEqual(fil.read(), "{}\n".format(message))
|
||||||
|
|
||||||
@patch('homeassistant.components.notify.command_line._LOGGER.error')
|
@patch('homeassistant.components.notify.command_line._LOGGER.error')
|
||||||
def test_error_for_none_zero_exit_code(self, mock_error):
|
def test_error_for_none_zero_exit_code(self, mock_error):
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
"""Test config utils."""
|
"""Test config utils."""
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
|
import asyncio
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
import unittest.mock as mock
|
import unittest.mock as mock
|
||||||
@ -546,7 +547,7 @@ def test_merge_duplicate_keys(merge_log_err):
|
|||||||
assert len(config['input_select']) == 1
|
assert len(config['input_select']) == 1
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@asyncio.coroutine
|
||||||
def test_merge_customize(hass):
|
def test_merge_customize(hass):
|
||||||
"""Test loading core config onto hass object."""
|
"""Test loading core config onto hass object."""
|
||||||
core_config = {
|
core_config = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user