diff --git a/homeassistant/components/group.py b/homeassistant/components/group.py index 5dde5d6fea8..41c3f7e269b 100644 --- a/homeassistant/components/group.py +++ b/homeassistant/components/group.py @@ -64,7 +64,7 @@ GROUP_SCHEMA = vol.Schema({ }) CONFIG_SCHEMA = vol.Schema({ - DOMAIN: cv.ordered_dict(vol.All(_conf_preprocess, GROUP_SCHEMA)) + DOMAIN: vol.Schema({cv.match_all: vol.All(_conf_preprocess, GROUP_SCHEMA)}) }, extra=vol.ALLOW_EXTRA) # List of ON/OFF state tuples for groupable states diff --git a/homeassistant/components/media_player/dunehd.py b/homeassistant/components/media_player/dunehd.py index 1facb523da6..4ff1d57c558 100644 --- a/homeassistant/components/media_player/dunehd.py +++ b/homeassistant/components/media_player/dunehd.py @@ -22,7 +22,7 @@ CONF_SOURCES = 'sources' PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_HOST): cv.string, - vol.Optional(CONF_SOURCES): cv.ordered_dict(cv.string, cv.string), + vol.Optional(CONF_SOURCES): vol.Schema({cv.string: cv.string}), vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, }) diff --git a/homeassistant/components/rss_feed_template.py b/homeassistant/components/rss_feed_template.py index e6af34a9b5e..1441a98c0a8 100644 --- a/homeassistant/components/rss_feed_template.py +++ b/homeassistant/components/rss_feed_template.py @@ -20,8 +20,8 @@ DEPENDENCIES = ['http'] DOMAIN = 'rss_feed_template' CONFIG_SCHEMA = vol.Schema({ - DOMAIN: cv.ordered_dict( - vol.Schema({ + DOMAIN: vol.Schema({ + cv.match_all: vol.Schema({ vol.Optional('requires_api_password', default=True): cv.boolean, vol.Optional('title'): cv.template, vol.Required('items'): vol.All( @@ -32,7 +32,7 @@ CONFIG_SCHEMA = vol.Schema({ }] ) }) - ) + }) }, extra=vol.ALLOW_EXTRA) diff --git a/homeassistant/components/zwave/__init__.py b/homeassistant/components/zwave/__init__.py index 0a32a664dc3..bf7eaa87e68 100755 --- a/homeassistant/components/zwave/__init__.py +++ b/homeassistant/components/zwave/__init__.py @@ -125,7 +125,7 @@ CONFIG_SCHEMA = vol.Schema({ vol.Optional(CONF_DEVICE_CONFIG, default={}): vol.Schema({cv.entity_id: DEVICE_CONFIG_SCHEMA_ENTRY}), vol.Optional(CONF_DEVICE_CONFIG_GLOB, default={}): - cv.ordered_dict(DEVICE_CONFIG_SCHEMA_ENTRY, cv.string), + vol.Schema({cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}), vol.Optional(CONF_DEVICE_CONFIG_DOMAIN, default={}): vol.Schema({cv.string: DEVICE_CONFIG_SCHEMA_ENTRY}), vol.Optional(CONF_DEBUG, default=DEFAULT_DEBUG): cv.boolean, diff --git a/homeassistant/config.py b/homeassistant/config.py index 3d1aee6c4f0..39a6d3304ac 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -112,7 +112,7 @@ CUSTOMIZE_CONFIG_SCHEMA = vol.Schema({ vol.Optional(CONF_CUSTOMIZE_DOMAIN, default={}): vol.Schema({cv.string: dict}), vol.Optional(CONF_CUSTOMIZE_GLOB, default={}): - cv.ordered_dict(OrderedDict, cv.string), + vol.Schema({cv.string: OrderedDict}), }) CORE_CONFIG_SCHEMA = CUSTOMIZE_CONFIG_SCHEMA.extend({ @@ -454,7 +454,7 @@ def _identify_config_schema(module): except (AttributeError, KeyError): return (None, None) t_schema = str(schema) - if t_schema.startswith(('{', ' Sequence: """Ensure that input is a list or make one from comma-separated string.""" if isinstance(value, str): diff --git a/tests/helpers/test_config_validation.py b/tests/helpers/test_config_validation.py index 7255447cd49..ac652e29833 100644 --- a/tests/helpers/test_config_validation.py +++ b/tests/helpers/test_config_validation.py @@ -1,5 +1,4 @@ """Test config validators.""" -from collections import OrderedDict from datetime import timedelta, datetime, date import enum import os @@ -448,63 +447,6 @@ def test_has_at_least_one_key(): schema(value) -def test_ordered_dict_only_dict(): - """Test ordered_dict validator.""" - schema = vol.Schema(cv.ordered_dict(cv.match_all, cv.match_all)) - - for value in (None, [], 100, 'hello'): - with pytest.raises(vol.MultipleInvalid): - schema(value) - - -def test_ordered_dict_order(): - """Test ordered_dict validator.""" - schema = vol.Schema(cv.ordered_dict(int, cv.string)) - - val = OrderedDict() - val['first'] = 1 - val['second'] = 2 - - validated = schema(val) - - assert isinstance(validated, OrderedDict) - assert ['first', 'second'] == list(validated.keys()) - - -def test_ordered_dict_key_validator(): - """Test ordered_dict key validator.""" - schema = vol.Schema(cv.ordered_dict(cv.match_all, cv.string)) - - with pytest.raises(vol.Invalid): - schema({None: 1}) - - schema({'hello': 'world'}) - - schema = vol.Schema(cv.ordered_dict(cv.match_all, int)) - - with pytest.raises(vol.Invalid): - schema({'hello': 1}) - - schema({1: 'works'}) - - -def test_ordered_dict_value_validator(): # pylint: disable=invalid-name - """Test ordered_dict validator.""" - schema = vol.Schema(cv.ordered_dict(cv.string)) - - with pytest.raises(vol.Invalid): - schema({'hello': None}) - - schema({'hello': 'world'}) - - schema = vol.Schema(cv.ordered_dict(int)) - - with pytest.raises(vol.Invalid): - schema({'hello': 'world'}) - - schema({'hello': 5}) - - def test_enum(): """Test enum validator.""" class TestEnum(enum.Enum):