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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
IcloudDeviceBatterySensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self._device.unique_id}_battery" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._device.unique_id}_battery\""
] | [
60,
4
] | [
62,
50
] | python | ca | ['fr', 'ca', 'en'] | False |
IcloudDeviceBatterySensor.name | (self) | Sensor name. | Sensor name. | def name(self) -> str:
"""Sensor name."""
return f"{self._device.name} battery state" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._device.name} battery state\""
] | [
65,
4
] | [
67,
51
] | python | en | ['en', 'ceb', 'en'] | False |
IcloudDeviceBatterySensor.device_class | (self) | Return the device class of the sensor. | Return the device class of the sensor. | def device_class(self) -> str:
"""Return the device class of the sensor."""
return DEVICE_CLASS_BATTERY | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DEVICE_CLASS_BATTERY"
] | [
70,
4
] | [
72,
35
] | python | en | ['en', 'en', 'en'] | True |
IcloudDeviceBatterySensor.state | (self) | Battery state percentage. | Battery state percentage. | def state(self) -> int:
"""Battery state percentage."""
return self._device.battery_level | [
"def",
"state",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"_device",
".",
"battery_level"
] | [
75,
4
] | [
77,
41
] | python | en | ['en', 'en', 'en'] | True |
IcloudDeviceBatterySensor.unit_of_measurement | (self) | Battery state measured in percentage. | Battery state measured in percentage. | def unit_of_measurement(self) -> str:
"""Battery state measured in percentage."""
return PERCENTAGE | [
"def",
"unit_of_measurement",
"(",
"self",
")",
"->",
"str",
":",
"return",
"PERCENTAGE"
] | [
80,
4
] | [
82,
25
] | python | en | ['en', 'en', 'en'] | True |
IcloudDeviceBatterySensor.icon | (self) | Battery state icon handling. | Battery state icon handling. | def icon(self) -> str:
"""Battery state icon handling."""
return icon_for_battery_level(
battery_level=self._device.battery_level,
charging=self._device.battery_status == "Charging",
) | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"icon_for_battery_level",
"(",
"battery_level",
"=",
"self",
".",
"_device",
".",
"battery_level",
",",
"charging",
"=",
"self",
".",
"_device",
".",
"battery_status",
"==",
"\"Charging\"",
",",
")... | [
85,
4
] | [
90,
9
] | python | en | ['en', 'en', 'en'] | True |
IcloudDeviceBatterySensor.device_state_attributes | (self) | Return default attributes for the iCloud device entity. | Return default attributes for the iCloud device entity. | def device_state_attributes(self) -> Dict[str, any]:
"""Return default attributes for the iCloud device entity."""
return self._device.state_attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"any",
"]",
":",
"return",
"self",
".",
"_device",
".",
"state_attributes"
] | [
93,
4
] | [
95,
44
] | python | en | ['en', 'en', 'en'] | True |
IcloudDeviceBatterySensor.device_info | (self) | Return the device information. | Return the device information. | def device_info(self) -> Dict[str, any]:
"""Return the device information."""
return {
"identifiers": {(DOMAIN, self._device.unique_id)},
"name": self._device.name,
"manufacturer": "Apple",
"model": self._device.device_model,
} | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"any",
"]",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device",
".",
"unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_device",
... | [
98,
4
] | [
105,
9
] | python | en | ['en', 'en', 'en'] | True |
IcloudDeviceBatterySensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self) -> bool:
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
108,
4
] | [
110,
20
] | python | en | ['en', 'en', 'en'] | True |
IcloudDeviceBatterySensor.async_added_to_hass | (self) | Register state update callback. | Register state update callback. | async def async_added_to_hass(self):
"""Register state update callback."""
self._unsub_dispatcher = async_dispatcher_connect(
self.hass, self._account.signal_device_update, self.async_write_ha_state
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_unsub_dispatcher",
"=",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_account",
".",
"signal_device_update",
",",
"self",
".",
"async_write_ha_state",
")"
] | [
112,
4
] | [
116,
9
] | python | en | ['en', 'co', 'en'] | True |
IcloudDeviceBatterySensor.async_will_remove_from_hass | (self) | Clean up after entity before removal. | Clean up after entity before removal. | async def async_will_remove_from_hass(self):
"""Clean up after entity before removal."""
self._unsub_dispatcher() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_unsub_dispatcher",
"(",
")"
] | [
118,
4
] | [
120,
32
] | python | en | ['en', 'en', 'en'] | True |
default_sensor | () | Create an ArloSensor with default values. | Create an ArloSensor with default values. | def default_sensor():
"""Create an ArloSensor with default values."""
return _get_sensor() | [
"def",
"default_sensor",
"(",
")",
":",
"return",
"_get_sensor",
"(",
")"
] | [
27,
0
] | [
29,
24
] | python | en | ['en', 'ga', 'en'] | True |
battery_sensor | () | Create an ArloSensor with battery data. | Create an ArloSensor with battery data. | def battery_sensor():
"""Create an ArloSensor with battery data."""
data = _get_named_tuple({"battery_level": 50})
return _get_sensor("Battery Level", "battery_level", data) | [
"def",
"battery_sensor",
"(",
")",
":",
"data",
"=",
"_get_named_tuple",
"(",
"{",
"\"battery_level\"",
":",
"50",
"}",
")",
"return",
"_get_sensor",
"(",
"\"Battery Level\"",
",",
"\"battery_level\"",
",",
"data",
")"
] | [
33,
0
] | [
36,
62
] | python | en | ['en', 'en', 'en'] | True |
temperature_sensor | () | Create a temperature ArloSensor. | Create a temperature ArloSensor. | def temperature_sensor():
"""Create a temperature ArloSensor."""
return _get_sensor("Temperature", "temperature") | [
"def",
"temperature_sensor",
"(",
")",
":",
"return",
"_get_sensor",
"(",
"\"Temperature\"",
",",
"\"temperature\"",
")"
] | [
40,
0
] | [
42,
52
] | python | en | ['en', 'la', 'en'] | True |
humidity_sensor | () | Create a humidity ArloSensor. | Create a humidity ArloSensor. | def humidity_sensor():
"""Create a humidity ArloSensor."""
return _get_sensor("Humidity", "humidity") | [
"def",
"humidity_sensor",
"(",
")",
":",
"return",
"_get_sensor",
"(",
"\"Humidity\"",
",",
"\"humidity\"",
")"
] | [
46,
0
] | [
48,
46
] | python | en | ['en', 'mg', 'en'] | True |
cameras_sensor | () | Create a total cameras ArloSensor. | Create a total cameras ArloSensor. | def cameras_sensor():
"""Create a total cameras ArloSensor."""
data = _get_named_tuple({"cameras": [0, 0]})
return _get_sensor("Arlo Cameras", "total_cameras", data) | [
"def",
"cameras_sensor",
"(",
")",
":",
"data",
"=",
"_get_named_tuple",
"(",
"{",
"\"cameras\"",
":",
"[",
"0",
",",
"0",
"]",
"}",
")",
"return",
"_get_sensor",
"(",
"\"Arlo Cameras\"",
",",
"\"total_cameras\"",
",",
"data",
")"
] | [
52,
0
] | [
55,
61
] | python | en | ['es', 'id', 'en'] | False |
captured_sensor | () | Create a captured today ArloSensor. | Create a captured today ArloSensor. | def captured_sensor():
"""Create a captured today ArloSensor."""
data = _get_named_tuple({"captured_today": [0, 0, 0, 0, 0]})
return _get_sensor("Captured Today", "captured_today", data) | [
"def",
"captured_sensor",
"(",
")",
":",
"data",
"=",
"_get_named_tuple",
"(",
"{",
"\"captured_today\"",
":",
"[",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
"]",
"}",
")",
"return",
"_get_sensor",
"(",
"\"Captured Today\"",
",",
"\"captured_today\"",
... | [
59,
0
] | [
62,
64
] | python | en | ['en', 'ro', 'en'] | True |
platform_setup | () | Create an instance of the PlatformSetupFixture class. | Create an instance of the PlatformSetupFixture class. | def platform_setup():
"""Create an instance of the PlatformSetupFixture class."""
return PlatformSetupFixture() | [
"def",
"platform_setup",
"(",
")",
":",
"return",
"PlatformSetupFixture",
"(",
")"
] | [
80,
0
] | [
82,
33
] | python | en | ['en', 'lb', 'en'] | True |
sensor_with_hass_data | (default_sensor, hass) | Create a sensor with async_dispatcher_connected mocked. | Create a sensor with async_dispatcher_connected mocked. | def sensor_with_hass_data(default_sensor, hass):
"""Create a sensor with async_dispatcher_connected mocked."""
hass.data = {}
default_sensor.hass = hass
return default_sensor | [
"def",
"sensor_with_hass_data",
"(",
"default_sensor",
",",
"hass",
")",
":",
"hass",
".",
"data",
"=",
"{",
"}",
"default_sensor",
".",
"hass",
"=",
"hass",
"return",
"default_sensor"
] | [
86,
0
] | [
90,
25
] | python | en | ['en', 'en', 'en'] | True |
mock_dispatch | () | Mock the dispatcher connect method. | Mock the dispatcher connect method. | def mock_dispatch():
"""Mock the dispatcher connect method."""
target = "homeassistant.components.arlo.sensor.async_dispatcher_connect"
with patch(target) as _mock:
yield _mock | [
"def",
"mock_dispatch",
"(",
")",
":",
"target",
"=",
"\"homeassistant.components.arlo.sensor.async_dispatcher_connect\"",
"with",
"patch",
"(",
"target",
")",
"as",
"_mock",
":",
"yield",
"_mock"
] | [
94,
0
] | [
98,
19
] | python | en | ['en', 'en', 'en'] | True |
test_setup_with_no_data | (platform_setup, hass) | Test setup_platform with no data. | Test setup_platform with no data. | def test_setup_with_no_data(platform_setup, hass):
"""Test setup_platform with no data."""
arlo.setup_platform(hass, None, platform_setup.add_entities)
assert platform_setup.sensors is None
assert not platform_setup.update | [
"def",
"test_setup_with_no_data",
"(",
"platform_setup",
",",
"hass",
")",
":",
"arlo",
".",
"setup_platform",
"(",
"hass",
",",
"None",
",",
"platform_setup",
".",
"add_entities",
")",
"assert",
"platform_setup",
".",
"sensors",
"is",
"None",
"assert",
"not",
... | [
101,
0
] | [
105,
36
] | python | en | ['en', 'pt', 'en'] | True |
test_setup_with_valid_data | (platform_setup, hass) | Test setup_platform with valid data. | Test setup_platform with valid data. | def test_setup_with_valid_data(platform_setup, hass):
"""Test setup_platform with valid data."""
config = {
"monitored_conditions": [
"last_capture",
"total_cameras",
"captured_today",
"battery_level",
"signal_strength",
"temperatur... | [
"def",
"test_setup_with_valid_data",
"(",
"platform_setup",
",",
"hass",
")",
":",
"config",
"=",
"{",
"\"monitored_conditions\"",
":",
"[",
"\"last_capture\"",
",",
"\"total_cameras\"",
",",
"\"captured_today\"",
",",
"\"battery_level\"",
",",
"\"signal_strength\"",
",... | [
108,
0
] | [
134,
32
] | python | en | ['en', 'da', 'en'] | True |
test_sensor_name | (default_sensor) | Test the name property. | Test the name property. | def test_sensor_name(default_sensor):
"""Test the name property."""
assert default_sensor.name == "Last" | [
"def",
"test_sensor_name",
"(",
"default_sensor",
")",
":",
"assert",
"default_sensor",
".",
"name",
"==",
"\"Last\""
] | [
137,
0
] | [
139,
40
] | python | en | ['en', 'en', 'en'] | True |
test_async_added_to_hass | (sensor_with_hass_data, mock_dispatch) | Test dispatcher called when added. | Test dispatcher called when added. | async def test_async_added_to_hass(sensor_with_hass_data, mock_dispatch):
"""Test dispatcher called when added."""
await sensor_with_hass_data.async_added_to_hass()
assert len(mock_dispatch.mock_calls) == 1
kall = mock_dispatch.call_args
args, kwargs = kall
assert len(args) == 3
assert args[... | [
"async",
"def",
"test_async_added_to_hass",
"(",
"sensor_with_hass_data",
",",
"mock_dispatch",
")",
":",
"await",
"sensor_with_hass_data",
".",
"async_added_to_hass",
"(",
")",
"assert",
"len",
"(",
"mock_dispatch",
".",
"mock_calls",
")",
"==",
"1",
"kall",
"=",
... | [
142,
0
] | [
151,
21
] | python | en | ['en', 'de', 'en'] | True |
test_sensor_state_default | (default_sensor) | Test the state property. | Test the state property. | def test_sensor_state_default(default_sensor):
"""Test the state property."""
assert default_sensor.state is None | [
"def",
"test_sensor_state_default",
"(",
"default_sensor",
")",
":",
"assert",
"default_sensor",
".",
"state",
"is",
"None"
] | [
154,
0
] | [
156,
39
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_icon_battery | (battery_sensor) | Test the battery icon. | Test the battery icon. | def test_sensor_icon_battery(battery_sensor):
"""Test the battery icon."""
assert battery_sensor.icon == "mdi:battery-50" | [
"def",
"test_sensor_icon_battery",
"(",
"battery_sensor",
")",
":",
"assert",
"battery_sensor",
".",
"icon",
"==",
"\"mdi:battery-50\""
] | [
159,
0
] | [
161,
50
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_icon | (temperature_sensor) | Test the icon property. | Test the icon property. | def test_sensor_icon(temperature_sensor):
"""Test the icon property."""
assert temperature_sensor.icon == "mdi:thermometer" | [
"def",
"test_sensor_icon",
"(",
"temperature_sensor",
")",
":",
"assert",
"temperature_sensor",
".",
"icon",
"==",
"\"mdi:thermometer\""
] | [
164,
0
] | [
166,
55
] | python | en | ['en', 'en', 'en'] | True |
test_unit_of_measure | (default_sensor, battery_sensor) | Test the unit_of_measurement property. | Test the unit_of_measurement property. | def test_unit_of_measure(default_sensor, battery_sensor):
"""Test the unit_of_measurement property."""
assert default_sensor.unit_of_measurement is None
assert battery_sensor.unit_of_measurement == PERCENTAGE | [
"def",
"test_unit_of_measure",
"(",
"default_sensor",
",",
"battery_sensor",
")",
":",
"assert",
"default_sensor",
".",
"unit_of_measurement",
"is",
"None",
"assert",
"battery_sensor",
".",
"unit_of_measurement",
"==",
"PERCENTAGE"
] | [
169,
0
] | [
172,
59
] | python | en | ['en', 'en', 'en'] | True |
test_device_class | (default_sensor, temperature_sensor, humidity_sensor) | Test the device_class property. | Test the device_class property. | def test_device_class(default_sensor, temperature_sensor, humidity_sensor):
"""Test the device_class property."""
assert default_sensor.device_class is None
assert temperature_sensor.device_class == DEVICE_CLASS_TEMPERATURE
assert humidity_sensor.device_class == DEVICE_CLASS_HUMIDITY | [
"def",
"test_device_class",
"(",
"default_sensor",
",",
"temperature_sensor",
",",
"humidity_sensor",
")",
":",
"assert",
"default_sensor",
".",
"device_class",
"is",
"None",
"assert",
"temperature_sensor",
".",
"device_class",
"==",
"DEVICE_CLASS_TEMPERATURE",
"assert",
... | [
175,
0
] | [
179,
64
] | python | en | ['en', 'en', 'en'] | True |
test_update_total_cameras | (cameras_sensor) | Test update method for total_cameras sensor type. | Test update method for total_cameras sensor type. | def test_update_total_cameras(cameras_sensor):
"""Test update method for total_cameras sensor type."""
cameras_sensor.update()
assert cameras_sensor.state == 2 | [
"def",
"test_update_total_cameras",
"(",
"cameras_sensor",
")",
":",
"cameras_sensor",
".",
"update",
"(",
")",
"assert",
"cameras_sensor",
".",
"state",
"==",
"2"
] | [
182,
0
] | [
185,
36
] | python | en | ['en', 'da', 'en'] | True |
test_update_captured_today | (captured_sensor) | Test update method for captured_today sensor type. | Test update method for captured_today sensor type. | def test_update_captured_today(captured_sensor):
"""Test update method for captured_today sensor type."""
captured_sensor.update()
assert captured_sensor.state == 5 | [
"def",
"test_update_captured_today",
"(",
"captured_sensor",
")",
":",
"captured_sensor",
".",
"update",
"(",
")",
"assert",
"captured_sensor",
".",
"state",
"==",
"5"
] | [
188,
0
] | [
191,
37
] | python | en | ['en', 'nl', 'en'] | True |
test_state_attributes | () | Test attributes for camera sensor types. | Test attributes for camera sensor types. | def test_state_attributes():
"""Test attributes for camera sensor types."""
_test_attributes("battery_level")
_test_attributes("signal_strength")
_test_attributes("temperature")
_test_attributes("humidity")
_test_attributes("air_quality") | [
"def",
"test_state_attributes",
"(",
")",
":",
"_test_attributes",
"(",
"\"battery_level\"",
")",
"_test_attributes",
"(",
"\"signal_strength\"",
")",
"_test_attributes",
"(",
"\"temperature\"",
")",
"_test_attributes",
"(",
"\"humidity\"",
")",
"_test_attributes",
"(",
... | [
203,
0
] | [
209,
35
] | python | en | ['en', 'en', 'en'] | True |
test_attributes_total_cameras | (cameras_sensor) | Test attributes for total cameras sensor type. | Test attributes for total cameras sensor type. | def test_attributes_total_cameras(cameras_sensor):
"""Test attributes for total cameras sensor type."""
attrs = cameras_sensor.device_state_attributes
assert attrs.get(ATTR_ATTRIBUTION) == "Data provided by arlo.netgear.com"
assert attrs.get("brand") == "Netgear Arlo"
assert attrs.get("model") is No... | [
"def",
"test_attributes_total_cameras",
"(",
"cameras_sensor",
")",
":",
"attrs",
"=",
"cameras_sensor",
".",
"device_state_attributes",
"assert",
"attrs",
".",
"get",
"(",
"ATTR_ATTRIBUTION",
")",
"==",
"\"Data provided by arlo.netgear.com\"",
"assert",
"attrs",
".",
"... | [
212,
0
] | [
217,
37
] | python | en | ['en', 'en', 'en'] | True |
test_update | () | Test update method for direct transcription sensor types. | Test update method for direct transcription sensor types. | def test_update():
"""Test update method for direct transcription sensor types."""
_test_update("battery_level", "battery_level", 100)
_test_update("signal_strength", "signal_strength", 100)
_test_update("temperature", "ambient_temperature", 21.4)
_test_update("humidity", "ambient_humidity", 45.1)
... | [
"def",
"test_update",
"(",
")",
":",
"_test_update",
"(",
"\"battery_level\"",
",",
"\"battery_level\"",
",",
"100",
")",
"_test_update",
"(",
"\"signal_strength\"",
",",
"\"signal_strength\"",
",",
"100",
")",
"_test_update",
"(",
"\"temperature\"",
",",
"\"ambient... | [
227,
0
] | [
233,
60
] | python | en | ['en', 'no', 'en'] | True |
PlatformSetupFixture.__init__ | (self) | Instantiate the platform setup fixture. | Instantiate the platform setup fixture. | def __init__(self):
"""Instantiate the platform setup fixture."""
self.sensors = None
self.update = False | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"sensors",
"=",
"None",
"self",
".",
"update",
"=",
"False"
] | [
68,
4
] | [
71,
27
] | python | en | ['en', 'lv', 'en'] | True |
PlatformSetupFixture.add_entities | (self, sensors, update) | Mock method for adding devices. | Mock method for adding devices. | def add_entities(self, sensors, update):
"""Mock method for adding devices."""
self.sensors = sensors
self.update = update | [
"def",
"add_entities",
"(",
"self",
",",
"sensors",
",",
"update",
")",
":",
"self",
".",
"sensors",
"=",
"sensors",
"self",
".",
"update",
"=",
"update"
] | [
73,
4
] | [
76,
28
] | python | en | ['id', 'en', 'en'] | True |
test_random_binary_sensor_on | (hass) | Test the Random binary sensor. | Test the Random binary sensor. | async def test_random_binary_sensor_on(hass):
"""Test the Random binary sensor."""
config = {"binary_sensor": {"platform": "random", "name": "test"}}
with patch(
"homeassistant.components.random.binary_sensor.getrandbits",
return_value=1,
):
assert await async_setup_component(
... | [
"async",
"def",
"test_random_binary_sensor_on",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"random\"",
",",
"\"name\"",
":",
"\"test\"",
"}",
"}",
"with",
"patch",
"(",
"\"homeassistant.components.random.binary_s... | [
6,
0
] | [
23,
30
] | python | en | ['en', 'ku', 'en'] | True |
test_random_binary_sensor_off | (hass) | Test the Random binary sensor. | Test the Random binary sensor. | async def test_random_binary_sensor_off(hass):
"""Test the Random binary sensor."""
config = {"binary_sensor": {"platform": "random", "name": "test"}}
with patch(
"homeassistant.components.random.binary_sensor.getrandbits",
return_value=False,
):
assert await async_setup_compone... | [
"async",
"def",
"test_random_binary_sensor_off",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"\"binary_sensor\"",
":",
"{",
"\"platform\"",
":",
"\"random\"",
",",
"\"name\"",
":",
"\"test\"",
"}",
"}",
"with",
"patch",
"(",
"\"homeassistant.components.random.binary_... | [
26,
0
] | [
43,
31
] | python | en | ['en', 'ku', 'en'] | True |
_make_causal_mask | (input_ids_shape: tf.TensorShape, past_key_values_length: int = 0) |
Make causal mask used for bi-directional self-attention.
|
Make causal mask used for bi-directional self-attention.
| def _make_causal_mask(input_ids_shape: tf.TensorShape, past_key_values_length: int = 0):
"""
Make causal mask used for bi-directional self-attention.
"""
bsz, tgt_len = input_ids_shape
mask = tf.ones((tgt_len, tgt_len)) * LARGE_NEGATIVE
mask_cond = tf.range(shape_list(mask)[-1])
mask = tf.w... | [
"def",
"_make_causal_mask",
"(",
"input_ids_shape",
":",
"tf",
".",
"TensorShape",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"tgt_len",
"=",
"input_ids_shape",
"mask",
"=",
"tf",
".",
"ones",
"(",
"(",
"tgt_len",
",",
"tgt_... | [
84,
0
] | [
97,
58
] | python | en | ['en', 'error', 'th'] | False |
_expand_mask | (mask: tf.Tensor, tgt_len: Optional[int] = None, past_key_values_length: int = 0) |
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
|
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
| def _expand_mask(mask: tf.Tensor, tgt_len: Optional[int] = None, past_key_values_length: int = 0):
"""
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
"""
src_len = shape_list(mask)[1]
tgt_len = tgt_len if tgt_len is not None else src_len
one_cst = tf.consta... | [
"def",
"_expand_mask",
"(",
"mask",
":",
"tf",
".",
"Tensor",
",",
"tgt_len",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"src_len",
"=",
"shape_list",
"(",
"mask",
")",
"[",
"1",
"]",... | [
101,
0
] | [
111,
53
] | python | en | ['en', 'error', 'th'] | False |
TFBlenderbotSmallLearnedPositionalEmbedding.call | (self, input_shape: tf.TensorShape, past_key_values_length: int = 0) | Input is expected to be of size [bsz x seqlen]. | Input is expected to be of size [bsz x seqlen]. | def call(self, input_shape: tf.TensorShape, past_key_values_length: int = 0):
"""Input is expected to be of size [bsz x seqlen]."""
bsz, seq_len = input_shape[:2]
positions = tf.range(past_key_values_length, seq_len + past_key_values_length, delta=1, name="range")
return super().call(po... | [
"def",
"call",
"(",
"self",
",",
"input_shape",
":",
"tf",
".",
"TensorShape",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"seq_len",
"=",
"input_shape",
"[",
":",
"2",
"]",
"positions",
"=",
"tf",
".",
"range",
"(",
"p... | [
123,
4
] | [
128,
38
] | python | en | ['en', 'en', 'en'] | True |
TFBlenderbotSmallAttention.call | (
self,
hidden_states: tf.Tensor,
key_value_states: Optional[tf.Tensor] = None,
past_key_value: Optional[Tuple[Tuple[tf.Tensor]]] = None,
attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
training=False,
) | Input shape: Batch x Time x Channel | Input shape: Batch x Time x Channel | def call(
self,
hidden_states: tf.Tensor,
key_value_states: Optional[tf.Tensor] = None,
past_key_value: Optional[Tuple[Tuple[tf.Tensor]]] = None,
attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
training=False,
) -> Tupl... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
":",
"tf",
".",
"Tensor",
",",
"key_value_states",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"past_key_value",
":",
"Optional",
"[",
"Tuple",
"[",
"Tuple",
"[",
"tf",
".",
"Tenso... | [
162,
4
] | [
278,
56
] | python | en | ['en', 'pl', 'en'] | True |
TFBlenderbotSmallEncoderLayer.call | (self, hidden_states: tf.Tensor, attention_mask: tf.Tensor, layer_head_mask: tf.Tensor, training=False) |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
laye... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
laye... | def call(self, hidden_states: tf.Tensor, attention_mask: tf.Tensor, layer_head_mask: tf.Tensor, training=False):
"""
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
":",
"tf",
".",
"Tensor",
",",
"attention_mask",
":",
"tf",
".",
"Tensor",
",",
"layer_head_mask",
":",
"tf",
".",
"Tensor",
",",
"training",
"=",
"False",
")",
":",
"residual",
"=",
"hidden_states",
"hid... | [
297,
4
] | [
332,
47
] | python | en | ['en', 'error', 'th'] | False |
TFBlenderbotSmallDecoderLayer.call | (
self,
hidden_states,
attention_mask: Optional[tf.Tensor] = None,
encoder_hidden_states: Optional[tf.Tensor] = None,
encoder_attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
encoder_layer_head_mask: Optional[tf.Tensor] = No... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
enco... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
enco... | def call(
self,
hidden_states,
attention_mask: Optional[tf.Tensor] = None,
encoder_hidden_states: Optional[tf.Tensor] = None,
encoder_attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
encoder_layer_head_mask: Optional[tf.Tens... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
",",
"attention_mask",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"encoder_hidden_states",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"encoder_attention_mask",
... | [
364,
4
] | [
439,
9
] | python | en | ['en', 'error', 'th'] | False |
setup | (hass, config) | Set up the Emoncms history component. | Set up the Emoncms history component. | def setup(hass, config):
"""Set up the Emoncms history component."""
conf = config[DOMAIN]
whitelist = conf.get(CONF_WHITELIST)
def send_data(url, apikey, node, payload):
"""Send payload data to Emoncms."""
try:
fullurl = f"{url}/input/post.json"
data = {"apikey"... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"whitelist",
"=",
"conf",
".",
"get",
"(",
"CONF_WHITELIST",
")",
"def",
"send_data",
"(",
"url",
",",
"apikey",
",",
"node",
",",
"payload",
")",
":",
... | [
42,
0
] | [
101,
15
] | python | en | ['en', 'en', 'en'] | True |
async_detect_location_info | (
session: aiohttp.ClientSession,
) | Detect location information. | Detect location information. | async def async_detect_location_info(
session: aiohttp.ClientSession,
) -> Optional[LocationInfo]:
"""Detect location information."""
data = await _get_ipapi(session)
if data is None:
data = await _get_ip_api(session)
if data is None:
return None
data["use_metric"] = data["cou... | [
"async",
"def",
"async_detect_location_info",
"(",
"session",
":",
"aiohttp",
".",
"ClientSession",
",",
")",
"->",
"Optional",
"[",
"LocationInfo",
"]",
":",
"data",
"=",
"await",
"_get_ipapi",
"(",
"session",
")",
"if",
"data",
"is",
"None",
":",
"data",
... | [
47,
0
] | [
61,
31
] | python | en | ['en', 'en', 'en'] | True |
distance | (
lat1: Optional[float], lon1: Optional[float], lat2: float, lon2: float
) | Calculate the distance in meters between two points.
Async friendly.
| Calculate the distance in meters between two points. | def distance(
lat1: Optional[float], lon1: Optional[float], lat2: float, lon2: float
) -> Optional[float]:
"""Calculate the distance in meters between two points.
Async friendly.
"""
if lat1 is None or lon1 is None:
return None
result = vincenty((lat1, lon1), (lat2, lon2))
if result... | [
"def",
"distance",
"(",
"lat1",
":",
"Optional",
"[",
"float",
"]",
",",
"lon1",
":",
"Optional",
"[",
"float",
"]",
",",
"lat2",
":",
"float",
",",
"lon2",
":",
"float",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"if",
"lat1",
"is",
"None",
... | [
64,
0
] | [
76,
24
] | python | en | ['en', 'en', 'en'] | True |
vincenty | (
point1: Tuple[float, float], point2: Tuple[float, float], miles: bool = False
) |
Vincenty formula (inverse method) to calculate the distance.
Result in kilometers or miles between two points on the surface of a
spheroid.
Async friendly.
|
Vincenty formula (inverse method) to calculate the distance. | def vincenty(
point1: Tuple[float, float], point2: Tuple[float, float], miles: bool = False
) -> Optional[float]:
"""
Vincenty formula (inverse method) to calculate the distance.
Result in kilometers or miles between two points on the surface of a
spheroid.
Async friendly.
"""
# short-... | [
"def",
"vincenty",
"(",
"point1",
":",
"Tuple",
"[",
"float",
",",
"float",
"]",
",",
"point2",
":",
"Tuple",
"[",
"float",
",",
"float",
"]",
",",
"miles",
":",
"bool",
"=",
"False",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"# short-circuit co... | [
82,
0
] | [
161,
22
] | python | en | ['en', 'error', 'th'] | False |
_get_ipapi | (session: aiohttp.ClientSession) | Query ipapi.co for location data. | Query ipapi.co for location data. | async def _get_ipapi(session: aiohttp.ClientSession) -> Optional[Dict[str, Any]]:
"""Query ipapi.co for location data."""
try:
resp = await session.get(IPAPI, timeout=5)
except (aiohttp.ClientError, asyncio.TimeoutError):
return None
try:
raw_info = await resp.json()
except ... | [
"async",
"def",
"_get_ipapi",
"(",
"session",
":",
"aiohttp",
".",
"ClientSession",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"try",
":",
"resp",
"=",
"await",
"session",
".",
"get",
"(",
"IPAPI",
",",
"timeout",
"=",... | [
164,
0
] | [
191,
5
] | python | en | ['en', 'en', 'it'] | True |
_get_ip_api | (session: aiohttp.ClientSession) | Query ip-api.com for location data. | Query ip-api.com for location data. | async def _get_ip_api(session: aiohttp.ClientSession) -> Optional[Dict[str, Any]]:
"""Query ip-api.com for location data."""
try:
resp = await session.get(IP_API, timeout=5)
except (aiohttp.ClientError, asyncio.TimeoutError):
return None
try:
raw_info = await resp.json()
exc... | [
"async",
"def",
"_get_ip_api",
"(",
"session",
":",
"aiohttp",
".",
"ClientSession",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"try",
":",
"resp",
"=",
"await",
"session",
".",
"get",
"(",
"IP_API",
",",
"timeout",
"=... | [
194,
0
] | [
216,
5
] | python | en | ['en', 'pt', 'en'] | True |
simple_queue | () | Fixture that get the queue. | Fixture that get the queue. | def simple_queue():
"""Fixture that get the queue."""
simple_queue_fixed = queue.SimpleQueue()
with patch(
"homeassistant.components.system_log.queue.SimpleQueue",
return_value=simple_queue_fixed,
):
yield simple_queue_fixed | [
"def",
"simple_queue",
"(",
")",
":",
"simple_queue_fixed",
"=",
"queue",
".",
"SimpleQueue",
"(",
")",
"with",
"patch",
"(",
"\"homeassistant.components.system_log.queue.SimpleQueue\"",
",",
"return_value",
"=",
"simple_queue_fixed",
",",
")",
":",
"yield",
"simple_q... | [
18,
0
] | [
25,
32
] | python | en | ['en', 'nl', 'en'] | True |
get_error_log | (hass, hass_client, expected_count) | Fetch all entries from system_log via the API. | Fetch all entries from system_log via the API. | async def get_error_log(hass, hass_client, expected_count):
"""Fetch all entries from system_log via the API."""
client = await hass_client()
resp = await client.get("/api/error/all")
assert resp.status == 200
data = await resp.json()
assert len(data) == expected_count
return data | [
"async",
"def",
"get_error_log",
"(",
"hass",
",",
"hass_client",
",",
"expected_count",
")",
":",
"client",
"=",
"await",
"hass_client",
"(",
")",
"resp",
"=",
"await",
"client",
".",
"get",
"(",
"\"/api/error/all\"",
")",
"assert",
"resp",
".",
"status",
... | [
38,
0
] | [
48,
15
] | python | en | ['en', 'pt', 'en'] | True |
assert_log | (log, exception, message, level) | Assert that specified values are in a specific log entry. | Assert that specified values are in a specific log entry. | def assert_log(log, exception, message, level):
"""Assert that specified values are in a specific log entry."""
if not isinstance(message, list):
message = [message]
assert log["name"] == "test_logger"
assert exception in log["exception"]
assert message == log["message"]
assert level ==... | [
"def",
"assert_log",
"(",
"log",
",",
"exception",
",",
"message",
",",
"level",
")",
":",
"if",
"not",
"isinstance",
"(",
"message",
",",
"list",
")",
":",
"message",
"=",
"[",
"message",
"]",
"assert",
"log",
"[",
"\"name\"",
"]",
"==",
"\"test_logge... | [
58,
0
] | [
67,
29
] | python | en | ['en', 'en', 'en'] | True |
get_frame | (name) | Get log stack frame. | Get log stack frame. | def get_frame(name):
"""Get log stack frame."""
return (name, 5, None, None) | [
"def",
"get_frame",
"(",
"name",
")",
":",
"return",
"(",
"name",
",",
"5",
",",
"None",
",",
"None",
")"
] | [
70,
0
] | [
72,
32
] | python | da | ['da', 'da', 'en'] | True |
test_normal_logs | (hass, simple_queue, hass_client) | Test that debug and info are not logged. | Test that debug and info are not logged. | async def test_normal_logs(hass, simple_queue, hass_client):
"""Test that debug and info are not logged."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
_LOGGER.debug("debug")
_LOGGER.info("info")
await _async_block_until_queue_empty(hass, simple_queue)
# Assert done by g... | [
"async",
"def",
"test_normal_logs",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"_LOGGER",
".",
"debug",
"(",
"\"debug\"",
")",
"_LOG... | [
75,
0
] | [
84,
45
] | python | en | ['en', 'en', 'en'] | True |
test_exception | (hass, simple_queue, hass_client) | Test that exceptions are logged and retrieved correctly. | Test that exceptions are logged and retrieved correctly. | async def test_exception(hass, simple_queue, hass_client):
"""Test that exceptions are logged and retrieved correctly."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
_generate_and_log_exception("exception message", "log message")
await _async_block_until_queue_empty(hass, simple_q... | [
"async",
"def",
"test_exception",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"_generate_and_log_exception",
"(",
"\"exception message\"",
... | [
87,
0
] | [
94,
64
] | python | en | ['en', 'en', 'en'] | True |
test_warning | (hass, simple_queue, hass_client) | Test that warning are logged and retrieved correctly. | Test that warning are logged and retrieved correctly. | async def test_warning(hass, simple_queue, hass_client):
"""Test that warning are logged and retrieved correctly."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
_LOGGER.warning("warning message")
await _async_block_until_queue_empty(hass, simple_queue)
log = (await get_error_... | [
"async",
"def",
"test_warning",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"_LOGGER",
".",
"warning",
"(",
"\"warning message\"",
")",... | [
97,
0
] | [
104,
53
] | python | en | ['en', 'en', 'en'] | True |
test_error | (hass, simple_queue, hass_client) | Test that errors are logged and retrieved correctly. | Test that errors are logged and retrieved correctly. | async def test_error(hass, simple_queue, hass_client):
"""Test that errors are logged and retrieved correctly."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
_LOGGER.error("error message")
await _async_block_until_queue_empty(hass, simple_queue)
log = (await get_error_log(has... | [
"async",
"def",
"test_error",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"_LOGGER",
".",
"error",
"(",
"\"error message\"",
")",
"aw... | [
107,
0
] | [
114,
49
] | python | en | ['en', 'en', 'en'] | True |
test_config_not_fire_event | (hass, simple_queue) | Test that errors are not posted as events with default config. | Test that errors are not posted as events with default config. | async def test_config_not_fire_event(hass, simple_queue):
"""Test that errors are not posted as events with default config."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
events = []
@callback
def event_listener(event):
"""Listen to events of type system_log_event."""... | [
"async",
"def",
"test_config_not_fire_event",
"(",
"hass",
",",
"simple_queue",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"events",
"=",
"[",
"]",
"@",
"callback",
"def",
"event_listener"... | [
117,
0
] | [
132,
27
] | python | en | ['en', 'en', 'en'] | True |
test_error_posted_as_event | (hass, simple_queue) | Test that error are posted as events. | Test that error are posted as events. | async def test_error_posted_as_event(hass, simple_queue):
"""Test that error are posted as events."""
await async_setup_component(
hass, system_log.DOMAIN, {"system_log": {"max_entries": 2, "fire_event": True}}
)
events = []
@callback
def event_listener(event):
"""Listen to even... | [
"async",
"def",
"test_error_posted_as_event",
"(",
"hass",
",",
"simple_queue",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"{",
"\"system_log\"",
":",
"{",
"\"max_entries\"",
":",
"2",
",",
"\"fire_event\"",
"... | [
135,
0
] | [
153,
60
] | python | en | ['en', 'en', 'en'] | True |
test_critical | (hass, simple_queue, hass_client) | Test that critical are logged and retrieved correctly. | Test that critical are logged and retrieved correctly. | async def test_critical(hass, simple_queue, hass_client):
"""Test that critical are logged and retrieved correctly."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
_LOGGER.critical("critical message")
await _async_block_until_queue_empty(hass, simple_queue)
log = (await get_er... | [
"async",
"def",
"test_critical",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"_LOGGER",
".",
"critical",
"(",
"\"critical message\"",
"... | [
156,
0
] | [
163,
55
] | python | en | ['en', 'en', 'en'] | True |
test_remove_older_logs | (hass, simple_queue, hass_client) | Test that older logs are rotated out. | Test that older logs are rotated out. | async def test_remove_older_logs(hass, simple_queue, hass_client):
"""Test that older logs are rotated out."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
_LOGGER.error("error message 1")
_LOGGER.error("error message 2")
_LOGGER.error("error message 3")
await _async_block_... | [
"async",
"def",
"test_remove_older_logs",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"_LOGGER",
".",
"error",
"(",
"\"error message 1\""... | [
166,
0
] | [
176,
54
] | python | en | ['en', 'en', 'en'] | True |
log_msg | (nr=2) | Log an error at same line. | Log an error at same line. | def log_msg(nr=2):
"""Log an error at same line."""
_LOGGER.error("error message %s", nr) | [
"def",
"log_msg",
"(",
"nr",
"=",
"2",
")",
":",
"_LOGGER",
".",
"error",
"(",
"\"error message %s\"",
",",
"nr",
")"
] | [
179,
0
] | [
181,
41
] | python | da | ['da', 'lb', 'en'] | False |
test_dedupe_logs | (hass, simple_queue, hass_client) | Test that duplicate log entries are dedupe. | Test that duplicate log entries are dedupe. | async def test_dedupe_logs(hass, simple_queue, hass_client):
"""Test that duplicate log entries are dedupe."""
await async_setup_component(hass, system_log.DOMAIN, {})
_LOGGER.error("error message 1")
log_msg()
log_msg("2-2")
_LOGGER.error("error message 3")
await _async_block_until_queue_em... | [
"async",
"def",
"test_dedupe_logs",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"{",
"}",
")",
"_LOGGER",
".",
"error",
"(",
"\"error message 1\"",
")",
... | [
184,
0
] | [
223,
5
] | python | en | ['en', 'en', 'en'] | True |
test_clear_logs | (hass, simple_queue, hass_client) | Test that the log can be cleared via a service call. | Test that the log can be cleared via a service call. | async def test_clear_logs(hass, simple_queue, hass_client):
"""Test that the log can be cleared via a service call."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
_LOGGER.error("error message")
await _async_block_until_queue_empty(hass, simple_queue)
await hass.services.async... | [
"async",
"def",
"test_clear_logs",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"_LOGGER",
".",
"error",
"(",
"\"error message\"",
")",
... | [
226,
0
] | [
236,
45
] | python | en | ['en', 'en', 'en'] | True |
test_write_log | (hass) | Test that error propagates to logger. | Test that error propagates to logger. | async def test_write_log(hass):
"""Test that error propagates to logger."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
logger = MagicMock()
with patch("logging.getLogger", return_value=logger) as mock_logging:
await hass.services.async_call(
system_log.DOMAIN,... | [
"async",
"def",
"test_write_log",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"logger",
"=",
"MagicMock",
"(",
")",
"with",
"patch",
"(",
"\"logging.getLogger\"",
",",
"retur... | [
239,
0
] | [
249,
65
] | python | en | ['en', 'el-Latn', 'en'] | True |
test_write_choose_logger | (hass) | Test that correct logger is chosen. | Test that correct logger is chosen. | async def test_write_choose_logger(hass):
"""Test that correct logger is chosen."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
with patch("logging.getLogger") as mock_logging:
await hass.services.async_call(
system_log.DOMAIN,
system_log.SERVICE_WRITE,... | [
"async",
"def",
"test_write_choose_logger",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"with",
"patch",
"(",
"\"logging.getLogger\"",
")",
"as",
"mock_logging",
":",
"await",
... | [
252,
0
] | [
262,
52
] | python | en | ['en', 'en', 'en'] | True |
test_write_choose_level | (hass) | Test that correct logger is chosen. | Test that correct logger is chosen. | async def test_write_choose_level(hass):
"""Test that correct logger is chosen."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
logger = MagicMock()
with patch("logging.getLogger", return_value=logger):
await hass.services.async_call(
system_log.DOMAIN,
... | [
"async",
"def",
"test_write_choose_level",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"logger",
"=",
"MagicMock",
"(",
")",
"with",
"patch",
"(",
"\"logging.getLogger\"",
",",... | [
265,
0
] | [
276,
65
] | python | en | ['en', 'en', 'en'] | True |
test_unknown_path | (hass, simple_queue, hass_client) | Test error logged from unknown path. | Test error logged from unknown path. | async def test_unknown_path(hass, simple_queue, hass_client):
"""Test error logged from unknown path."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
_LOGGER.findCaller = MagicMock(return_value=("unknown_path", 0, None, None))
_LOGGER.error("error message")
await _async_block_u... | [
"async",
"def",
"test_unknown_path",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"_LOGGER",
".",
"findCaller",
"=",
"MagicMock",
"(",
... | [
279,
0
] | [
286,
47
] | python | en | ['en', 'en', 'en'] | True |
async_log_error_from_test_path | (hass, path, sq) | Log error while mocking the path. | Log error while mocking the path. | async def async_log_error_from_test_path(hass, path, sq):
"""Log error while mocking the path."""
call_path = "internal_path.py"
with patch.object(
_LOGGER, "findCaller", MagicMock(return_value=(call_path, 0, None, None))
):
with patch(
"traceback.extract_stack",
... | [
"async",
"def",
"async_log_error_from_test_path",
"(",
"hass",
",",
"path",
",",
"sq",
")",
":",
"call_path",
"=",
"\"internal_path.py\"",
"with",
"patch",
".",
"object",
"(",
"_LOGGER",
",",
"\"findCaller\"",
",",
"MagicMock",
"(",
"return_value",
"=",
"(",
"... | [
289,
0
] | [
307,
58
] | python | en | ['en', 'en', 'en'] | True |
test_homeassistant_path | (hass, simple_queue, hass_client) | Test error logged from Home Assistant path. | Test error logged from Home Assistant path. | async def test_homeassistant_path(hass, simple_queue, hass_client):
"""Test error logged from Home Assistant path."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
with patch(
"homeassistant.components.system_log.HOMEASSISTANT_PATH",
new=["venv_path/homeassistant"],
... | [
"async",
"def",
"test_homeassistant_path",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"with",
"patch",
"(",
"\"homeassistant.components.sy... | [
310,
0
] | [
321,
57
] | python | en | ['en', 'en', 'en'] | True |
test_config_path | (hass, simple_queue, hass_client) | Test error logged from config path. | Test error logged from config path. | async def test_config_path(hass, simple_queue, hass_client):
"""Test error logged from config path."""
await async_setup_component(hass, system_log.DOMAIN, BASIC_CONFIG)
with patch.object(hass.config, "config_dir", new="config"):
await async_log_error_from_test_path(
hass, "config/custom... | [
"async",
"def",
"test_config_path",
"(",
"hass",
",",
"simple_queue",
",",
"hass_client",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"system_log",
".",
"DOMAIN",
",",
"BASIC_CONFIG",
")",
"with",
"patch",
".",
"object",
"(",
"hass",
".",
"... | [
324,
0
] | [
332,
59
] | python | en | ['en', 'en', 'en'] | True |
registry | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def registry(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"registry",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
14,
0
] | [
16,
37
] | python | en | ['en', 'fy', 'en'] | True |
update_events | (hass) | Capture update events. | Capture update events. | def update_events(hass):
"""Capture update events."""
events = []
@callback
def async_capture(event):
events.append(event.data)
hass.bus.async_listen(device_registry.EVENT_DEVICE_REGISTRY_UPDATED, async_capture)
return events | [
"def",
"update_events",
"(",
"hass",
")",
":",
"events",
"=",
"[",
"]",
"@",
"callback",
"def",
"async_capture",
"(",
"event",
")",
":",
"events",
".",
"append",
"(",
"event",
".",
"data",
")",
"hass",
".",
"bus",
".",
"async_listen",
"(",
"device_regi... | [
20,
0
] | [
30,
17
] | python | en | ['es', 'nl', 'en'] | False |
test_get_or_create_returns_same_entry | (hass, registry, update_events) | Make sure we do not duplicate entries. | Make sure we do not duplicate entries. | async def test_get_or_create_returns_same_entry(hass, registry, update_events):
"""Make sure we do not duplicate entries."""
entry = registry.async_get_or_create(
config_entry_id="1234",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("bridgeid"... | [
"async",
"def",
"test_get_or_create_returns_same_entry",
"(",
"hass",
",",
"registry",
",",
"update_events",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"1234\"",
",",
"connections",
"=",
"{",
"(",
"device_registry"... | [
33,
0
] | [
73,
52
] | python | en | ['en', 'en', 'en'] | True |
test_requirement_for_identifier_or_connection | (registry) | Make sure we do require some descriptor of device. | Make sure we do require some descriptor of device. | async def test_requirement_for_identifier_or_connection(registry):
"""Make sure we do require some descriptor of device."""
entry = registry.async_get_or_create(
config_entry_id="1234",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers=set(),
... | [
"async",
"def",
"test_requirement_for_identifier_or_connection",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"1234\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"CONNECTION_NETWORK_MAC"... | [
76,
0
] | [
103,
25
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_config_entries | (registry) | Make sure we do not get duplicate entries. | Make sure we do not get duplicate entries. | async def test_multiple_config_entries(registry):
"""Make sure we do not get duplicate entries."""
entry = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("bridgeid", "0123")},
manufac... | [
"async",
"def",
"test_multiple_config_entries",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"CONNECTION_NETWORK_MAC",
",",
"\"12:3... | [
106,
0
] | [
133,
50
] | python | en | ['en', 'en', 'en'] | True |
test_loading_from_storage | (hass, hass_storage) | Test loading stored devices on start. | Test loading stored devices on start. | async def test_loading_from_storage(hass, hass_storage):
"""Test loading stored devices on start."""
hass_storage[device_registry.STORAGE_KEY] = {
"version": device_registry.STORAGE_VERSION,
"data": {
"devices": [
{
"config_entries": ["1234"],
... | [
"async",
"def",
"test_loading_from_storage",
"(",
"hass",
",",
"hass_storage",
")",
":",
"hass_storage",
"[",
"device_registry",
".",
"STORAGE_KEY",
"]",
"=",
"{",
"\"version\"",
":",
"device_registry",
".",
"STORAGE_VERSION",
",",
"\"data\"",
":",
"{",
"\"devices... | [
136,
0
] | [
196,
45
] | python | en | ['en', 'en', 'en'] | True |
test_removing_config_entries | (hass, registry, update_events) | Make sure we do not get duplicate entries. | Make sure we do not get duplicate entries. | async def test_removing_config_entries(hass, registry, update_events):
"""Make sure we do not get duplicate entries."""
entry = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("bridgeid", "012... | [
"async",
"def",
"test_removing_config_entries",
"(",
"hass",
",",
"registry",
",",
"update_events",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
... | [
199,
0
] | [
247,
53
] | python | en | ['en', 'en', 'en'] | True |
test_deleted_device_removing_config_entries | (hass, registry, update_events) | Make sure we do not get duplicate entries. | Make sure we do not get duplicate entries. | async def test_deleted_device_removing_config_entries(hass, registry, update_events):
"""Make sure we do not get duplicate entries."""
entry = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("... | [
"async",
"def",
"test_deleted_device_removing_config_entries",
"(",
"hass",
",",
"registry",
",",
"update_events",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_regi... | [
250,
0
] | [
320,
32
] | python | en | ['en', 'en', 'en'] | True |
test_removing_area_id | (registry) | Make sure we can clear area id. | Make sure we can clear area id. | async def test_removing_area_id(registry):
"""Make sure we can clear area id."""
entry = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("bridgeid", "0123")},
manufacturer="manufacture... | [
"async",
"def",
"test_removing_area_id",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"CONNECTION_NETWORK_MAC",
",",
"\"12:34:56:AB... | [
323,
0
] | [
339,
40
] | python | en | ['en', 'en', 'en'] | True |
test_deleted_device_removing_area_id | (registry) | Make sure we can clear area id of deleted device. | Make sure we can clear area id of deleted device. | async def test_deleted_device_removing_area_id(registry):
"""Make sure we can clear area id of deleted device."""
entry = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("bridgeid", "0123")},
... | [
"async",
"def",
"test_deleted_device_removing_area_id",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"CONNECTION_NETWORK_MAC",
",",
... | [
342,
0
] | [
369,
40
] | python | en | ['en', 'en', 'en'] | True |
test_specifying_via_device_create | (registry) | Test specifying a via_device and updating. | Test specifying a via_device and updating. | async def test_specifying_via_device_create(registry):
"""Test specifying a via_device and updating."""
via = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("hue", "0123")},
manufactu... | [
"async",
"def",
"test_specifying_via_device_create",
"(",
"registry",
")",
":",
"via",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"CONNECTION_NETWORK_MAC",
",",
"\"1... | [
372,
0
] | [
391,
40
] | python | en | ['en', 'en', 'en'] | True |
test_specifying_via_device_update | (registry) | Test specifying a via_device and updating. | Test specifying a via_device and updating. | async def test_specifying_via_device_update(registry):
"""Test specifying a via_device and updating."""
light = registry.async_get_or_create(
config_entry_id="456",
connections=set(),
identifiers={("hue", "456")},
manufacturer="manufacturer",
model="light",
via_de... | [
"async",
"def",
"test_specifying_via_device_update",
"(",
"registry",
")",
":",
"light",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"456\"",
",",
"connections",
"=",
"set",
"(",
")",
",",
"identifiers",
"=",
"{",
"(",
"\"hue\"",
... | [
394,
0
] | [
424,
40
] | python | en | ['en', 'en', 'en'] | True |
test_loading_saving_data | (hass, registry) | Test that we load/save data correctly. | Test that we load/save data correctly. | async def test_loading_saving_data(hass, registry):
"""Test that we load/save data correctly."""
orig_via = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("hue", "0123")},
manufacture... | [
"async",
"def",
"test_loading_saving_data",
"(",
"hass",
",",
"registry",
")",
":",
"orig_via",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"CONNECTION_NETWORK_MAC",
... | [
427,
0
] | [
510,
36
] | python | en | ['en', 'en', 'en'] | True |
test_no_unnecessary_changes | (registry) | Make sure we do not consider devices changes. | Make sure we do not consider devices changes. | async def test_no_unnecessary_changes(registry):
"""Make sure we do not consider devices changes."""
entry = registry.async_get_or_create(
config_entry_id="1234",
connections={("ethernet", "12:34:56:78:90:AB:CD:EF")},
identifiers={("hue", "456"), ("bla", "123")},
)
with patch(
... | [
"async",
"def",
"test_no_unnecessary_changes",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"1234\"",
",",
"connections",
"=",
"{",
"(",
"\"ethernet\"",
",",
"\"12:34:56:78:90:AB:CD:EF\"",
")",
"}",
... | [
513,
0
] | [
528,
41
] | python | en | ['en', 'en', 'en'] | True |
test_format_mac | (registry) | Make sure we normalize mac addresses. | Make sure we normalize mac addresses. | async def test_format_mac(registry):
"""Make sure we normalize mac addresses."""
entry = registry.async_get_or_create(
config_entry_id="1234",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
)
for mac in ["123456ABCDEF", "123456abcdef", "12:34:56:ab:cd:ef", "... | [
"async",
"def",
"test_format_mac",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"1234\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"CONNECTION_NETWORK_MAC",
",",
"\"12:34:56:AB:CD:E... | [
531,
0
] | [
560,
67
] | python | en | ['en', 'da', 'en'] | True |
test_update | (registry) | Verify that we can update some attributes of a device. | Verify that we can update some attributes of a device. | async def test_update(registry):
"""Verify that we can update some attributes of a device."""
entry = registry.async_get_or_create(
config_entry_id="1234",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("hue", "456"), ("bla", "123")},
)
... | [
"async",
"def",
"test_update",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"1234\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"CONNECTION_NETWORK_MAC",
",",
"\"12:34:56:AB:CD:EF\""... | [
563,
0
] | [
607,
59
] | python | en | ['en', 'en', 'en'] | True |
test_update_remove_config_entries | (hass, registry, update_events) | Make sure we do not get duplicate entries. | Make sure we do not get duplicate entries. | async def test_update_remove_config_entries(hass, registry, update_events):
"""Make sure we do not get duplicate entries."""
entry = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("bridgeid",... | [
"async",
"def",
"test_update_remove_config_entries",
"(",
"hass",
",",
"registry",
",",
"update_events",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
"... | [
610,
0
] | [
665,
53
] | python | en | ['en', 'en', 'en'] | True |
test_loading_race_condition | (hass) | Test only one storage load called when concurrent loading occurred . | Test only one storage load called when concurrent loading occurred . | async def test_loading_race_condition(hass):
"""Test only one storage load called when concurrent loading occurred ."""
with patch(
"homeassistant.helpers.device_registry.DeviceRegistry.async_load"
) as mock_load:
results = await asyncio.gather(
device_registry.async_get_registry... | [
"async",
"def",
"test_loading_race_condition",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.helpers.device_registry.DeviceRegistry.async_load\"",
")",
"as",
"mock_load",
":",
"results",
"=",
"await",
"asyncio",
".",
"gather",
"(",
"device_registry",
"."... | [
668,
0
] | [
679,
39
] | python | en | ['en', 'en', 'en'] | True |
test_update_sw_version | (registry) | Verify that we can update software version of a device. | Verify that we can update software version of a device. | async def test_update_sw_version(registry):
"""Verify that we can update software version of a device."""
entry = registry.async_get_or_create(
config_entry_id="1234",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("bla", "123")},
)
ass... | [
"async",
"def",
"test_update_sw_version",
"(",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"1234\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"CONNECTION_NETWORK_MAC",
",",
"\"12:34:56:... | [
682,
0
] | [
697,
49
] | python | en | ['en', 'en', 'en'] | True |
test_cleanup_device_registry | (hass, registry) | Test cleanup works. | Test cleanup works. | async def test_cleanup_device_registry(hass, registry):
"""Test cleanup works."""
config_entry = MockConfigEntry(domain="hue")
config_entry.add_to_hass(hass)
d1 = registry.async_get_or_create(
identifiers={("hue", "d1")}, config_entry_id=config_entry.entry_id
)
registry.async_get_or_cre... | [
"async",
"def",
"test_cleanup_device_registry",
"(",
"hass",
",",
"registry",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"hue\"",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"d1",
"=",
"registry",
".",
"async_get_or_cr... | [
700,
0
] | [
728,
74
] | python | en | ['nl', 'en', 'en'] | True |
test_cleanup_startup | (hass) | Test we run a cleanup on startup. | Test we run a cleanup on startup. | async def test_cleanup_startup(hass):
"""Test we run a cleanup on startup."""
hass.state = CoreState.not_running
await device_registry.async_get_registry(hass)
with patch(
"homeassistant.helpers.device_registry.Debouncer.async_call"
) as mock_call:
hass.bus.async_fire(EVENT_HOMEASSI... | [
"async",
"def",
"test_cleanup_startup",
"(",
"hass",
")",
":",
"hass",
".",
"state",
"=",
"CoreState",
".",
"not_running",
"await",
"device_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"with",
"patch",
"(",
"\"homeassistant.helpers.device_registry.Debouncer... | [
731,
0
] | [
742,
41
] | python | en | ['en', 'en', 'en'] | True |
test_cleanup_entity_registry_change | (hass) | Test we run a cleanup when entity registry changes. | Test we run a cleanup when entity registry changes. | async def test_cleanup_entity_registry_change(hass):
"""Test we run a cleanup when entity registry changes."""
await device_registry.async_get_registry(hass)
ent_reg = await entity_registry.async_get_registry(hass)
with patch(
"homeassistant.helpers.device_registry.Debouncer.async_call"
) a... | [
"async",
"def",
"test_cleanup_entity_registry_change",
"(",
"hass",
")",
":",
"await",
"device_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"ent_reg",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"with",
"patch",
"(",
"\... | [
745,
0
] | [
770,
45
] | python | en | ['en', 'en', 'en'] | True |
test_restore_device | (hass, registry, update_events) | Make sure device id is stable. | Make sure device id is stable. | async def test_restore_device(hass, registry, update_events):
"""Make sure device id is stable."""
entry = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("bridgeid", "0123")},
manufac... | [
"async",
"def",
"test_restore_device",
"(",
"hass",
",",
"registry",
",",
"update_events",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"CONNECT... | [
773,
0
] | [
825,
53
] | python | en | ['en', 'en', 'en'] | True |
test_restore_simple_device | (hass, registry, update_events) | Make sure device id is stable. | Make sure device id is stable. | async def test_restore_simple_device(hass, registry, update_events):
"""Make sure device id is stable."""
entry = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("bridgeid", "0123")},
)
... | [
"async",
"def",
"test_restore_simple_device",
"(",
"hass",
",",
"registry",
",",
"update_events",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"... | [
828,
0
] | [
870,
53
] | python | en | ['en', 'en', 'en'] | True |
test_restore_shared_device | (hass, registry, update_events) | Make sure device id is stable for shared devices. | Make sure device id is stable for shared devices. | async def test_restore_shared_device(hass, registry, update_events):
"""Make sure device id is stable for shared devices."""
entry = registry.async_get_or_create(
config_entry_id="123",
connections={(device_registry.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
identifiers={("entry_123"... | [
"async",
"def",
"test_restore_shared_device",
"(",
"hass",
",",
"registry",
",",
"update_events",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"123\"",
",",
"connections",
"=",
"{",
"(",
"device_registry",
".",
"... | [
873,
0
] | [
968,
52
] | python | en | ['en', 'en', 'en'] | True |
test_get_or_create_empty_then_set_default_values | (hass, registry) | Test creating an entry, then setting default name, model, manufacturer. | Test creating an entry, then setting default name, model, manufacturer. | async def test_get_or_create_empty_then_set_default_values(hass, registry):
"""Test creating an entry, then setting default name, model, manufacturer."""
entry = registry.async_get_or_create(
identifiers={("bridgeid", "0123")}, config_entry_id="1234"
)
assert entry.name is None
assert entry.... | [
"async",
"def",
"test_get_or_create_empty_then_set_default_values",
"(",
"hass",
",",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"identifiers",
"=",
"{",
"(",
"\"bridgeid\"",
",",
"\"0123\"",
")",
"}",
",",
"config_entry_id",
... | [
971,
0
] | [
1000,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_or_create_empty_then_update | (hass, registry) | Test creating an entry, then setting name, model, manufacturer. | Test creating an entry, then setting name, model, manufacturer. | async def test_get_or_create_empty_then_update(hass, registry):
"""Test creating an entry, then setting name, model, manufacturer."""
entry = registry.async_get_or_create(
identifiers={("bridgeid", "0123")}, config_entry_id="1234"
)
assert entry.name is None
assert entry.model is None
as... | [
"async",
"def",
"test_get_or_create_empty_then_update",
"(",
"hass",
",",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"identifiers",
"=",
"{",
"(",
"\"bridgeid\"",
",",
"\"0123\"",
")",
"}",
",",
"config_entry_id",
"=",
"\"12... | [
1003,
0
] | [
1032,
49
] | python | en | ['en', 'en', 'en'] | True |
test_get_or_create_sets_default_values | (hass, registry) | Test creating an entry, then setting default name, model, manufacturer. | Test creating an entry, then setting default name, model, manufacturer. | async def test_get_or_create_sets_default_values(hass, registry):
"""Test creating an entry, then setting default name, model, manufacturer."""
entry = registry.async_get_or_create(
config_entry_id="1234",
identifiers={("bridgeid", "0123")},
default_name="default name 1",
default... | [
"async",
"def",
"test_get_or_create_sets_default_values",
"(",
"hass",
",",
"registry",
")",
":",
"entry",
"=",
"registry",
".",
"async_get_or_create",
"(",
"config_entry_id",
"=",
"\"1234\"",
",",
"identifiers",
"=",
"{",
"(",
"\"bridgeid\"",
",",
"\"0123\"",
")"... | [
1035,
0
] | [
1057,
57
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.