Updater component - rename opt_out to reporting (#3979)
* Updater component - rename opt_out to reporting * Fix tests
This commit is contained in:
parent
9f7e167669
commit
6e903fd429
2 changed files with 6 additions and 6 deletions
|
@ -27,12 +27,12 @@ DOMAIN = 'updater'
|
||||||
ENTITY_ID = 'updater.updater'
|
ENTITY_ID = 'updater.updater'
|
||||||
ATTR_RELEASE_NOTES = 'release_notes'
|
ATTR_RELEASE_NOTES = 'release_notes'
|
||||||
UPDATER_UUID_FILE = '.uuid'
|
UPDATER_UUID_FILE = '.uuid'
|
||||||
CONF_OPT_OUT = 'opt_out'
|
CONF_REPORTING = 'reporting'
|
||||||
|
|
||||||
REQUIREMENTS = ['distro==1.0.0']
|
REQUIREMENTS = ['distro==1.0.0']
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema({DOMAIN: {
|
CONFIG_SCHEMA = vol.Schema({DOMAIN: {
|
||||||
vol.Optional(CONF_OPT_OUT, default=False): cv.boolean
|
vol.Optional(CONF_REPORTING, default=True): cv.boolean
|
||||||
}}, extra=vol.ALLOW_EXTRA)
|
}}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ def setup(hass, config):
|
||||||
_LOGGER.warning('Updater not supported in development version')
|
_LOGGER.warning('Updater not supported in development version')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
huuid = None if config.get(CONF_OPT_OUT) else _load_uuid(hass)
|
huuid = _load_uuid(hass) if config.get(CONF_REPORTING) else None
|
||||||
|
|
||||||
# Update daily, start 1 hour after startup
|
# Update daily, start 1 hour after startup
|
||||||
_dt = datetime.now() + timedelta(hours=1)
|
_dt = datetime.now() + timedelta(hours=1)
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestUpdater(unittest.TestCase):
|
||||||
with assert_setup_component(1) as config:
|
with assert_setup_component(1) as config:
|
||||||
setup_component(self.hass, updater.DOMAIN, {updater.DOMAIN: {}})
|
setup_component(self.hass, updater.DOMAIN, {updater.DOMAIN: {}})
|
||||||
_dt = datetime.now() + timedelta(hours=1)
|
_dt = datetime.now() + timedelta(hours=1)
|
||||||
assert config['updater'] == {'opt_out': False}
|
assert config['updater'] == {'reporting': True}
|
||||||
|
|
||||||
for secs in [-1, 0, 1]:
|
for secs in [-1, 0, 1]:
|
||||||
fire_time_changed(self.hass, _dt + timedelta(seconds=secs))
|
fire_time_changed(self.hass, _dt + timedelta(seconds=secs))
|
||||||
|
@ -61,7 +61,7 @@ class TestUpdater(unittest.TestCase):
|
||||||
assert setup_component(
|
assert setup_component(
|
||||||
self.hass, updater.DOMAIN, {updater.DOMAIN: {}})
|
self.hass, updater.DOMAIN, {updater.DOMAIN: {}})
|
||||||
_dt = datetime.now() + timedelta(hours=1)
|
_dt = datetime.now() + timedelta(hours=1)
|
||||||
assert config['updater'] == {'opt_out': False}
|
assert config['updater'] == {'reporting': True}
|
||||||
|
|
||||||
self.assertIsNone(self.hass.states.get(updater.ENTITY_ID))
|
self.assertIsNone(self.hass.states.get(updater.ENTITY_ID))
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ class TestUpdater(unittest.TestCase):
|
||||||
with assert_setup_component(1) as config:
|
with assert_setup_component(1) as config:
|
||||||
assert not setup_component(
|
assert not setup_component(
|
||||||
self.hass, updater.DOMAIN, {updater.DOMAIN: {}})
|
self.hass, updater.DOMAIN, {updater.DOMAIN: {}})
|
||||||
assert config['updater'] == {'opt_out': False}
|
assert config['updater'] == {'reporting': True}
|
||||||
|
|
||||||
def test_uuid_function(self):
|
def test_uuid_function(self):
|
||||||
"""Test if the uuid function works."""
|
"""Test if the uuid function works."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue