def test_has_at_most_one_key(): """Test has_at_most_one_key validator.""" schema = vol.Schema(cv.has_at_most_one_key("beer", "soda")) for value in (None, [], {"beer": None, "soda": None}): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ({}, {"beer": None}, {"soda": None}): schema(value)
def test_has_at_most_one_key(): """Test has_at_most_one_key validator.""" schema = vol.Schema(cv.has_at_most_one_key('beer', 'soda')) for value in (None, [], {'beer': None, 'soda': None}): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ({}, {'beer': None}, {'soda': None}): schema(value)
def test_has_at_most_one_key(): """Test has_at_most_one_key validator.""" schema = vol.Schema(cv.has_at_most_one_key('beer', 'soda')) for value in (None, [], {'beer': None, 'soda': None}): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ({}, {'beer': None}, {'soda': None}): schema(value)
# Events have a transparency that determine whether or not they block time on calendar. # When an event is opaque, it means "Show me as busy" which is the default. Events that # are not opaque are ignored by default. OPAQUE = "opaque" _EVENT_IN_TYPES = vol.Schema({ vol.Exclusive(EVENT_IN_DAYS, EVENT_TYPES_CONF): cv.positive_int, vol.Exclusive(EVENT_IN_WEEKS, EVENT_TYPES_CONF): cv.positive_int, }) SERVICE_CREATE_EVENT = "create_event" CREATE_EVENT_SCHEMA = vol.All( cv.has_at_least_one_key(EVENT_START_DATE, EVENT_START_DATETIME, EVENT_IN), cv.has_at_most_one_key(EVENT_START_DATE, EVENT_START_DATETIME, EVENT_IN), cv.make_entity_service_schema({ vol.Required(EVENT_SUMMARY): cv.string, vol.Optional(EVENT_DESCRIPTION, default=""): cv.string, vol.Inclusive(EVENT_START_DATE, "dates", "Start and end dates must both be specified"): cv.date, vol.Inclusive(EVENT_END_DATE, "dates", "Start and end dates must both be specified"): cv.date, vol.Inclusive( EVENT_START_DATETIME, "datetimes", "Start and end datetimes must both be specified", ): cv.datetime,