Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
HiveDeviceLight.is_on
(self)
Return true if light is on.
Return true if light is on.
def is_on(self): """Return true if light is on.""" return self.session.light.get_state(self.node_id)
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "session", ".", "light", ".", "get_state", "(", "self", ".", "node_id", ")" ]
[ 95, 4 ]
[ 97, 57 ]
python
en
['en', 'et', 'en']
True
HiveDeviceLight.turn_on
(self, **kwargs)
Instruct the light to turn on.
Instruct the light to turn on.
def turn_on(self, **kwargs): """Instruct the light to turn on.""" new_brightness = None new_color_temp = None new_color = None if ATTR_BRIGHTNESS in kwargs: tmp_new_brightness = kwargs.get(ATTR_BRIGHTNESS) percentage_brightness = (tmp_new_brightness / 255)...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "new_brightness", "=", "None", "new_color_temp", "=", "None", "new_color", "=", "None", "if", "ATTR_BRIGHTNESS", "in", "kwargs", ":", "tmp_new_brightness", "=", "kwargs", ".", "get", "(", "A...
[ 100, 4 ]
[ 126, 9 ]
python
en
['en', 'en', 'en']
True
HiveDeviceLight.turn_off
(self, **kwargs)
Instruct the light to turn off.
Instruct the light to turn off.
def turn_off(self, **kwargs): """Instruct the light to turn off.""" self.session.light.turn_off(self.node_id)
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "session", ".", "light", ".", "turn_off", "(", "self", ".", "node_id", ")" ]
[ 129, 4 ]
[ 131, 49 ]
python
en
['en', 'en', 'en']
True
HiveDeviceLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" supported_features = None if self.light_device_type == "warmwhitelight": supported_features = SUPPORT_BRIGHTNESS elif self.light_device_type == "tuneablelight": supported_features = SUPPORT_BRIGHTNESS | ...
[ "def", "supported_features", "(", "self", ")", ":", "supported_features", "=", "None", "if", "self", ".", "light_device_type", "==", "\"warmwhitelight\"", ":", "supported_features", "=", "SUPPORT_BRIGHTNESS", "elif", "self", ".", "light_device_type", "==", "\"tuneable...
[ 134, 4 ]
[ 144, 33 ]
python
en
['da', 'en', 'en']
True
HiveDeviceLight.update
(self)
Update all Node data from Hive.
Update all Node data from Hive.
def update(self): """Update all Node data from Hive.""" self.session.core.update_data(self.node_id) self.attributes = self.session.attributes.state_attributes(self.node_id)
[ "def", "update", "(", "self", ")", ":", "self", ".", "session", ".", "core", ".", "update_data", "(", "self", ".", "node_id", ")", "self", ".", "attributes", "=", "self", ".", "session", ".", "attributes", ".", "state_attributes", "(", "self", ".", "no...
[ 146, 4 ]
[ 149, 80 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the BH1750 sensor.
Set up the BH1750 sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the BH1750 sensor.""" name = config[CONF_NAME] bus_number = config[CONF_I2C_BUS] i2c_address = config[CONF_I2C_ADDRESS] operation_mode = config[CONF_OPERATION_MODE] bus = smbus.SMBus(bus_number) ...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", "[", "CONF_NAME", "]", "bus_number", "=", "config", "[", "CONF_I2C_BUS", "]", "i2c_address", "="...
[ 61, 0 ]
[ 93, 33 ]
python
en
['en', 'pt', 'en']
True
BH1750Sensor.__init__
(self, bh1750_sensor, name, unit, multiplier=1.0)
Initialize the sensor.
Initialize the sensor.
def __init__(self, bh1750_sensor, name, unit, multiplier=1.0): """Initialize the sensor.""" self._name = name self._unit_of_measurement = unit self._multiplier = multiplier self.bh1750_sensor = bh1750_sensor if self.bh1750_sensor.light_level >= 0: self._state ...
[ "def", "__init__", "(", "self", ",", "bh1750_sensor", ",", "name", ",", "unit", ",", "multiplier", "=", "1.0", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_unit_of_measurement", "=", "unit", "self", ".", "_multiplier", "=", "multiplier", "...
[ 99, 4 ]
[ 108, 30 ]
python
en
['en', 'en', 'en']
True
BH1750Sensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self) -> str: """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 111, 4 ]
[ 113, 25 ]
python
en
['en', 'mi', 'en']
True
BH1750Sensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self) -> int: """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_state" ]
[ 116, 4 ]
[ 118, 26 ]
python
en
['en', 'en', 'en']
True
BH1750Sensor.unit_of_measurement
(self)
Return the unit of measurement of the sensor.
Return the unit of measurement of the sensor.
def unit_of_measurement(self) -> str: """Return the unit of measurement of the sensor.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 121, 4 ]
[ 123, 40 ]
python
en
['en', 'bg', 'en']
True
BH1750Sensor.device_class
(self)
Return the class of this device, from component DEVICE_CLASSES.
Return the class of this device, from component DEVICE_CLASSES.
def device_class(self) -> str: """Return the class of this device, from component DEVICE_CLASSES.""" return DEVICE_CLASS_ILLUMINANCE
[ "def", "device_class", "(", "self", ")", "->", "str", ":", "return", "DEVICE_CLASS_ILLUMINANCE" ]
[ 126, 4 ]
[ 128, 39 ]
python
en
['en', 'en', 'en']
True
BH1750Sensor.async_update
(self)
Get the latest data from the BH1750 and update the states.
Get the latest data from the BH1750 and update the states.
async def async_update(self): """Get the latest data from the BH1750 and update the states.""" await self.hass.async_add_executor_job(self.bh1750_sensor.update) if self.bh1750_sensor.sample_ok and self.bh1750_sensor.light_level >= 0: self._state = int(round(self.bh1750_sensor.light_l...
[ "async", "def", "async_update", "(", "self", ")", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "bh1750_sensor", ".", "update", ")", "if", "self", ".", "bh1750_sensor", ".", "sample_ok", "and", "self", ".", "bh1750_senso...
[ 130, 4 ]
[ 138, 13 ]
python
en
['en', 'en', 'en']
True
async_start_discovery_service
(hass: HomeAssistantType)
Set up the pizone internal discovery.
Set up the pizone internal discovery.
async def async_start_discovery_service(hass: HomeAssistantType): """Set up the pizone internal discovery.""" disco = hass.data.get(DATA_DISCOVERY_SERVICE) if disco: # Already started return disco # discovery local services disco = DiscoveryService(hass) hass.data[DATA_DISCOVERY...
[ "async", "def", "async_start_discovery_service", "(", "hass", ":", "HomeAssistantType", ")", ":", "disco", "=", "hass", ".", "data", ".", "get", "(", "DATA_DISCOVERY_SERVICE", ")", "if", "disco", ":", "# Already started", "return", "disco", "# discovery local servic...
[ 54, 0 ]
[ 77, 16 ]
python
en
['en', 'en', 'en']
True
async_stop_discovery_service
(hass: HomeAssistantType)
Stop the discovery service.
Stop the discovery service.
async def async_stop_discovery_service(hass: HomeAssistantType): """Stop the discovery service.""" disco = hass.data.get(DATA_DISCOVERY_SERVICE) if not disco: return await disco.pi_disco.close() del hass.data[DATA_DISCOVERY_SERVICE]
[ "async", "def", "async_stop_discovery_service", "(", "hass", ":", "HomeAssistantType", ")", ":", "disco", "=", "hass", ".", "data", ".", "get", "(", "DATA_DISCOVERY_SERVICE", ")", "if", "not", "disco", ":", "return", "await", "disco", ".", "pi_disco", ".", "...
[ 80, 0 ]
[ 87, 41 ]
python
en
['en', 'en', 'en']
True
DiscoveryService.__init__
(self, hass)
Initialise discovery service.
Initialise discovery service.
def __init__(self, hass): """Initialise discovery service.""" super().__init__() self.hass = hass self.pi_disco = None
[ "def", "__init__", "(", "self", ",", "hass", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "hass", "=", "hass", "self", ".", "pi_disco", "=", "None" ]
[ 26, 4 ]
[ 30, 28 ]
python
en
['fr', 'en', 'en']
True
DiscoveryService.controller_discovered
(self, ctrl: pizone.Controller)
Handle new controller discoverery.
Handle new controller discoverery.
def controller_discovered(self, ctrl: pizone.Controller) -> None: """Handle new controller discoverery.""" async_dispatcher_send(self.hass, DISPATCH_CONTROLLER_DISCOVERED, ctrl)
[ "def", "controller_discovered", "(", "self", ",", "ctrl", ":", "pizone", ".", "Controller", ")", "->", "None", ":", "async_dispatcher_send", "(", "self", ".", "hass", ",", "DISPATCH_CONTROLLER_DISCOVERED", ",", "ctrl", ")" ]
[ 33, 4 ]
[ 35, 78 ]
python
en
['da', 'en', 'en']
True
DiscoveryService.controller_disconnected
(self, ctrl: pizone.Controller, ex: Exception)
On disconnect from controller.
On disconnect from controller.
def controller_disconnected(self, ctrl: pizone.Controller, ex: Exception) -> None: """On disconnect from controller.""" async_dispatcher_send(self.hass, DISPATCH_CONTROLLER_DISCONNECTED, ctrl, ex)
[ "def", "controller_disconnected", "(", "self", ",", "ctrl", ":", "pizone", ".", "Controller", ",", "ex", ":", "Exception", ")", "->", "None", ":", "async_dispatcher_send", "(", "self", ".", "hass", ",", "DISPATCH_CONTROLLER_DISCONNECTED", ",", "ctrl", ",", "ex...
[ 37, 4 ]
[ 39, 84 ]
python
en
['en', 'en', 'en']
True
DiscoveryService.controller_reconnected
(self, ctrl: pizone.Controller)
On reconnect to controller.
On reconnect to controller.
def controller_reconnected(self, ctrl: pizone.Controller) -> None: """On reconnect to controller.""" async_dispatcher_send(self.hass, DISPATCH_CONTROLLER_RECONNECTED, ctrl)
[ "def", "controller_reconnected", "(", "self", ",", "ctrl", ":", "pizone", ".", "Controller", ")", "->", "None", ":", "async_dispatcher_send", "(", "self", ".", "hass", ",", "DISPATCH_CONTROLLER_RECONNECTED", ",", "ctrl", ")" ]
[ 41, 4 ]
[ 43, 79 ]
python
en
['en', 'en', 'en']
True
DiscoveryService.controller_update
(self, ctrl: pizone.Controller)
System update message is received from the controller.
System update message is received from the controller.
def controller_update(self, ctrl: pizone.Controller) -> None: """System update message is received from the controller.""" async_dispatcher_send(self.hass, DISPATCH_CONTROLLER_UPDATE, ctrl)
[ "def", "controller_update", "(", "self", ",", "ctrl", ":", "pizone", ".", "Controller", ")", "->", "None", ":", "async_dispatcher_send", "(", "self", ".", "hass", ",", "DISPATCH_CONTROLLER_UPDATE", ",", "ctrl", ")" ]
[ 45, 4 ]
[ 47, 74 ]
python
en
['en', 'en', 'en']
True
DiscoveryService.zone_update
(self, ctrl: pizone.Controller, zone: pizone.Zone)
Zone update message is received from the controller.
Zone update message is received from the controller.
def zone_update(self, ctrl: pizone.Controller, zone: pizone.Zone) -> None: """Zone update message is received from the controller.""" async_dispatcher_send(self.hass, DISPATCH_ZONE_UPDATE, ctrl, zone)
[ "def", "zone_update", "(", "self", ",", "ctrl", ":", "pizone", ".", "Controller", ",", "zone", ":", "pizone", ".", "Zone", ")", "->", "None", ":", "async_dispatcher_send", "(", "self", ".", "hass", ",", "DISPATCH_ZONE_UPDATE", ",", "ctrl", ",", "zone", "...
[ 49, 4 ]
[ 51, 74 ]
python
en
['en', 'en', 'en']
True
test_boolean
()
Test boolean validation.
Test boolean validation.
def test_boolean(): """Test boolean validation.""" schema = vol.Schema(cv.boolean) for value in ( None, "T", "negative", "lock", "tr ue", [], [1, 2], {"one": "two"}, test_boolean, ): with pytest.raises(vol.MultipleInvalid)...
[ "def", "test_boolean", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "boolean", ")", "for", "value", "in", "(", "None", ",", "\"T\"", ",", "\"negative\"", ",", "\"lock\"", ",", "\"tr ue\"", ",", "[", "]", ",", "[", "1", ",", ...
[ 16, 0 ]
[ 38, 32 ]
python
en
['en', 'et', 'it']
False
test_latitude
()
Test latitude validation.
Test latitude validation.
def test_latitude(): """Test latitude validation.""" schema = vol.Schema(cv.latitude) for value in ("invalid", None, -91, 91, "-91", "91", "123.01A"): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ("-89", 89, "12.34"): schema(value)
[ "def", "test_latitude", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "latitude", ")", "for", "value", "in", "(", "\"invalid\"", ",", "None", ",", "-", "91", ",", "91", ",", "\"-91\"", ",", "\"91\"", ",", "\"123.01A\"", ")", "...
[ 41, 0 ]
[ 50, 21 ]
python
et
['et', 'et', 'en']
True
test_longitude
()
Test longitude validation.
Test longitude validation.
def test_longitude(): """Test longitude validation.""" schema = vol.Schema(cv.longitude) for value in ("invalid", None, -181, 181, "-181", "181", "123.01A"): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ("-179", 179, "12.34"): schema(value)
[ "def", "test_longitude", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "longitude", ")", "for", "value", "in", "(", "\"invalid\"", ",", "None", ",", "-", "181", ",", "181", ",", "\"-181\"", ",", "\"181\"", ",", "\"123.01A\"", ")...
[ 53, 0 ]
[ 62, 21 ]
python
et
['et', 'et', 'it']
True
test_port
()
Test TCP/UDP network port.
Test TCP/UDP network port.
def test_port(): """Test TCP/UDP network port.""" schema = vol.Schema(cv.port) for value in ("invalid", None, -1, 0, 80000, "81000"): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ("1000", 21, 24574): schema(value)
[ "def", "test_port", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "port", ")", "for", "value", "in", "(", "\"invalid\"", ",", "None", ",", "-", "1", ",", "0", ",", "80000", ",", "\"81000\"", ")", ":", "with", "pytest", ".", ...
[ 65, 0 ]
[ 74, 21 ]
python
da
['es', 'da', 'en']
False
test_isfile
()
Validate that the value is an existing file.
Validate that the value is an existing file.
def test_isfile(): """Validate that the value is an existing file.""" schema = vol.Schema(cv.isfile) fake_file = "this-file-does-not.exist" assert not os.path.isfile(fake_file) for value in ("invalid", None, -1, 0, 80000, fake_file): with pytest.raises(vol.Invalid): schema(valu...
[ "def", "test_isfile", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "isfile", ")", "fake_file", "=", "\"this-file-does-not.exist\"", "assert", "not", "os", ".", "path", ".", "isfile", "(", "fake_file", ")", "for", "value", "in", "("...
[ 77, 0 ]
[ 93, 26 ]
python
en
['en', 'en', 'en']
True
test_platform_config
()
Test platform config validation.
Test platform config validation.
def test_platform_config(): """Test platform config validation.""" options = ({}, {"hello": "world"}) for value in options: with pytest.raises(vol.MultipleInvalid): cv.PLATFORM_SCHEMA(value) options = ({"platform": "mqtt"}, {"platform": "mqtt", "beer": "yes"}) for value in optio...
[ "def", "test_platform_config", "(", ")", ":", "options", "=", "(", "{", "}", ",", "{", "\"hello\"", ":", "\"world\"", "}", ")", "for", "value", "in", "options", ":", "with", "pytest", ".", "raises", "(", "vol", ".", "MultipleInvalid", ")", ":", "cv", ...
[ 122, 0 ]
[ 131, 38 ]
python
da
['nl', 'da', 'en']
False
test_ensure_list
()
Test ensure_list.
Test ensure_list.
def test_ensure_list(): """Test ensure_list.""" schema = vol.Schema(cv.ensure_list) assert [] == schema(None) assert [1] == schema(1) assert [1] == schema([1]) assert ["1"] == schema("1") assert ["1"] == schema(["1"]) assert [{"1": "2"}] == schema({"1": "2"})
[ "def", "test_ensure_list", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "ensure_list", ")", "assert", "[", "]", "==", "schema", "(", "None", ")", "assert", "[", "1", "]", "==", "schema", "(", "1", ")", "assert", "[", "1", "...
[ 134, 0 ]
[ 142, 45 ]
python
en
['fr', 'et', 'en']
False
test_entity_id
()
Test entity ID validation.
Test entity ID validation.
def test_entity_id(): """Test entity ID validation.""" schema = vol.Schema(cv.entity_id) with pytest.raises(vol.MultipleInvalid): schema("invalid_entity") assert schema("sensor.LIGHT") == "sensor.light"
[ "def", "test_entity_id", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "entity_id", ")", "with", "pytest", ".", "raises", "(", "vol", ".", "MultipleInvalid", ")", ":", "schema", "(", "\"invalid_entity\"", ")", "assert", "schema", "(...
[ 145, 0 ]
[ 152, 51 ]
python
en
['en', 'et', 'en']
True
test_entity_ids
()
Test entity ID validation.
Test entity ID validation.
def test_entity_ids(): """Test entity ID validation.""" schema = vol.Schema(cv.entity_ids) options = ( "invalid_entity", "sensor.light,sensor_invalid", ["invalid_entity"], ["sensor.light", "sensor_invalid"], ["sensor.light,sensor_invalid"], ) for value in opt...
[ "def", "test_entity_ids", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "entity_ids", ")", "options", "=", "(", "\"invalid_entity\"", ",", "\"sensor.light,sensor_invalid\"", ",", "[", "\"invalid_entity\"", "]", ",", "[", "\"sensor.light\"",...
[ 155, 0 ]
[ 174, 86 ]
python
en
['en', 'et', 'en']
True
test_entity_domain
()
Test entity domain validation.
Test entity domain validation.
def test_entity_domain(): """Test entity domain validation.""" schema = vol.Schema(cv.entity_domain("sensor")) for value in ( "invalid_entity", "cover.demo", "cover.demo,sensor.another_entity", "", ): with pytest.raises(vol.MultipleInvalid): schema(va...
[ "def", "test_entity_domain", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "entity_domain", "(", "\"sensor\"", ")", ")", "for", "value", "in", "(", "\"invalid_entity\"", ",", "\"cover.demo\"", ",", "\"cover.demo,sensor.another_entity\"", ",...
[ 177, 0 ]
[ 199, 65 ]
python
en
['en', 'zu', 'en']
True
test_entities_domain
()
Test entities domain validation.
Test entities domain validation.
def test_entities_domain(): """Test entities domain validation.""" schema = vol.Schema(cv.entities_domain("sensor")) options = ( None, "", "invalid_entity", ["sensor.light", "cover.demo"], ["sensor.light", "sensor_invalid"], ) for value in options: w...
[ "def", "test_entities_domain", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "entities_domain", "(", "\"sensor\"", ")", ")", "options", "=", "(", "None", ",", "\"\"", ",", "\"invalid_entity\"", ",", "[", "\"sensor.light\"", ",", "\"co...
[ 202, 0 ]
[ 223, 85 ]
python
en
['fr', 'en', 'en']
True
test_ensure_list_csv
()
Test ensure_list_csv.
Test ensure_list_csv.
def test_ensure_list_csv(): """Test ensure_list_csv.""" schema = vol.Schema(cv.ensure_list_csv) options = (None, 12, [], ["string"], "string1,string2") for value in options: schema(value) assert schema("string1, string2 ") == ["string1", "string2"]
[ "def", "test_ensure_list_csv", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "ensure_list_csv", ")", "options", "=", "(", "None", ",", "12", ",", "[", "]", ",", "[", "\"string\"", "]", ",", "\"string1,string2\"", ")", "for", "valu...
[ 226, 0 ]
[ 234, 64 ]
python
be
['fr', 'be', 'en']
False
test_event_schema
()
Test event_schema validation.
Test event_schema validation.
def test_event_schema(): """Test event_schema validation.""" options = ( {}, None, {"event_data": {}}, {"event": "state_changed", "event_data": 1}, ) for value in options: with pytest.raises(vol.MultipleInvalid): cv.EVENT_SCHEMA(value) options = (...
[ "def", "test_event_schema", "(", ")", ":", "options", "=", "(", "{", "}", ",", "None", ",", "{", "\"event_data\"", ":", "{", "}", "}", ",", "{", "\"event\"", ":", "\"state_changed\"", ",", "\"event_data\"", ":", "1", "}", ",", ")", "for", "value", "i...
[ 237, 0 ]
[ 254, 30 ]
python
de
['de', 'de', 'it']
True
test_icon
()
Test icon validation.
Test icon validation.
def test_icon(): """Test icon validation.""" schema = vol.Schema(cv.icon) for value in (False, "work"): with pytest.raises(vol.MultipleInvalid): schema(value) schema("mdi:work") schema("custom:prefix")
[ "def", "test_icon", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "icon", ")", "for", "value", "in", "(", "False", ",", "\"work\"", ")", ":", "with", "pytest", ".", "raises", "(", "vol", ".", "MultipleInvalid", ")", ":", "sche...
[ 257, 0 ]
[ 266, 27 ]
python
en
['es', 'ja', 'en']
False
test_time_period
()
Test time_period validation.
Test time_period validation.
def test_time_period(): """Test time_period validation.""" schema = vol.Schema(cv.time_period) options = ( None, "", "hello:world", "12:", "12:34:56:78", {}, {"wrong_key": -10}, "12.5:30", "12:30.5", "12.5:30:30", "12:3...
[ "def", "test_time_period", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "time_period", ")", "options", "=", "(", "None", ",", "\"\"", ",", "\"hello:world\"", ",", "\"12:\"", ",", "\"12:34:56:78\"", ",", "{", "}", ",", "{", "\"wro...
[ 269, 0 ]
[ 315, 38 ]
python
en
['da', 'en', 'en']
True
test_remove_falsy
()
Test remove falsy.
Test remove falsy.
def test_remove_falsy(): """Test remove falsy.""" assert cv.remove_falsy([0, None, 1, "1", {}, [], ""]) == [1, "1"]
[ "def", "test_remove_falsy", "(", ")", ":", "assert", "cv", ".", "remove_falsy", "(", "[", "0", ",", "None", ",", "1", ",", "\"1\"", ",", "{", "}", ",", "[", "]", ",", "\"\"", "]", ")", "==", "[", "1", ",", "\"1\"", "]" ]
[ 318, 0 ]
[ 320, 69 ]
python
en
['en', 'en', 'en']
True
test_service
()
Test service validation.
Test service validation.
def test_service(): """Test service validation.""" schema = vol.Schema(cv.service) with pytest.raises(vol.MultipleInvalid): schema("invalid_turn_on") schema("homeassistant.turn_on")
[ "def", "test_service", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "service", ")", "with", "pytest", ".", "raises", "(", "vol", ".", "MultipleInvalid", ")", ":", "schema", "(", "\"invalid_turn_on\"", ")", "schema", "(", "\"homeass...
[ 323, 0 ]
[ 330, 35 ]
python
en
['en', 'ky', 'en']
True
test_service_schema
()
Test service_schema validation.
Test service_schema validation.
def test_service_schema(): """Test service_schema validation.""" options = ( {}, None, { "service": "homeassistant.turn_on", "service_template": "homeassistant.turn_on", }, {"data": {"entity_id": "light.kitchen"}}, {"service": "homeassistan...
[ "def", "test_service_schema", "(", ")", ":", "options", "=", "(", "{", "}", ",", "None", ",", "{", "\"service\"", ":", "\"homeassistant.turn_on\"", ",", "\"service_template\"", ":", "\"homeassistant.turn_on\"", ",", "}", ",", "{", "\"data\"", ":", "{", "\"enti...
[ 333, 0 ]
[ 363, 32 ]
python
de
['de', 'de', 'en']
True
test_slug
()
Test slug validation.
Test slug validation.
def test_slug(): """Test slug validation.""" schema = vol.Schema(cv.slug) for value in (None, "hello world"): with pytest.raises(vol.MultipleInvalid): schema(value) for value in (12345, "hello"): schema(value)
[ "def", "test_slug", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "slug", ")", "for", "value", "in", "(", "None", ",", "\"hello world\"", ")", ":", "with", "pytest", ".", "raises", "(", "vol", ".", "MultipleInvalid", ")", ":", ...
[ 366, 0 ]
[ 375, 21 ]
python
et
['nl', 'et', 'it']
False
test_string
(hass)
Test string validation.
Test string validation.
def test_string(hass): """Test string validation.""" schema = vol.Schema(cv.string) with pytest.raises(vol.Invalid): schema(None) with pytest.raises(vol.Invalid): schema([]) with pytest.raises(vol.Invalid): schema({}) for value in (True, 1, "hello"): schema(va...
[ "def", "test_string", "(", "hass", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "string", ")", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "schema", "(", "None", ")", "with", "pytest", ".", "raises", "("...
[ 378, 0 ]
[ 405, 37 ]
python
en
['nl', 'sv', 'en']
False
test_string_with_no_html
()
Test string with no html validation.
Test string with no html validation.
def test_string_with_no_html(): """Test string with no html validation.""" schema = vol.Schema(cv.string_with_no_html) with pytest.raises(vol.Invalid): schema("This has HTML in it <a>Link</a>") with pytest.raises(vol.Invalid): schema("<b>Bold</b>") for value in ( True, ...
[ "def", "test_string_with_no_html", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "string_with_no_html", ")", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "schema", "(", "\"This has HTML in it <a>Link</a>\"", ")",...
[ 408, 0 ]
[ 425, 21 ]
python
en
['en', 'en', 'en']
True
test_temperature_unit
()
Test temperature unit validation.
Test temperature unit validation.
def test_temperature_unit(): """Test temperature unit validation.""" schema = vol.Schema(cv.temperature_unit) with pytest.raises(vol.MultipleInvalid): schema("K") schema("C") schema("F")
[ "def", "test_temperature_unit", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "temperature_unit", ")", "with", "pytest", ".", "raises", "(", "vol", ".", "MultipleInvalid", ")", ":", "schema", "(", "\"K\"", ")", "schema", "(", "\"C\"...
[ 428, 0 ]
[ 436, 15 ]
python
en
['nl', 'la', 'en']
False
test_x10_address
()
Test x10 addr validator.
Test x10 addr validator.
def test_x10_address(): """Test x10 addr validator.""" schema = vol.Schema(cv.x10_address) with pytest.raises(vol.Invalid): schema("Q1") schema("q55") schema("garbage_addr") schema("a1") schema("C11")
[ "def", "test_x10_address", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "x10_address", ")", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "schema", "(", "\"Q1\"", ")", "schema", "(", "\"q55\"", ")", "sc...
[ 439, 0 ]
[ 448, 17 ]
python
ar
['en', 'ar', 'hi']
False
test_template
()
Test template validator.
Test template validator.
def test_template(): """Test template validator.""" schema = vol.Schema(cv.template) for value in (None, "{{ partial_print }", "{% if True %}Hello", ["test"]): with pytest.raises(vol.Invalid): schema(value) options = ( 1, "Hello", "{{ beer }}", "{% i...
[ "def", "test_template", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "template", ")", "for", "value", "in", "(", "None", ",", "\"{{ partial_print }\"", ",", "\"{% if True %}Hello\"", ",", "[", "\"test\"", "]", ")", ":", "with", "py...
[ 451, 0 ]
[ 466, 21 ]
python
en
['en', 'et', 'en']
True
test_dynamic_template
()
Test dynamic template validator.
Test dynamic template validator.
def test_dynamic_template(): """Test dynamic template validator.""" schema = vol.Schema(cv.dynamic_template) for value in ( None, 1, "{{ partial_print }", "{% if True %}Hello", ["test"], "just a string", ): with pytest.raises(vol.Invalid): ...
[ "def", "test_dynamic_template", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "dynamic_template", ")", "for", "value", "in", "(", "None", ",", "1", ",", "\"{{ partial_print }\"", ",", "\"{% if True %}Hello\"", ",", "[", "\"test\"", "]",...
[ 469, 0 ]
[ 489, 21 ]
python
en
['en', 'en', 'en']
True
test_template_complex
()
Test template_complex validator.
Test template_complex validator.
def test_template_complex(): """Test template_complex validator.""" schema = vol.Schema(cv.template_complex) for value in ("{{ partial_print }", "{% if True %}Hello"): with pytest.raises(vol.MultipleInvalid): schema(value) options = ( 1, "Hello", "{{ beer }}...
[ "def", "test_template_complex", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "template_complex", ")", "for", "value", "in", "(", "\"{{ partial_print }\"", ",", "\"{% if True %}Hello\"", ")", ":", "with", "pytest", ".", "raises", "(", "...
[ 492, 0 ]
[ 523, 37 ]
python
en
['en', 'et', 'en']
True
test_time_zone
()
Test time zone validation.
Test time zone validation.
def test_time_zone(): """Test time zone validation.""" schema = vol.Schema(cv.time_zone) with pytest.raises(vol.MultipleInvalid): schema("America/Do_Not_Exist") schema("America/Los_Angeles") schema("UTC")
[ "def", "test_time_zone", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "time_zone", ")", "with", "pytest", ".", "raises", "(", "vol", ".", "MultipleInvalid", ")", ":", "schema", "(", "\"America/Do_Not_Exist\"", ")", "schema", "(", "...
[ 526, 0 ]
[ 534, 17 ]
python
en
['nl', 'en', 'en']
True
test_date
()
Test date validation.
Test date validation.
def test_date(): """Test date validation.""" schema = vol.Schema(cv.date) for value in ["Not a date", "23:42", "2016-11-23T18:59:08"]: with pytest.raises(vol.Invalid): schema(value) schema(datetime.now().date()) schema("2016-11-23")
[ "def", "test_date", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "date", ")", "for", "value", "in", "[", "\"Not a date\"", ",", "\"23:42\"", ",", "\"2016-11-23T18:59:08\"", "]", ":", "with", "pytest", ".", "raises", "(", "vol", "...
[ 537, 0 ]
[ 546, 24 ]
python
de
['fr', 'de', 'en']
False
test_time
()
Test date validation.
Test date validation.
def test_time(): """Test date validation.""" schema = vol.Schema(cv.time) for value in ["Not a time", "2016-11-23", "2016-11-23T18:59:08"]: with pytest.raises(vol.Invalid): schema(value) schema(datetime.now().time()) schema("23:42:00") schema("23:42")
[ "def", "test_time", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "time", ")", "for", "value", "in", "[", "\"Not a time\"", ",", "\"2016-11-23\"", ",", "\"2016-11-23T18:59:08\"", "]", ":", "with", "pytest", ".", "raises", "(", "vol"...
[ 549, 0 ]
[ 559, 19 ]
python
de
['fr', 'de', 'en']
False
test_datetime
()
Test date time validation.
Test date time validation.
def test_datetime(): """Test date time validation.""" schema = vol.Schema(cv.datetime) for value in [date.today(), "Wrong DateTime"]: with pytest.raises(vol.MultipleInvalid): schema(value) schema(datetime.now()) schema("2016-11-23T18:59:08")
[ "def", "test_datetime", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "datetime", ")", "for", "value", "in", "[", "date", ".", "today", "(", ")", ",", "\"Wrong DateTime\"", "]", ":", "with", "pytest", ".", "raises", "(", "vol", ...
[ 562, 0 ]
[ 570, 33 ]
python
en
['fr', 'en', 'en']
True
test_multi_select
()
Test multi select validation. Expected behavior: - Will not accept any input but a list - Will not accept selections outside of configured scope
Test multi select validation.
def test_multi_select(): """Test multi select validation. Expected behavior: - Will not accept any input but a list - Will not accept selections outside of configured scope """ schema = vol.Schema(cv.multi_select({"paulus": "Paulus", "robban": "Robban"})) with pytest.raises(vol.Inv...
[ "def", "test_multi_select", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "multi_select", "(", "{", "\"paulus\"", ":", "\"Paulus\"", ",", "\"robban\"", ":", "\"Robban\"", "}", ")", ")", "with", "pytest", ".", "raises", "(", "vol", ...
[ 573, 0 ]
[ 586, 32 ]
python
en
['nl', 'et', 'en']
False
test_multi_select_in_serializer
()
Test multi_select with custom_serializer.
Test multi_select with custom_serializer.
def test_multi_select_in_serializer(): """Test multi_select with custom_serializer.""" assert cv.custom_serializer(cv.multi_select({"paulus": "Paulus"})) == { "type": "multi_select", "options": {"paulus": "Paulus"}, }
[ "def", "test_multi_select_in_serializer", "(", ")", ":", "assert", "cv", ".", "custom_serializer", "(", "cv", ".", "multi_select", "(", "{", "\"paulus\"", ":", "\"Paulus\"", "}", ")", ")", "==", "{", "\"type\"", ":", "\"multi_select\"", ",", "\"options\"", ":"...
[ 589, 0 ]
[ 594, 5 ]
python
en
['en', 'en', 'en']
True
test_boolean_in_serializer
()
Test boolean with custom_serializer.
Test boolean with custom_serializer.
def test_boolean_in_serializer(): """Test boolean with custom_serializer.""" assert cv.custom_serializer(cv.boolean) == { "type": "boolean", }
[ "def", "test_boolean_in_serializer", "(", ")", ":", "assert", "cv", ".", "custom_serializer", "(", "cv", ".", "boolean", ")", "==", "{", "\"type\"", ":", "\"boolean\"", ",", "}" ]
[ 597, 0 ]
[ 601, 5 ]
python
en
['en', 'en', 'en']
True
test_string_in_serializer
()
Test string with custom_serializer.
Test string with custom_serializer.
def test_string_in_serializer(): """Test string with custom_serializer.""" assert cv.custom_serializer(cv.string) == { "type": "string", }
[ "def", "test_string_in_serializer", "(", ")", ":", "assert", "cv", ".", "custom_serializer", "(", "cv", ".", "string", ")", "==", "{", "\"type\"", ":", "\"string\"", ",", "}" ]
[ 604, 0 ]
[ 608, 5 ]
python
en
['en', 'en', 'en']
True
test_positive_time_period_dict_in_serializer
()
Test positive_time_period_dict with custom_serializer.
Test positive_time_period_dict with custom_serializer.
def test_positive_time_period_dict_in_serializer(): """Test positive_time_period_dict with custom_serializer.""" assert cv.custom_serializer(cv.positive_time_period_dict) == { "type": "positive_time_period_dict", }
[ "def", "test_positive_time_period_dict_in_serializer", "(", ")", ":", "assert", "cv", ".", "custom_serializer", "(", "cv", ".", "positive_time_period_dict", ")", "==", "{", "\"type\"", ":", "\"positive_time_period_dict\"", ",", "}" ]
[ 611, 0 ]
[ 615, 5 ]
python
en
['en', 'en', 'en']
True
schema
()
Create a schema used for testing deprecation.
Create a schema used for testing deprecation.
def schema(): """Create a schema used for testing deprecation.""" return vol.Schema({"venus": cv.boolean, "mars": cv.boolean, "jupiter": cv.boolean})
[ "def", "schema", "(", ")", ":", "return", "vol", ".", "Schema", "(", "{", "\"venus\"", ":", "cv", ".", "boolean", ",", "\"mars\"", ":", "cv", ".", "boolean", ",", "\"jupiter\"", ":", "cv", ".", "boolean", "}", ")" ]
[ 619, 0 ]
[ 621, 87 ]
python
en
['en', 'en', 'en']
True
version
(monkeypatch)
Patch the version used for testing to 0.5.0.
Patch the version used for testing to 0.5.0.
def version(monkeypatch): """Patch the version used for testing to 0.5.0.""" monkeypatch.setattr(homeassistant.const, "__version__", "0.5.0")
[ "def", "version", "(", "monkeypatch", ")", ":", "monkeypatch", ".", "setattr", "(", "homeassistant", ".", "const", ",", "\"__version__\"", ",", "\"0.5.0\"", ")" ]
[ 625, 0 ]
[ 627, 68 ]
python
en
['en', 'en', 'en']
True
test_deprecated_with_no_optionals
(caplog, schema)
Test deprecation behaves correctly when optional params are None. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema without changing any values - No warning or difference in output if key is not provided
Test deprecation behaves correctly when optional params are None.
def test_deprecated_with_no_optionals(caplog, schema): """ Test deprecation behaves correctly when optional params are None. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema without changing any values - No warning or difference ...
[ "def", "test_deprecated_with_no_optionals", "(", "caplog", ",", "schema", ")", ":", "deprecated_schema", "=", "vol", ".", "All", "(", "cv", ".", "deprecated", "(", "\"mars\"", ")", ",", "schema", ")", "test_data", "=", "{", "\"mars\"", ":", "True", "}", "o...
[ 630, 0 ]
[ 659, 30 ]
python
en
['en', 'error', 'th']
False
test_deprecated_with_replacement_key
(caplog, schema)
Test deprecation behaves correctly when only a replacement key is provided. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema moving the value from key to replacement_key - Processes schema changing nothing if only replacement_key pr...
Test deprecation behaves correctly when only a replacement key is provided.
def test_deprecated_with_replacement_key(caplog, schema): """ Test deprecation behaves correctly when only a replacement key is provided. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema moving the value from key to replacement_key ...
[ "def", "test_deprecated_with_replacement_key", "(", "caplog", ",", "schema", ")", ":", "deprecated_schema", "=", "vol", ".", "All", "(", "cv", ".", "deprecated", "(", "\"mars\"", ",", "replacement_key", "=", "\"jupiter\"", ")", ",", "schema", ")", "test_data", ...
[ 662, 0 ]
[ 697, 30 ]
python
en
['en', 'error', 'th']
False
test_deprecated_with_invalidation_version
(caplog, schema, version)
Test deprecation behaves correctly with only an invalidation_version. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema without changing any values - No warning or difference in output if key is not provided - Once the invali...
Test deprecation behaves correctly with only an invalidation_version.
def test_deprecated_with_invalidation_version(caplog, schema, version): """ Test deprecation behaves correctly with only an invalidation_version. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema without changing any values - No w...
[ "def", "test_deprecated_with_invalidation_version", "(", "caplog", ",", "schema", ",", "version", ")", ":", "deprecated_schema", "=", "vol", ".", "All", "(", "cv", ".", "deprecated", "(", "\"mars\"", ",", "invalidation_version", "=", "\"1.0.0\"", ")", ",", "sche...
[ 700, 0 ]
[ 745, 5 ]
python
en
['en', 'error', 'th']
False
test_deprecated_with_replacement_key_and_invalidation_version
( caplog, schema, version )
Test deprecation behaves with a replacement key & invalidation_version. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema moving the value from key to replacement_key - Processes schema changing nothing if only replacement_key provid...
Test deprecation behaves with a replacement key & invalidation_version.
def test_deprecated_with_replacement_key_and_invalidation_version( caplog, schema, version ): """ Test deprecation behaves with a replacement key & invalidation_version. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema moving the val...
[ "def", "test_deprecated_with_replacement_key_and_invalidation_version", "(", "caplog", ",", "schema", ",", "version", ")", ":", "deprecated_schema", "=", "vol", ".", "All", "(", "cv", ".", "deprecated", "(", "\"mars\"", ",", "replacement_key", "=", "\"jupiter\"", ",...
[ 748, 0 ]
[ 805, 5 ]
python
en
['en', 'error', 'th']
False
test_deprecated_with_default
(caplog, schema)
Test deprecation behaves correctly with a default value. This is likely a scenario that would never occur. Expected behavior: - Behaves identically as when the default value was not present
Test deprecation behaves correctly with a default value.
def test_deprecated_with_default(caplog, schema): """ Test deprecation behaves correctly with a default value. This is likely a scenario that would never occur. Expected behavior: - Behaves identically as when the default value was not present """ deprecated_schema = vol.All(cv.depreca...
[ "def", "test_deprecated_with_default", "(", "caplog", ",", "schema", ")", ":", "deprecated_schema", "=", "vol", ".", "All", "(", "cv", ".", "deprecated", "(", "\"mars\"", ",", "default", "=", "False", ")", ",", "schema", ")", "test_data", "=", "{", "\"mars...
[ 808, 0 ]
[ 834, 30 ]
python
en
['en', 'error', 'th']
False
test_deprecated_with_replacement_key_and_default
(caplog, schema)
Test deprecation with a replacement key and default. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema moving the value from key to replacement_key - Processes schema changing nothing if only replacement_key provided - No war...
Test deprecation with a replacement key and default.
def test_deprecated_with_replacement_key_and_default(caplog, schema): """ Test deprecation with a replacement key and default. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema moving the value from key to replacement_key - Proces...
[ "def", "test_deprecated_with_replacement_key_and_default", "(", "caplog", ",", "schema", ")", ":", "deprecated_schema", "=", "vol", ".", "All", "(", "cv", ".", "deprecated", "(", "\"mars\"", ",", "replacement_key", "=", "\"jupiter\"", ",", "default", "=", "False",...
[ 837, 0 ]
[ 891, 38 ]
python
en
['en', 'error', 'th']
False
test_deprecated_with_replacement_key_invalidation_version_default
( caplog, schema, version )
Test deprecation with a replacement key, invalidation_version & default. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema moving the value from key to replacement_key - Processes schema changing nothing if only replacement_key provi...
Test deprecation with a replacement key, invalidation_version & default.
def test_deprecated_with_replacement_key_invalidation_version_default( caplog, schema, version ): """ Test deprecation with a replacement key, invalidation_version & default. Expected behavior: - Outputs the appropriate deprecation warning if key is detected - Processes schema moving th...
[ "def", "test_deprecated_with_replacement_key_invalidation_version_default", "(", "caplog", ",", "schema", ",", "version", ")", ":", "deprecated_schema", "=", "vol", ".", "All", "(", "cv", ".", "deprecated", "(", "\"mars\"", ",", "replacement_key", "=", "\"jupiter\"", ...
[ 894, 0 ]
[ 954, 5 ]
python
en
['en', 'error', 'th']
False
test_deprecated_cant_find_module
()
Test if the current module cannot be inspected.
Test if the current module cannot be inspected.
def test_deprecated_cant_find_module(): """Test if the current module cannot be inspected.""" with patch("inspect.getmodule", return_value=None): # This used to raise. cv.deprecated( "mars", replacement_key="jupiter", invalidation_version="1.0.0", ...
[ "def", "test_deprecated_cant_find_module", "(", ")", ":", "with", "patch", "(", "\"inspect.getmodule\"", ",", "return_value", "=", "None", ")", ":", "# This used to raise.", "cv", ".", "deprecated", "(", "\"mars\"", ",", "replacement_key", "=", "\"jupiter\"", ",", ...
[ 957, 0 ]
[ 966, 9 ]
python
en
['en', 'en', 'en']
True
test_key_dependency
()
Test key_dependency validator.
Test key_dependency validator.
def test_key_dependency(): """Test key_dependency validator.""" schema = vol.Schema(cv.key_dependency("beer", "soda")) options = {"beer": None} for value in options: with pytest.raises(vol.MultipleInvalid): schema(value) options = ({"beer": None, "soda": None}, {"soda": None}, ...
[ "def", "test_key_dependency", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "key_dependency", "(", "\"beer\"", ",", "\"soda\"", ")", ")", "options", "=", "{", "\"beer\"", ":", "None", "}", "for", "value", "in", "options", ":", "wi...
[ 969, 0 ]
[ 980, 21 ]
python
af
['hu', 'af', 'en']
False
test_has_at_most_one_key
()
Test has_at_most_one_key validator.
Test has_at_most_one_key validator.
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}, {"so...
[ "def", "test_has_at_most_one_key", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "has_at_most_one_key", "(", "\"beer\"", ",", "\"soda\"", ")", ")", "for", "value", "in", "(", "None", ",", "[", "]", ",", "{", "\"beer\"", ":", "None...
[ 983, 0 ]
[ 992, 21 ]
python
en
['en', 'en', 'it']
True
test_has_at_least_one_key
()
Test has_at_least_one_key validator.
Test has_at_least_one_key validator.
def test_has_at_least_one_key(): """Test has_at_least_one_key validator.""" schema = vol.Schema(cv.has_at_least_one_key("beer", "soda")) for value in (None, [], {}, {"wine": None}): with pytest.raises(vol.MultipleInvalid): schema(value) for value in ({"beer": None}, {"soda": None})...
[ "def", "test_has_at_least_one_key", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "has_at_least_one_key", "(", "\"beer\"", ",", "\"soda\"", ")", ")", "for", "value", "in", "(", "None", ",", "[", "]", ",", "{", "}", ",", "{", "\"...
[ 995, 0 ]
[ 1004, 21 ]
python
en
['en', 'et', 'it']
False
test_enum
()
Test enum validator.
Test enum validator.
def test_enum(): """Test enum validator.""" class TestEnum(enum.Enum): """Test enum.""" value1 = "Value 1" value2 = "Value 2" schema = vol.Schema(cv.enum(TestEnum)) with pytest.raises(vol.Invalid): schema("value3")
[ "def", "test_enum", "(", ")", ":", "class", "TestEnum", "(", "enum", ".", "Enum", ")", ":", "\"\"\"Test enum.\"\"\"", "value1", "=", "\"Value 1\"", "value2", "=", "\"Value 2\"", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "enum", "(", "TestEnum", ...
[ 1007, 0 ]
[ 1019, 24 ]
python
de
['de', 'et', 'it']
False
test_socket_timeout
()
Test socket timeout validator.
Test socket timeout validator.
def test_socket_timeout(): # pylint: disable=invalid-name """Test socket timeout validator.""" schema = vol.Schema(cv.socket_timeout) with pytest.raises(vol.Invalid): schema(0.0) with pytest.raises(vol.Invalid): schema(-1) assert _GLOBAL_DEFAULT_TIMEOUT == schema(None) asser...
[ "def", "test_socket_timeout", "(", ")", ":", "# pylint: disable=invalid-name", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "socket_timeout", ")", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "schema", "(", "0.0", ")", "wi...
[ 1022, 0 ]
[ 1034, 27 ]
python
en
['en', 'et', 'en']
True
test_matches_regex
()
Test matches_regex validator.
Test matches_regex validator.
def test_matches_regex(): """Test matches_regex validator.""" schema = vol.Schema(cv.matches_regex(".*uiae.*")) with pytest.raises(vol.Invalid): schema(1.0) with pytest.raises(vol.Invalid): schema(" nrtd ") test_str = "This is a test including uiae." assert schema(test_str)...
[ "def", "test_matches_regex", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "matches_regex", "(", "\".*uiae.*\"", ")", ")", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "schema", "(", "1.0", ")", "with", ...
[ 1037, 0 ]
[ 1048, 39 ]
python
de
['nl', 'de', 'it']
False
test_is_regex
()
Test the is_regex validator.
Test the is_regex validator.
def test_is_regex(): """Test the is_regex validator.""" schema = vol.Schema(cv.is_regex) with pytest.raises(vol.Invalid): schema("(") with pytest.raises(vol.Invalid): schema({"a dict": "is not a regex"}) valid_re = ".*" schema(valid_re)
[ "def", "test_is_regex", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "is_regex", ")", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "schema", "(", "\"(\"", ")", "with", "pytest", ".", "raises", "(", "...
[ 1051, 0 ]
[ 1062, 20 ]
python
en
['en', 'et', 'en']
True
test_comp_entity_ids
()
Test config validation for component entity IDs.
Test config validation for component entity IDs.
def test_comp_entity_ids(): """Test config validation for component entity IDs.""" schema = vol.Schema(cv.comp_entity_ids) for valid in ( "ALL", "all", "AlL", "light.kitchen", ["light.kitchen"], ["light.kitchen", "light.ceiling"], [], ): s...
[ "def", "test_comp_entity_ids", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "comp_entity_ids", ")", "for", "valid", "in", "(", "\"ALL\"", ",", "\"all\"", ",", "\"AlL\"", ",", "\"light.kitchen\"", ",", "[", "\"light.kitchen\"", "]", "...
[ 1065, 0 ]
[ 1082, 27 ]
python
en
['nb', 'en', 'en']
True
test_uuid4_hex
(caplog)
Test uuid validation.
Test uuid validation.
def test_uuid4_hex(caplog): """Test uuid validation.""" schema = vol.Schema(cv.uuid4_hex) for value in ["Not a hex string", "0", 0]: with pytest.raises(vol.Invalid): schema(value) with pytest.raises(vol.Invalid): # the 13th char should be 4 schema("a03d31b22eee1acc9...
[ "def", "test_uuid4_hex", "(", "caplog", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "uuid4_hex", ")", "for", "value", "in", "[", "\"Not a hex string\"", ",", "\"0\"", ",", "0", "]", ":", "with", "pytest", ".", "raises", "(", "vol", ...
[ 1085, 0 ]
[ 1103, 39 ]
python
et
['fi', 'et', 'ur']
False
test_key_value_schemas
()
Test key value schemas.
Test key value schemas.
def test_key_value_schemas(): """Test key value schemas.""" schema = vol.Schema( cv.key_value_schemas( "mode", { "number": vol.Schema({"mode": "number", "data": int}), "string": vol.Schema({"mode": "string", "data": str}), }, ) ...
[ "def", "test_key_value_schemas", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "key_value_schemas", "(", "\"mode\"", ",", "{", "\"number\"", ":", "vol", ".", "Schema", "(", "{", "\"mode\"", ":", "\"number\"", ",", "\"data\"", ":", "...
[ 1106, 0 ]
[ 1139, 44 ]
python
de
['de', 'de', 'en']
True
test_script
(caplog)
Test script validation is user friendly.
Test script validation is user friendly.
def test_script(caplog): """Test script validation is user friendly.""" for data, msg in ( ({"delay": "{{ invalid"}, "should be format 'HH:MM'"), ({"wait_template": "{{ invalid"}, "invalid template"), ({"condition": "invalid"}, "Unexpected value for condition: 'invalid'"), ({"eve...
[ "def", "test_script", "(", "caplog", ")", ":", "for", "data", ",", "msg", "in", "(", "(", "{", "\"delay\"", ":", "\"{{ invalid\"", "}", ",", "\"should be format 'HH:MM'\"", ")", ",", "(", "{", "\"wait_template\"", ":", "\"{{ invalid\"", "}", ",", "\"invalid ...
[ 1142, 0 ]
[ 1161, 40 ]
python
en
['en', 'en', 'en']
True
test_whitespace
()
Test whitespace validation.
Test whitespace validation.
def test_whitespace(): """Test whitespace validation.""" schema = vol.Schema(cv.whitespace) for value in ( None, "" "T", "negative", "lock", "tr ue", [], [1, 2], {"one": "two"}, ): with pytest.raises(vol.MultipleInvalid): ...
[ "def", "test_whitespace", "(", ")", ":", "schema", "=", "vol", ".", "Schema", "(", "cv", ".", "whitespace", ")", "for", "value", "in", "(", "None", ",", "\"\"", "\"T\"", ",", "\"negative\"", ",", "\"lock\"", ",", "\"tr ue\"", ",", "[", "]", ",", "["...
[ 1164, 0 ]
[ 1182, 28 ]
python
en
['en', 'zu', 'en']
True
validate_config
(config)
Use the platform schema to validate configuration.
Use the platform schema to validate configuration.
def validate_config(config): """Use the platform schema to validate configuration.""" validated_config = universal.PLATFORM_SCHEMA(config) validated_config.pop("platform") return validated_config
[ "def", "validate_config", "(", "config", ")", ":", "validated_config", "=", "universal", ".", "PLATFORM_SCHEMA", "(", "config", ")", "validated_config", ".", "pop", "(", "\"platform\"", ")", "return", "validated_config" ]
[ 29, 0 ]
[ 33, 27 ]
python
en
['en', 'en', 'en']
True
test_state_template
(hass)
Test with a simple valid state template.
Test with a simple valid state template.
async def test_state_template(hass): """Test with a simple valid state template.""" hass.states.async_set("sensor.test_sensor", STATE_ON) await async_setup_component( hass, "media_player", { "media_player": { "platform": "universal", "name...
[ "async", "def", "test_state_template", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_sensor\"", ",", "STATE_ON", ")", "await", "async_setup_component", "(", "hass", ",", "\"media_player\"", ",", "{", "\"media_player\"", ":", ...
[ 734, 0 ]
[ 757, 64 ]
python
en
['en', 'en', 'en']
True
test_invalid_state_template
(hass)
Test invalid state template sets state to None.
Test invalid state template sets state to None.
async def test_invalid_state_template(hass): """Test invalid state template sets state to None.""" hass.states.async_set("sensor.test_sensor", "on") await async_setup_component( hass, "media_player", { "media_player": { "platform": "universal", ...
[ "async", "def", "test_invalid_state_template", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"sensor.test_sensor\"", ",", "\"on\"", ")", "await", "async_setup_component", "(", "hass", ",", "\"media_player\"", ",", "{", "\"media_player\"", ...
[ 760, 0 ]
[ 783, 68 ]
python
en
['en', 'en', 'en']
True
test_master_state_with_template
(hass)
Test the state_template option.
Test the state_template option.
async def test_master_state_with_template(hass): """Test the state_template option.""" hass.states.async_set("input_boolean.test", STATE_OFF) hass.states.async_set("media_player.mock1", STATE_OFF) templ = ( '{% if states.input_boolean.test.state == "off" %}on' "{% else %}{{ states.media...
[ "async", "def", "test_master_state_with_template", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"input_boolean.test\"", ",", "STATE_OFF", ")", "hass", ".", "states", ".", "async_set", "(", "\"media_player.mock1\"", ",", "STATE_OFF", ")", ...
[ 786, 0 ]
[ 826, 39 ]
python
en
['en', 'en', 'en']
True
test_reload
(hass)
Test reloading the media player from yaml.
Test reloading the media player from yaml.
async def test_reload(hass): """Test reloading the media player from yaml.""" hass.states.async_set("input_boolean.test", STATE_OFF) hass.states.async_set("media_player.mock1", STATE_OFF) templ = ( '{% if states.input_boolean.test.state == "off" %}on' "{% else %}{{ states.media_player.m...
[ "async", "def", "test_reload", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"input_boolean.test\"", ",", "STATE_OFF", ")", "hass", ".", "states", ".", "async_set", "(", "\"media_player.mock1\"", ",", "STATE_OFF", ")", "templ", "=", ...
[ 829, 0 ]
[ 888, 87 ]
python
en
['en', 'en', 'en']
True
MockMediaPlayer.__init__
(self, hass, name)
Initialize the media player.
Initialize the media player.
def __init__(self, hass, name): """Initialize the media player.""" self.hass = hass self._name = name self.entity_id = media_player.ENTITY_ID_FORMAT.format(name) self._state = STATE_OFF self._volume_level = 0 self._is_volume_muted = False self._media_title...
[ "def", "__init__", "(", "self", ",", "hass", ",", "name", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "_name", "=", "name", "self", ".", "entity_id", "=", "media_player", ".", "ENTITY_ID_FORMAT", ".", "format", "(", "name", ")", "self", ...
[ 39, 4 ]
[ 103, 9 ]
python
en
['en', 'en', 'en']
True
MockMediaPlayer.name
(self)
Return the name of player.
Return the name of player.
def name(self): """Return the name of player.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 106, 4 ]
[ 108, 25 ]
python
en
['en', 'en', 'en']
True
MockMediaPlayer.state
(self)
Return the state of the player.
Return the state of the player.
def state(self): """Return the state of the player.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 111, 4 ]
[ 113, 26 ]
python
en
['en', 'en', 'en']
True
MockMediaPlayer.volume_level
(self)
Return the volume level of player.
Return the volume level of player.
def volume_level(self): """Return the volume level of player.""" return self._volume_level
[ "def", "volume_level", "(", "self", ")", ":", "return", "self", ".", "_volume_level" ]
[ 116, 4 ]
[ 118, 33 ]
python
en
['en', 'en', 'en']
True
MockMediaPlayer.is_volume_muted
(self)
Return true if the media player is muted.
Return true if the media player is muted.
def is_volume_muted(self): """Return true if the media player is muted.""" return self._is_volume_muted
[ "def", "is_volume_muted", "(", "self", ")", ":", "return", "self", ".", "_is_volume_muted" ]
[ 121, 4 ]
[ 123, 36 ]
python
en
['en', 'en', 'en']
True
MockMediaPlayer.supported_features
(self)
Flag media player features that are supported.
Flag media player features that are supported.
def supported_features(self): """Flag media player features that are supported.""" return self._supported_features
[ "def", "supported_features", "(", "self", ")", ":", "return", "self", ".", "_supported_features" ]
[ 126, 4 ]
[ 128, 39 ]
python
en
['en', 'en', 'en']
True
MockMediaPlayer.media_image_url
(self)
Image url of current playing media.
Image url of current playing media.
def media_image_url(self): """Image url of current playing media.""" return self._media_image_url
[ "def", "media_image_url", "(", "self", ")", ":", "return", "self", ".", "_media_image_url" ]
[ 131, 4 ]
[ 133, 36 ]
python
en
['en', 'en', 'en']
True
MockMediaPlayer.shuffle
(self)
Return true if the media player is shuffling.
Return true if the media player is shuffling.
def shuffle(self): """Return true if the media player is shuffling.""" return self._shuffle
[ "def", "shuffle", "(", "self", ")", ":", "return", "self", ".", "_shuffle" ]
[ 136, 4 ]
[ 138, 28 ]
python
en
['en', 'en', 'en']
True
MockMediaPlayer.turn_on
(self)
Mock turn_on function.
Mock turn_on function.
def turn_on(self): """Mock turn_on function.""" self._state = None
[ "def", "turn_on", "(", "self", ")", ":", "self", ".", "_state", "=", "None" ]
[ 140, 4 ]
[ 142, 26 ]
python
en
['en', 'af', 'en']
True
MockMediaPlayer.turn_off
(self)
Mock turn_off function.
Mock turn_off function.
def turn_off(self): """Mock turn_off function.""" self._state = STATE_OFF
[ "def", "turn_off", "(", "self", ")", ":", "self", ".", "_state", "=", "STATE_OFF" ]
[ 144, 4 ]
[ 146, 31 ]
python
en
['en', 'en', 'en']
True
MockMediaPlayer.mute_volume
(self, mute)
Mock mute function.
Mock mute function.
def mute_volume(self, mute): """Mock mute function.""" self._is_volume_muted = mute
[ "def", "mute_volume", "(", "self", ",", "mute", ")", ":", "self", ".", "_is_volume_muted", "=", "mute" ]
[ 148, 4 ]
[ 150, 36 ]
python
en
['en', 'fy', 'en']
True
MockMediaPlayer.set_volume_level
(self, volume)
Mock set volume level.
Mock set volume level.
def set_volume_level(self, volume): """Mock set volume level.""" self._volume_level = volume
[ "def", "set_volume_level", "(", "self", ",", "volume", ")", ":", "self", ".", "_volume_level", "=", "volume" ]
[ 152, 4 ]
[ 154, 35 ]
python
da
['fr', 'da', 'en']
False
MockMediaPlayer.media_pause
(self)
Mock pause.
Mock pause.
def media_pause(self): """Mock pause.""" self._state = STATE_PAUSED
[ "def", "media_pause", "(", "self", ")", ":", "self", ".", "_state", "=", "STATE_PAUSED" ]
[ 160, 4 ]
[ 162, 34 ]
python
de
['de', 'zh', 'en']
False
MockMediaPlayer.select_source
(self, source)
Set the input source.
Set the input source.
def select_source(self, source): """Set the input source.""" self._source = source
[ "def", "select_source", "(", "self", ",", "source", ")", ":", "self", ".", "_source", "=", "source" ]
[ 164, 4 ]
[ 166, 29 ]
python
en
['en', 'su', 'en']
True
MockMediaPlayer.clear_playlist
(self)
Clear players playlist.
Clear players playlist.
def clear_playlist(self): """Clear players playlist.""" self._tracks = 0
[ "def", "clear_playlist", "(", "self", ")", ":", "self", ".", "_tracks", "=", "0" ]
[ 168, 4 ]
[ 170, 24 ]
python
en
['fr', 'en', 'en']
True
MockMediaPlayer.set_shuffle
(self, shuffle)
Clear players playlist.
Clear players playlist.
def set_shuffle(self, shuffle): """Clear players playlist.""" self._shuffle = shuffle
[ "def", "set_shuffle", "(", "self", ",", "shuffle", ")", ":", "self", ".", "_shuffle", "=", "shuffle" ]
[ 172, 4 ]
[ 174, 31 ]
python
en
['fr', 'en', 'en']
True
TestMediaPlayer.setUp
(self)
Set up things to be run when tests are started.
Set up things to be run when tests are started.
def setUp(self): # pylint: disable=invalid-name """Set up things to be run when tests are started.""" self.hass = get_test_home_assistant() self.mock_mp_1 = MockMediaPlayer(self.hass, "mock1") self.mock_mp_1.schedule_update_ha_state() self.mock_mp_2 = MockMediaPlayer(self.hass...
[ "def", "setUp", "(", "self", ")", ":", "# pylint: disable=invalid-name", "self", ".", "hass", "=", "get_test_home_assistant", "(", ")", "self", ".", "mock_mp_1", "=", "MockMediaPlayer", "(", "self", ".", "hass", ",", "\"mock1\"", ")", "self", ".", "mock_mp_1",...
[ 180, 4 ]
[ 234, 47 ]
python
en
['en', 'en', 'en']
True
TestMediaPlayer.tear_down_cleanup
(self)
Stop everything that was started.
Stop everything that was started.
def tear_down_cleanup(self): """Stop everything that was started.""" self.hass.stop()
[ "def", "tear_down_cleanup", "(", "self", ")", ":", "self", ".", "hass", ".", "stop", "(", ")" ]
[ 236, 4 ]
[ 238, 24 ]
python
en
['en', 'en', 'en']
True