Deprecate conf_update_interval (#20924)

* Deprecate update_interval and replace with scan_interval

* Update tests

* Fix Darksky tests

* Fix Darksky tests correctly

This reverts commit a73384a223ba8a93c682042d9351cd5a7a399183.

* Provide the default for the non deprecated option

* Don't override default schema for sensors
This commit is contained in:
Rohan Kapoor authored and Paulus Schoutsen committed 2019-02-16 23:48:37 -08:00
1 parent bc17adda8d
commit 84053103f0
15 files changed
+249 -120

No files matched your search

+2 -2
View File
@@ -24,7 +24,7 @@ def setup_freedns(hass, aioclient_mock):
hass.loop.run_until_complete(async_setup_component(hass, freedns.DOMAIN, {
freedns.DOMAIN: {
'access_token': ACCESS_TOKEN,
'update_interval': UPDATE_INTERVAL,
'scan_interval': UPDATE_INTERVAL,
}
}))
@@ -62,7 +62,7 @@ def test_setup_fails_if_wrong_token(hass, aioclient_mock):
result = yield from async_setup_component(hass, freedns.DOMAIN, {
freedns.DOMAIN: {
'access_token': ACCESS_TOKEN,
'update_interval': UPDATE_INTERVAL,
'scan_interval': UPDATE_INTERVAL,
}
})
assert not result
+9 -6
View File
@@ -21,7 +21,7 @@ VALID_CONFIG_MINIMAL = {
'api_key': 'foo',
'forecast': [1, 2],
'monitored_conditions': ['summary', 'icon', 'temperature_high'],
'update_interval': timedelta(seconds=120),
'scan_interval': timedelta(seconds=120),
}
}
@@ -31,7 +31,7 @@ INVALID_CONFIG_MINIMAL = {
'api_key': 'foo',
'forecast': [1, 2],
'monitored_conditions': ['sumary', 'iocn', 'temperature_high'],
'update_interval': timedelta(seconds=120),
'scan_interval': timedelta(seconds=120),
}
}
@@ -45,7 +45,7 @@ VALID_CONFIG_LANG_DE = {
'monitored_conditions': ['summary', 'icon', 'temperature_high',
'minutely_summary', 'hourly_summary',
'daily_summary', 'humidity', ],
'update_interval': timedelta(seconds=120),
'scan_interval': timedelta(seconds=120),
}
}
@@ -56,7 +56,7 @@ INVALID_CONFIG_LANG = {
'forecast': [1, 2],
'language': 'yz',
'monitored_conditions': ['summary', 'icon', 'temperature_high'],
'update_interval': timedelta(seconds=120),
'scan_interval': timedelta(seconds=120),
}
}
@@ -138,8 +138,11 @@ class TestDarkSkySetup(unittest.TestCase):
msg = '400 Client Error: Bad Request for url: {}'.format(url)
mock_get_forecast.side_effect = HTTPError(msg,)
response = darksky.setup_platform(self.hass, VALID_CONFIG_MINIMAL,
MagicMock())
response = darksky.setup_platform(
self.hass,
VALID_CONFIG_MINIMAL['sensor'],
MagicMock()
)
assert not response
@requests_mock.Mocker()
+17 -1
View File
@@ -713,7 +713,7 @@ def test_deprecated_with_default(caplog, schema):
def test_deprecated_with_replacement_key_and_default(caplog, schema):
"""
Test deprecation behaves correctly when only a replacement key is provided.
Test deprecation with a replacement key and default.
Expected behavior:
- Outputs the appropriate deprecation warning if key is detected
@@ -748,6 +748,22 @@ def test_deprecated_with_replacement_key_and_default(caplog, schema):
assert len(caplog.records) == 0
assert {'venus': True, 'jupiter': False} == output
deprecated_schema_with_default = vol.All(
vol.Schema({
'venus': cv.boolean,
vol.Optional('mars', default=False): cv.boolean,
vol.Optional('jupiter', default=False): cv.boolean
}),
cv.deprecated('mars', replacement_key='jupiter', default=False)
)
test_data = {'mars': True}
output = deprecated_schema_with_default(test_data.copy())
assert len(caplog.records) == 1
assert ("The 'mars' option (with value 'True') is deprecated, "
"please replace it with 'jupiter'") in caplog.text
assert {'jupiter': True} == output
def test_deprecated_with_replacement_key_invalidation_version_default(
caplog, schema, version