diff --git a/homeassistant/components/influxdb.py b/homeassistant/components/influxdb.py index 6bac1fa7cfb..420781bcb74 100644 --- a/homeassistant/components/influxdb.py +++ b/homeassistant/components/influxdb.py @@ -33,8 +33,8 @@ TIMEOUT = 5 CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string, - vol.Required(CONF_USERNAME): cv.string, - vol.Required(CONF_PASSWORD): cv.string, + vol.Inclusive(CONF_USERNAME, 'authentication'): cv.string, + vol.Inclusive(CONF_PASSWORD, 'authentication'): cv.string, vol.Optional(CONF_BLACKLIST, default=[]): vol.All(cv.ensure_list, [cv.entity_id]), vol.Optional(CONF_DB_NAME, default=DEFAULT_DATABASE): cv.string, diff --git a/tests/components/test_influxdb.py b/tests/components/test_influxdb.py index 3210bf0db9f..3e4e6e0ad16 100644 --- a/tests/components/test_influxdb.py +++ b/tests/components/test_influxdb.py @@ -1,5 +1,4 @@ """The tests for the InfluxDB component.""" -import copy import unittest from unittest import mock @@ -53,18 +52,23 @@ class TestInfluxDB(unittest.TestCase): self.assertEqual(EVENT_STATE_CHANGED, self.hass.bus.listen.call_args_list[0][0][0]) - def test_setup_missing_keys(self, mock_client): - """Test the setup with missing keys.""" + def test_setup_minimal_config(self, mock_client): + """Tests the setup with minimal configuration.""" + config = { + 'influxdb': {} + } + + assert setup_component(self.hass, influxdb.DOMAIN, config) + + def test_setup_missing_password(self, mock_client): + """Test the setup with existing username and missing password.""" config = { 'influxdb': { - 'username': 'user', - 'password': 'pass', + 'username': 'user' } } - for missing in config['influxdb'].keys(): - config_copy = copy.deepcopy(config) - del config_copy['influxdb'][missing] - assert not setup_component(self.hass, influxdb.DOMAIN, config_copy) + + assert not setup_component(self.hass, influxdb.DOMAIN, config) def test_setup_query_fail(self, mock_client): """Test the setup for query failures."""