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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
mock_config_entry | () | Return a Ruckus Unleashed mock config entry. | Return a Ruckus Unleashed mock config entry. | def mock_config_entry() -> MockConfigEntry:
"""Return a Ruckus Unleashed mock config entry."""
return MockConfigEntry(
domain=DOMAIN,
title=DEFAULT_TITLE,
unique_id=DEFAULT_UNIQUE_ID,
data=CONFIG,
options=None,
) | [
"def",
"mock_config_entry",
"(",
")",
"->",
"MockConfigEntry",
":",
"return",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"title",
"=",
"DEFAULT_TITLE",
",",
"unique_id",
"=",
"DEFAULT_UNIQUE_ID",
",",
"data",
"=",
"CONFIG",
",",
"options",
"=",
"Non... | [
55,
0
] | [
63,
5
] | python | en | ['en', 'da', 'en'] | True |
init_integration | (hass) | Set up the Ruckus Unleashed integration in Home Assistant. | Set up the Ruckus Unleashed integration in Home Assistant. | async def init_integration(hass) -> MockConfigEntry:
"""Set up the Ruckus Unleashed integration in Home Assistant."""
entry = mock_config_entry()
with patch(
"homeassistant.components.ruckus_unleashed.Ruckus.connect",
return_value=None,
), patch(
"homeassistant.components.ruckus_... | [
"async",
"def",
"init_integration",
"(",
"hass",
")",
"->",
"MockConfigEntry",
":",
"entry",
"=",
"mock_config_entry",
"(",
")",
"with",
"patch",
"(",
"\"homeassistant.components.ruckus_unleashed.Ruckus.connect\"",
",",
"return_value",
"=",
"None",
",",
")",
",",
"p... | [
66,
0
] | [
91,
16
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Defer sensor setup to the shared sensor module. | Defer sensor setup to the shared sensor module. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Defer sensor setup to the shared sensor module."""
coordinator = await get_coordinator(hass)
async_add_entities(
CoronavirusSensor(coordinator, config_entry.data["country"], info_type)
for info_type in SENSORS
) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"await",
"get_coordinator",
"(",
"hass",
")",
"async_add_entities",
"(",
"CoronavirusSensor",
"(",
"coordinator",
",",
"config_entry",
"."... | [
15,
0
] | [
22,
5
] | python | en | ['en', 'pt', 'en'] | True |
CoronavirusSensor.__init__ | (self, coordinator, country, info_type) | Initialize coronavirus sensor. | Initialize coronavirus sensor. | def __init__(self, coordinator, country, info_type):
"""Initialize coronavirus sensor."""
super().__init__(coordinator)
if country == OPTION_WORLDWIDE:
self.name = f"Worldwide Coronavirus {info_type}"
else:
self.name = f"{coordinator.data[country].country} Coronav... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"country",
",",
"info_type",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"if",
"country",
"==",
"OPTION_WORLDWIDE",
":",
"self",
".",
"name",
"=",
"f\"Worldwide Coronavirus {... | [
31,
4
] | [
40,
34
] | python | en | ['en', 'sn', 'it'] | False |
CoronavirusSensor.available | (self) | Return if sensor is available. | Return if sensor is available. | def available(self):
"""Return if sensor is available."""
return self.coordinator.last_update_success and (
self.country in self.coordinator.data or self.country == OPTION_WORLDWIDE
) | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"last_update_success",
"and",
"(",
"self",
".",
"country",
"in",
"self",
".",
"coordinator",
".",
"data",
"or",
"self",
".",
"country",
"==",
"OPTION_WORLDWIDE",
")"
] | [
43,
4
] | [
47,
9
] | python | en | ['en', 'en', 'en'] | True |
CoronavirusSensor.state | (self) | State of the sensor. | State of the sensor. | def state(self):
"""State of the sensor."""
if self.country == OPTION_WORLDWIDE:
sum_cases = 0
for case in self.coordinator.data.values():
value = getattr(case, self.info_type)
if value is None:
continue
sum_case... | [
"def",
"state",
"(",
"self",
")",
":",
"if",
"self",
".",
"country",
"==",
"OPTION_WORLDWIDE",
":",
"sum_cases",
"=",
"0",
"for",
"case",
"in",
"self",
".",
"coordinator",
".",
"data",
".",
"values",
"(",
")",
":",
"value",
"=",
"getattr",
"(",
"case... | [
50,
4
] | [
62,
75
] | python | en | ['en', 'en', 'en'] | True |
CoronavirusSensor.icon | (self) | Return the icon. | Return the icon. | def icon(self):
"""Return the icon."""
return SENSORS[self.info_type] | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"SENSORS",
"[",
"self",
".",
"info_type",
"]"
] | [
65,
4
] | [
67,
38
] | python | en | ['en', 'sr', 'en'] | True |
CoronavirusSensor.unit_of_measurement | (self) | Return unit of measurement. | Return unit of measurement. | def unit_of_measurement(self):
"""Return unit of measurement."""
return "people" | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"\"people\""
] | [
70,
4
] | [
72,
23
] | python | en | ['en', 'la', 'en'] | True |
CoronavirusSensor.device_state_attributes | (self) | Return device attributes. | Return device attributes. | def device_state_attributes(self):
"""Return device attributes."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}"
] | [
75,
4
] | [
77,
46
] | python | en | ['es', 'mt', 'en'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the REST binary sensor. | Set up the REST binary sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the REST binary sensor."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
name = config.get(CONF_NAME)
resource = config.get(CONF_RESOURCE)
resource_template = config.get(CONF_RESOURCE_TEMPL... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATFORMS",
")",
"name",
"=",
"config",
".",
"... | [
67,
0
] | [
122,
5
] | python | en | ['en', 'cs', 'en'] | True |
RestBinarySensor.__init__ | (
self,
hass,
rest,
name,
device_class,
value_template,
force_update,
resource_template,
) | Initialize a REST binary sensor. | Initialize a REST binary sensor. | def __init__(
self,
hass,
rest,
name,
device_class,
value_template,
force_update,
resource_template,
):
"""Initialize a REST binary sensor."""
self._hass = hass
self.rest = rest
self._name = name
self._device_cla... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"rest",
",",
"name",
",",
"device_class",
",",
"value_template",
",",
"force_update",
",",
"resource_template",
",",
")",
":",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"rest",
"=",
"rest",
"self",
... | [
128,
4
] | [
147,
51
] | python | en | ['en', 'pl', 'en'] | True |
RestBinarySensor.name | (self) | Return the name of the binary sensor. | Return the name of the binary sensor. | def name(self):
"""Return the name of the binary sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
150,
4
] | [
152,
25
] | python | en | ['en', 'mi', 'en'] | True |
RestBinarySensor.device_class | (self) | Return the class of this sensor. | Return the class of this sensor. | def device_class(self):
"""Return the class of this sensor."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
155,
4
] | [
157,
33
] | python | en | ['en', 'en', 'en'] | True |
RestBinarySensor.available | (self) | Return the availability of this sensor. | Return the availability of this sensor. | def available(self):
"""Return the availability of this sensor."""
return self.rest.data is not None | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"rest",
".",
"data",
"is",
"not",
"None"
] | [
160,
4
] | [
162,
41
] | python | en | ['en', 'en', 'en'] | True |
RestBinarySensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self):
"""Return true if the binary sensor is on."""
if self.rest.data is None:
return False
response = self.rest.data
if self._value_template is not None:
response = self._value_template.async_render_with_possible_json_value(
self.rest... | [
"def",
"is_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"rest",
".",
"data",
"is",
"None",
":",
"return",
"False",
"response",
"=",
"self",
".",
"rest",
".",
"data",
"if",
"self",
".",
"_value_template",
"is",
"not",
"None",
":",
"response",
"=",
... | [
165,
4
] | [
182,
13
] | python | en | ['en', 'fy', 'en'] | True |
RestBinarySensor.force_update | (self) | Force update. | Force update. | def force_update(self):
"""Force update."""
return self._force_update | [
"def",
"force_update",
"(",
"self",
")",
":",
"return",
"self",
".",
"_force_update"
] | [
185,
4
] | [
187,
33
] | python | en | ['en', 'en', 'en'] | False |
RestBinarySensor.async_will_remove_from_hass | (self) | Shutdown the session. | Shutdown the session. | async def async_will_remove_from_hass(self):
"""Shutdown the session."""
await self.rest.async_remove() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"await",
"self",
".",
"rest",
".",
"async_remove",
"(",
")"
] | [
189,
4
] | [
191,
38
] | python | en | ['en', 'bg-Latn', 'en'] | True |
RestBinarySensor.async_update | (self) | Get the latest data from REST API and updates the state. | Get the latest data from REST API and updates the state. | async def async_update(self):
"""Get the latest data from REST API and updates the state."""
if self._resource_template is not None:
self.rest.set_url(self._resource_template.async_render(parse_result=False))
await self.rest.async_update() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resource_template",
"is",
"not",
"None",
":",
"self",
".",
"rest",
".",
"set_url",
"(",
"self",
".",
"_resource_template",
".",
"async_render",
"(",
"parse_result",
"=",
"False",
"... | [
193,
4
] | [
198,
38
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Pencom relay platform (pencompy). | Pencom relay platform (pencompy). | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Pencom relay platform (pencompy)."""
# Assign configuration variables.
host = config[CONF_HOST]
port = config[CONF_PORT]
boards = config[CONF_BOARDS]
# Setup connection
try:
hub = Pencompy(host, port, boards=bo... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"# Assign configuration variables.",
"host",
"=",
"config",
"[",
"CONF_HOST",
"]",
"port",
"=",
"config",
"[",
"CONF_PORT",
"]",
"boards",
"... | [
36,
0
] | [
58,
28
] | python | en | ['en', 'pt', 'en'] | True |
PencomRelay.__init__ | (self, hub, board, addr, name) | Create a relay. | Create a relay. | def __init__(self, hub, board, addr, name):
"""Create a relay."""
self._hub = hub
self._board = board
self._addr = addr
self._name = name
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"hub",
",",
"board",
",",
"addr",
",",
"name",
")",
":",
"self",
".",
"_hub",
"=",
"hub",
"self",
".",
"_board",
"=",
"board",
"self",
".",
"_addr",
"=",
"addr",
"self",
".",
"_name",
"=",
"name",
"self",
".",... | [
64,
4
] | [
70,
26
] | python | en | ['en', 'gd', 'en'] | True |
PencomRelay.name | (self) | Relay name. | Relay name. | def name(self):
"""Relay name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
73,
4
] | [
75,
25
] | python | en | ['en', 'mi', 'en'] | False |
PencomRelay.is_on | (self) | Return a relay's state. | Return a relay's state. | def is_on(self):
"""Return a relay's state."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
78,
4
] | [
80,
26
] | python | en | ['en', 'en', 'en'] | True |
PencomRelay.turn_on | (self, **kwargs) | Turn a relay on. | Turn a relay on. | def turn_on(self, **kwargs):
"""Turn a relay on."""
self._hub.set(self._board, self._addr, True) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_hub",
".",
"set",
"(",
"self",
".",
"_board",
",",
"self",
".",
"_addr",
",",
"True",
")"
] | [
82,
4
] | [
84,
52
] | python | en | ['en', 'en', 'en'] | True |
PencomRelay.turn_off | (self, **kwargs) | Turn a relay off. | Turn a relay off. | def turn_off(self, **kwargs):
"""Turn a relay off."""
self._hub.set(self._board, self._addr, False) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_hub",
".",
"set",
"(",
"self",
".",
"_board",
",",
"self",
".",
"_addr",
",",
"False",
")"
] | [
86,
4
] | [
88,
53
] | python | en | ['en', 'en', 'en'] | True |
PencomRelay.update | (self) | Refresh a relay's state. | Refresh a relay's state. | def update(self):
"""Refresh a relay's state."""
self._state = self._hub.get(self._board, self._addr) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_hub",
".",
"get",
"(",
"self",
".",
"_board",
",",
"self",
".",
"_addr",
")"
] | [
90,
4
] | [
92,
60
] | python | en | ['en', 'en', 'en'] | True |
PencomRelay.device_state_attributes | (self) | Return supported attributes. | Return supported attributes. | def device_state_attributes(self):
"""Return supported attributes."""
return {"board": self._board, "addr": self._addr} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"board\"",
":",
"self",
".",
"_board",
",",
"\"addr\"",
":",
"self",
".",
"_addr",
"}"
] | [
95,
4
] | [
97,
57
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprCloudSetup.setup_method | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant() | [
"def",
"setup_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")"
] | [
16,
4
] | [
18,
45
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprCloudSetup.teardown_method | (self) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
20,
4
] | [
22,
24
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprCloudSetup.test_setup_platform | (self) | Set up platform with one entity. | Set up platform with one entity. | def test_setup_platform(self):
"""Set up platform with one entity."""
config = {
ip.DOMAIN: {
"platform": "openalpr_cloud",
"source": {"entity_id": "camera.demo_camera"},
"region": "eu",
"api_key": "sk_abcxyz123456",
... | [
"def",
"test_setup_platform",
"(",
"self",
")",
":",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"openalpr_cloud\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\"camera.demo_camera\"",
"}",
",",
"\"region\"",
":",
"\"eu\"... | [
24,
4
] | [
40,
76
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprCloudSetup.test_setup_platform_name | (self) | Set up platform with one entity and set name. | Set up platform with one entity and set name. | def test_setup_platform_name(self):
"""Set up platform with one entity and set name."""
config = {
ip.DOMAIN: {
"platform": "openalpr_cloud",
"source": {"entity_id": "camera.demo_camera", "name": "test local"},
"region": "eu",
"... | [
"def",
"test_setup_platform_name",
"(",
"self",
")",
":",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"openalpr_cloud\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\"camera.demo_camera\"",
",",
"\"name\"",
":",
"\"test loc... | [
42,
4
] | [
58,
66
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprCloudSetup.test_setup_platform_without_api_key | (self) | Set up platform with one entity without api_key. | Set up platform with one entity without api_key. | def test_setup_platform_without_api_key(self):
"""Set up platform with one entity without api_key."""
config = {
ip.DOMAIN: {
"platform": "openalpr_cloud",
"source": {"entity_id": "camera.demo_camera"},
"region": "eu",
},
... | [
"def",
"test_setup_platform_without_api_key",
"(",
"self",
")",
":",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"openalpr_cloud\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\"camera.demo_camera\"",
"}",
",",
"\"region\"",
... | [
60,
4
] | [
72,
57
] | python | en | ['en', 'zu', 'en'] | True |
TestOpenAlprCloudSetup.test_setup_platform_without_region | (self) | Set up platform with one entity without region. | Set up platform with one entity without region. | def test_setup_platform_without_region(self):
"""Set up platform with one entity without region."""
config = {
ip.DOMAIN: {
"platform": "openalpr_cloud",
"source": {"entity_id": "camera.demo_camera"},
"api_key": "sk_abcxyz123456",
}... | [
"def",
"test_setup_platform_without_region",
"(",
"self",
")",
":",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"openalpr_cloud\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\"camera.demo_camera\"",
"}",
",",
"\"api_key\"",
... | [
74,
4
] | [
86,
57
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprCloud.setup_method | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
config = {
ip.DOMAIN: {
"platform": "openalpr_cloud",
"source": {"entity_id": "camera.demo_camera", "name": "test local"},
... | [
"def",
"setup_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"openalpr_cloud\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\... | [
92,
4
] | [
128,
9
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprCloud.teardown_method | (self) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
130,
4
] | [
132,
24
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprCloud.test_openalpr_process_image | (self, aioclient_mock) | Set up and scan a picture and test plates from event. | Set up and scan a picture and test plates from event. | def test_openalpr_process_image(self, aioclient_mock):
"""Set up and scan a picture and test plates from event."""
aioclient_mock.post(
OPENALPR_API_URL,
params=self.params,
text=load_fixture("alpr_cloud.json"),
status=200,
)
with patch(
... | [
"def",
"test_openalpr_process_image",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"OPENALPR_API_URL",
",",
"params",
"=",
"self",
".",
"params",
",",
"text",
"=",
"load_fixture",
"(",
"\"alpr_cloud.json\"",
")",
",",
"status... | [
134,
4
] | [
165,
74
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprCloud.test_openalpr_process_image_api_error | (self, aioclient_mock) | Set up and scan a picture and test api error. | Set up and scan a picture and test api error. | def test_openalpr_process_image_api_error(self, aioclient_mock):
"""Set up and scan a picture and test api error."""
aioclient_mock.post(
OPENALPR_API_URL,
params=self.params,
text="{'error': 'error message'}",
status=400,
)
with patch(
... | [
"def",
"test_openalpr_process_image_api_error",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"OPENALPR_API_URL",
",",
"params",
"=",
"self",
".",
"params",
",",
"text",
"=",
"\"{'error': 'error message'}\"",
",",
"status",
"=",
... | [
167,
4
] | [
184,
41
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprCloud.test_openalpr_process_image_api_timeout | (self, aioclient_mock) | Set up and scan a picture and test api error. | Set up and scan a picture and test api error. | def test_openalpr_process_image_api_timeout(self, aioclient_mock):
"""Set up and scan a picture and test api error."""
aioclient_mock.post(
OPENALPR_API_URL, params=self.params, exc=asyncio.TimeoutError()
)
with patch(
"homeassistant.components.camera.async_get_i... | [
"def",
"test_openalpr_process_image_api_timeout",
"(",
"self",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"OPENALPR_API_URL",
",",
"params",
"=",
"self",
".",
"params",
",",
"exc",
"=",
"asyncio",
".",
"TimeoutError",
"(",
")",
")",
"... | [
186,
4
] | [
200,
41
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the simulated sensor. | Set up the simulated sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the simulated sensor."""
name = config.get(CONF_NAME)
unit = config.get(CONF_UNIT)
amp = config.get(CONF_AMP)
mean = config.get(CONF_MEAN)
period = config.get(CONF_PERIOD)
phase = config.get(CONF_PHASE)
fwhm =... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"unit",
"=",
"config",
".",
"get",
"(",
"CONF_UNIT",
")",
"amp",
"=",
"con... | [
51,
0
] | [
66,
32
] | python | en | ['en', 'haw', 'en'] | True |
SimulatedSensor.__init__ | (
self, name, unit, amp, mean, period, phase, fwhm, seed, relative_to_epoch
) | Init the class. | Init the class. | def __init__(
self, name, unit, amp, mean, period, phase, fwhm, seed, relative_to_epoch
):
"""Init the class."""
self._name = name
self._unit = unit
self._amp = amp
self._mean = mean
self._period = period
self._phase = phase # phase in degrees
... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"unit",
",",
"amp",
",",
"mean",
",",
"period",
",",
"phase",
",",
"fwhm",
",",
"seed",
",",
"relative_to_epoch",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_unit",
"=",
"unit",
"sel... | [
72,
4
] | [
91,
26
] | python | en | ['en', 'en', 'en'] | True |
SimulatedSensor.time_delta | (self) | Return the time delta. | Return the time delta. | def time_delta(self):
"""Return the time delta."""
dt0 = self._start_time
dt1 = dt_util.utcnow()
return dt1 - dt0 | [
"def",
"time_delta",
"(",
"self",
")",
":",
"dt0",
"=",
"self",
".",
"_start_time",
"dt1",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"return",
"dt1",
"-",
"dt0"
] | [
93,
4
] | [
97,
24
] | python | en | ['en', 'en', 'en'] | True |
SimulatedSensor.signal_calc | (self) | Calculate the signal. | Calculate the signal. | def signal_calc(self):
"""Calculate the signal."""
mean = self._mean
amp = self._amp
time_delta = self.time_delta().total_seconds() * 1e6 # to milliseconds
period = self._period * 1e6 # to milliseconds
fwhm = self._fwhm / 2
phase = math.radians(self._phase)
... | [
"def",
"signal_calc",
"(",
"self",
")",
":",
"mean",
"=",
"self",
".",
"_mean",
"amp",
"=",
"self",
".",
"_amp",
"time_delta",
"=",
"self",
".",
"time_delta",
"(",
")",
".",
"total_seconds",
"(",
")",
"*",
"1e6",
"# to milliseconds",
"period",
"=",
"se... | [
99,
4
] | [
112,
48
] | python | en | ['en', 'en', 'en'] | True |
SimulatedSensor.async_update | (self) | Update the sensor. | Update the sensor. | async def async_update(self):
"""Update the sensor."""
self._state = self.signal_calc() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"self",
".",
"_state",
"=",
"self",
".",
"signal_calc",
"(",
")"
] | [
114,
4
] | [
116,
40
] | python | en | ['en', 'nl', 'en'] | True |
SimulatedSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
119,
4
] | [
121,
25
] | python | en | ['en', 'mi', 'en'] | True |
SimulatedSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
124,
4
] | [
126,
26
] | python | en | ['en', 'en', 'en'] | True |
SimulatedSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
129,
4
] | [
131,
19
] | python | en | ['en', 'en', 'en'] | True |
SimulatedSensor.unit_of_measurement | (self) | Return the unit this state is expressed in. | Return the unit this state is expressed in. | def unit_of_measurement(self):
"""Return the unit this state is expressed in."""
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit"
] | [
134,
4
] | [
136,
25
] | python | en | ['en', 'en', 'en'] | True |
SimulatedSensor.device_state_attributes | (self) | Return other details about the sensor state. | Return other details about the sensor state. | def device_state_attributes(self):
"""Return other details about the sensor state."""
return {
"amplitude": self._amp,
"mean": self._mean,
"period": self._period,
"phase": self._phase,
"spread": self._fwhm,
"seed": self._seed,
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"amplitude\"",
":",
"self",
".",
"_amp",
",",
"\"mean\"",
":",
"self",
".",
"_mean",
",",
"\"period\"",
":",
"self",
".",
"_period",
",",
"\"phase\"",
":",
"self",
".",
"_phase",
"... | [
139,
4
] | [
149,
9
] | python | en | ['en', 'en', 'en'] | True |
retry | (fn: Callable, timeout: int = 900) | Call the given function repeatedly, with 1 second intervals,
until it returns True or a timeout is reached.
| Call the given function repeatedly, with 1 second intervals,
until it returns True or a timeout is reached.
| def retry(fn: Callable, timeout: int = 900) -> None:
"""Call the given function repeatedly, with 1 second intervals,
until it returns True or a timeout is reached.
"""
for _ in range(timeout):
if fn(False):
return
time.sleep(1)
if not fn(True):
raise Exception(f... | [
"def",
"retry",
"(",
"fn",
":",
"Callable",
",",
"timeout",
":",
"int",
"=",
"900",
")",
"->",
"None",
":",
"for",
"_",
"in",
"range",
"(",
"timeout",
")",
":",
"if",
"fn",
"(",
"False",
")",
":",
"return",
"time",
".",
"sleep",
"(",
"1",
")",
... | [
131,
0
] | [
142,
68
] | python | en | ['en', 'en', 'en'] | True |
Machine.wait_for_unit | (self, unit: str, user: Optional[str] = None) | Wait for a systemd unit to get into "active" state.
Throws exceptions on "failed" and "inactive" states as well as
after timing out.
| Wait for a systemd unit to get into "active" state.
Throws exceptions on "failed" and "inactive" states as well as
after timing out.
| def wait_for_unit(self, unit: str, user: Optional[str] = None) -> None:
"""Wait for a systemd unit to get into "active" state.
Throws exceptions on "failed" and "inactive" states as well as
after timing out.
"""
def check_active(_: Any) -> bool:
info = self.get_unit_... | [
"def",
"wait_for_unit",
"(",
"self",
",",
"unit",
":",
"str",
",",
"user",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"def",
"check_active",
"(",
"_",
":",
"Any",
")",
"->",
"bool",
":",
"info",
"=",
"self",
".",
"get_... | [
367,
4
] | [
392,
27
] | python | en | ['en', 'en', 'en'] | True |
Machine.shell_interact | (self) | Allows you to interact with the guest shell
Should only be used during test development, not in the production test. | Allows you to interact with the guest shell | def shell_interact(self) -> None:
"""Allows you to interact with the guest shell
Should only be used during test development, not in the production test."""
self.connect()
self.log("Terminal is ready (there is no prompt):")
subprocess.run(
["socat", "READLINE", f"FD:... | [
"def",
"shell_interact",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"connect",
"(",
")",
"self",
".",
"log",
"(",
"\"Terminal is ready (there is no prompt):\"",
")",
"subprocess",
".",
"run",
"(",
"[",
"\"socat\"",
",",
"\"READLINE\"",
",",
"f\"FD:{self... | [
458,
4
] | [
467,
9
] | python | en | ['en', 'en', 'en'] | True |
Machine.succeed | (self, *commands: str) | Execute each command and check that it succeeds. | Execute each command and check that it succeeds. | def succeed(self, *commands: str) -> str:
"""Execute each command and check that it succeeds."""
output = ""
for command in commands:
with self.nested("must succeed: {}".format(command)):
(status, out) = self.execute(command)
if status != 0:
... | [
"def",
"succeed",
"(",
"self",
",",
"*",
"commands",
":",
"str",
")",
"->",
"str",
":",
"output",
"=",
"\"\"",
"for",
"command",
"in",
"commands",
":",
"with",
"self",
".",
"nested",
"(",
"\"must succeed: {}\"",
".",
"format",
"(",
"command",
")",
")",... | [
469,
4
] | [
481,
21
] | python | en | ['en', 'en', 'en'] | True |
Machine.fail | (self, *commands: str) | Execute each command and check that it fails. | Execute each command and check that it fails. | def fail(self, *commands: str) -> str:
"""Execute each command and check that it fails."""
output = ""
for command in commands:
with self.nested("must fail: {}".format(command)):
(status, out) = self.execute(command)
if status == 0:
... | [
"def",
"fail",
"(",
"self",
",",
"*",
"commands",
":",
"str",
")",
"->",
"str",
":",
"output",
"=",
"\"\"",
"for",
"command",
"in",
"commands",
":",
"with",
"self",
".",
"nested",
"(",
"\"must fail: {}\"",
".",
"format",
"(",
"command",
")",
")",
":"... | [
483,
4
] | [
494,
21
] | python | en | ['en', 'en', 'en'] | True |
Machine.wait_until_succeeds | (self, command: str) | Wait until a command returns success and return its output.
Throws an exception on timeout.
| Wait until a command returns success and return its output.
Throws an exception on timeout.
| def wait_until_succeeds(self, command: str) -> str:
"""Wait until a command returns success and return its output.
Throws an exception on timeout.
"""
output = ""
def check_success(_: Any) -> bool:
nonlocal output
status, output = self.execute(command)
... | [
"def",
"wait_until_succeeds",
"(",
"self",
",",
"command",
":",
"str",
")",
"->",
"str",
":",
"output",
"=",
"\"\"",
"def",
"check_success",
"(",
"_",
":",
"Any",
")",
"->",
"bool",
":",
"nonlocal",
"output",
"status",
",",
"output",
"=",
"self",
".",
... | [
496,
4
] | [
509,
25
] | python | en | ['en', 'fr', 'en'] | True |
Machine.wait_until_fails | (self, command: str) | Wait until a command returns failure.
Throws an exception on timeout.
| Wait until a command returns failure.
Throws an exception on timeout.
| def wait_until_fails(self, command: str) -> str:
"""Wait until a command returns failure.
Throws an exception on timeout.
"""
output = ""
def check_failure(_: Any) -> bool:
nonlocal output
status, output = self.execute(command)
return status !... | [
"def",
"wait_until_fails",
"(",
"self",
",",
"command",
":",
"str",
")",
"->",
"str",
":",
"output",
"=",
"\"\"",
"def",
"check_failure",
"(",
"_",
":",
"Any",
")",
"->",
"bool",
":",
"nonlocal",
"output",
"status",
",",
"output",
"=",
"self",
".",
"... | [
511,
4
] | [
524,
25
] | python | en | ['en', 'fr', 'en'] | True |
Machine.wait_until_tty_matches | (self, tty: str, regexp: str) | Wait until the visible output on the chosen TTY matches regular
expression. Throws an exception on timeout.
| Wait until the visible output on the chosen TTY matches regular
expression. Throws an exception on timeout.
| def wait_until_tty_matches(self, tty: str, regexp: str) -> None:
"""Wait until the visible output on the chosen TTY matches regular
expression. Throws an exception on timeout.
"""
matcher = re.compile(regexp)
def tty_matches(last: bool) -> bool:
text = self.get_tty_t... | [
"def",
"wait_until_tty_matches",
"(",
"self",
",",
"tty",
":",
"str",
",",
"regexp",
":",
"str",
")",
"->",
"None",
":",
"matcher",
"=",
"re",
".",
"compile",
"(",
"regexp",
")",
"def",
"tty_matches",
"(",
"last",
":",
"bool",
")",
"->",
"bool",
":",... | [
545,
4
] | [
561,
30
] | python | en | ['en', 'en', 'en'] | True |
Machine.wait_for_file | (self, filename: str) | Waits until the file exists in machine's file system. | Waits until the file exists in machine's file system. | def wait_for_file(self, filename: str) -> None:
"""Waits until the file exists in machine's file system."""
def check_file(_: Any) -> bool:
status, _ = self.execute("test -e {}".format(filename))
return status == 0
with self.nested("waiting for file ‘{}‘".format(filenam... | [
"def",
"wait_for_file",
"(",
"self",
",",
"filename",
":",
"str",
")",
"->",
"None",
":",
"def",
"check_file",
"(",
"_",
":",
"Any",
")",
"->",
"bool",
":",
"status",
",",
"_",
"=",
"self",
".",
"execute",
"(",
"\"test -e {}\"",
".",
"format",
"(",
... | [
568,
4
] | [
576,
29
] | python | en | ['en', 'en', 'en'] | True |
Machine.copy_from_host_via_shell | (self, source: str, target: str) | Copy a file from the host into the guest by piping it over the
shell into the destination file. Works without host-guest shared folder.
Prefer copy_from_host for whenever possible.
| Copy a file from the host into the guest by piping it over the
shell into the destination file. Works without host-guest shared folder.
Prefer copy_from_host for whenever possible.
| def copy_from_host_via_shell(self, source: str, target: str) -> None:
"""Copy a file from the host into the guest by piping it over the
shell into the destination file. Works without host-guest shared folder.
Prefer copy_from_host for whenever possible.
"""
with open(source, "rb"... | [
"def",
"copy_from_host_via_shell",
"(",
"self",
",",
"source",
":",
"str",
",",
"target",
":",
"str",
")",
"->",
"None",
":",
"with",
"open",
"(",
"source",
",",
"\"rb\"",
")",
"as",
"fh",
":",
"content_b64",
"=",
"base64",
".",
"b64encode",
"(",
"fh",... | [
635,
4
] | [
645,
13
] | python | en | ['en', 'en', 'en'] | True |
Machine.copy_from_host | (self, source: str, target: str) | Copy a file from the host into the guest via the `shared_dir` shared
among all the VMs (using a temporary directory).
| Copy a file from the host into the guest via the `shared_dir` shared
among all the VMs (using a temporary directory).
| def copy_from_host(self, source: str, target: str) -> None:
"""Copy a file from the host into the guest via the `shared_dir` shared
among all the VMs (using a temporary directory).
"""
host_src = pathlib.Path(source)
vm_target = pathlib.Path(target)
with tempfile.Temporar... | [
"def",
"copy_from_host",
"(",
"self",
",",
"source",
":",
"str",
",",
"target",
":",
"str",
")",
"->",
"None",
":",
"host_src",
"=",
"pathlib",
".",
"Path",
"(",
"source",
")",
"vm_target",
"=",
"pathlib",
".",
"Path",
"(",
"target",
")",
"with",
"te... | [
647,
4
] | [
665,
80
] | python | en | ['en', 'en', 'en'] | True |
Machine.copy_from_vm | (self, source: str, target_dir: str = "") | Copy a file from the VM (specified by an in-VM source path) to a path
relative to `$out`. The file is copied via the `shared_dir` shared among
all the VMs (using a temporary directory).
| Copy a file from the VM (specified by an in-VM source path) to a path
relative to `$out`. The file is copied via the `shared_dir` shared among
all the VMs (using a temporary directory).
| def copy_from_vm(self, source: str, target_dir: str = "") -> None:
"""Copy a file from the VM (specified by an in-VM source path) to a path
relative to `$out`. The file is copied via the `shared_dir` shared among
all the VMs (using a temporary directory).
"""
# Compute the source... | [
"def",
"copy_from_vm",
"(",
"self",
",",
"source",
":",
"str",
",",
"target_dir",
":",
"str",
"=",
"\"\"",
")",
"->",
"None",
":",
"# Compute the source, target, and intermediate shared file names",
"out_dir",
"=",
"pathlib",
".",
"Path",
"(",
"os",
".",
"enviro... | [
667,
4
] | [
689,
53
] | python | en | ['en', 'en', 'en'] | True |
Machine.dump_tty_contents | (self, tty: str) | Debugging: Dump the contents of the TTY<n> | Debugging: Dump the contents of the TTY<n> | def dump_tty_contents(self, tty: str) -> None:
"""Debugging: Dump the contents of the TTY<n>"""
self.execute("fold -w 80 /dev/vcs{} | systemd-cat".format(tty)) | [
"def",
"dump_tty_contents",
"(",
"self",
",",
"tty",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"execute",
"(",
"\"fold -w 80 /dev/vcs{} | systemd-cat\"",
".",
"format",
"(",
"tty",
")",
")"
] | [
691,
4
] | [
693,
71
] | python | en | ['en', 'en', 'en'] | True |
Machine.wait_for_x | (self) | Wait until it is possible to connect to the X server. Note that
testing the existence of /tmp/.X11-unix/X0 is insufficient.
| Wait until it is possible to connect to the X server. Note that
testing the existence of /tmp/.X11-unix/X0 is insufficient.
| def wait_for_x(self) -> None:
"""Wait until it is possible to connect to the X server. Note that
testing the existence of /tmp/.X11-unix/X0 is insufficient.
"""
def check_x(_: Any) -> bool:
cmd = (
"journalctl -b SYSLOG_IDENTIFIER=systemd | "
... | [
"def",
"wait_for_x",
"(",
"self",
")",
"->",
"None",
":",
"def",
"check_x",
"(",
"_",
":",
"Any",
")",
"->",
"bool",
":",
"cmd",
"=",
"(",
"\"journalctl -b SYSLOG_IDENTIFIER=systemd | \"",
"+",
"'grep \"Reached target Current graphical\"'",
")",
"status",
",",
"... | [
843,
4
] | [
860,
26
] | python | en | ['en', 'en', 'en'] | True |
Machine.forward_port | (self, host_port: int = 8080, guest_port: int = 80) | Forward a TCP port on the host to a TCP port on the guest.
Useful during interactive testing.
| Forward a TCP port on the host to a TCP port on the guest.
Useful during interactive testing.
| def forward_port(self, host_port: int = 8080, guest_port: int = 80) -> None:
"""Forward a TCP port on the host to a TCP port on the guest.
Useful during interactive testing.
"""
self.send_monitor_command(
"hostfwd_add tcp::{}-:{}".format(host_port, guest_port)
) | [
"def",
"forward_port",
"(",
"self",
",",
"host_port",
":",
"int",
"=",
"8080",
",",
"guest_port",
":",
"int",
"=",
"80",
")",
"->",
"None",
":",
"self",
".",
"send_monitor_command",
"(",
"\"hostfwd_add tcp::{}-:{}\"",
".",
"format",
"(",
"host_port",
",",
... | [
887,
4
] | [
893,
9
] | python | en | ['en', 'en', 'en'] | True |
Machine.block | (self) | Make the machine unreachable by shutting down eth1 (the multicast
interface used to talk to the other VMs). We keep eth0 up so that
the test driver can continue to talk to the machine.
| Make the machine unreachable by shutting down eth1 (the multicast
interface used to talk to the other VMs). We keep eth0 up so that
the test driver can continue to talk to the machine.
| def block(self) -> None:
"""Make the machine unreachable by shutting down eth1 (the multicast
interface used to talk to the other VMs). We keep eth0 up so that
the test driver can continue to talk to the machine.
"""
self.send_monitor_command("set_link virtio-net-pci.1 off") | [
"def",
"block",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"send_monitor_command",
"(",
"\"set_link virtio-net-pci.1 off\"",
")"
] | [
895,
4
] | [
900,
66
] | python | en | ['en', 'en', 'en'] | True |
Machine.unblock | (self) | Make the machine reachable. | Make the machine reachable. | def unblock(self) -> None:
"""Make the machine reachable."""
self.send_monitor_command("set_link virtio-net-pci.1 on") | [
"def",
"unblock",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"send_monitor_command",
"(",
"\"set_link virtio-net-pci.1 on\"",
")"
] | [
902,
4
] | [
904,
65
] | python | en | ['en', 'mi', 'en'] | True |
test_missing_client | (hass: HomeAssistant) | Validate that if client has not been setup, it fails immediately in setup. | Validate that if client has not been setup, it fails immediately in setup. | async def test_missing_client(hass: HomeAssistant):
"""Validate that if client has not been setup, it fails immediately in setup."""
try:
config_entry = MockConfigEntry(
data={
CONF_ENTRY_HOST: TEST_HOST,
CONF_ENTRY_ID: TEST_ID,
CONF_ENTRY_NAME... | [
"async",
"def",
"test_missing_client",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"try",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"data",
"=",
"{",
"CONF_ENTRY_HOST",
":",
"TEST_HOST",
",",
"CONF_ENTRY_ID",
":",
"TEST_ID",
",",
"CONF_ENTRY_NAME",
":",... | [
27,
0
] | [
42,
16
] | python | en | ['en', 'en', 'en'] | True |
test_initial_state | (hass: HomeAssistant) | Validate that entity and device states are updated on startup. | Validate that entity and device states are updated on startup. | async def test_initial_state(hass: HomeAssistant):
"""Validate that entity and device states are updated on startup."""
entity, device, _ = await _create_entries(hass)
state = hass.states.get(entity.entity_id)
# Basic state properties
assert state.name == entity.unique_id
assert state.state ==... | [
"async",
"def",
"test_initial_state",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"entity",
",",
"device",
",",
"_",
"=",
"await",
"_create_entries",
"(",
"hass",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"entity",
".",
"entity_id",
")"... | [
45,
0
] | [
67,
44
] | python | en | ['en', 'en', 'en'] | True |
test_initial_state_offline | (hass: HomeAssistant) | Validate that entity and device are restored from config is offline on startup. | Validate that entity and device are restored from config is offline on startup. | async def test_initial_state_offline(hass: HomeAssistant):
"""Validate that entity and device are restored from config is offline on startup."""
client = ClientMock()
client.is_offline = True
entity, device, _ = await _create_entries(hass, client)
state = hass.states.get(entity.entity_id)
asse... | [
"async",
"def",
"test_initial_state_offline",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"client",
"=",
"ClientMock",
"(",
")",
"client",
".",
"is_offline",
"=",
"True",
"entity",
",",
"device",
",",
"_",
"=",
"await",
"_create_entries",
"(",
"hass",
",",
... | [
70,
0
] | [
88,
44
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on | (hass: HomeAssistant) | Test support of the light.turn_on service. | Test support of the light.turn_on service. | async def test_turn_on(hass: HomeAssistant):
"""Test support of the light.turn_on service."""
client = ClientMock()
client.is_on = False
client.brightness = 20
entity, _, _ = await _create_entries(hass, client)
assert hass.states.get(entity.entity_id).state == "off"
await hass.services.asy... | [
"async",
"def",
"test_turn_on",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"client",
"=",
"ClientMock",
"(",
")",
"client",
".",
"is_on",
"=",
"False",
"client",
".",
"brightness",
"=",
"20",
"entity",
",",
"_",
",",
"_",
"=",
"await",
"_create_entries... | [
91,
0
] | [
108,
47
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on_with_brightness | (hass: HomeAssistant) | Test support of the light.turn_on service with a brightness parameter. | Test support of the light.turn_on service with a brightness parameter. | async def test_turn_on_with_brightness(hass: HomeAssistant):
"""Test support of the light.turn_on service with a brightness parameter."""
client = ClientMock()
client.is_on = False
client.brightness = 20
entity, _, _ = await _create_entries(hass, client)
assert hass.states.get(entity.entity_id)... | [
"async",
"def",
"test_turn_on_with_brightness",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"client",
"=",
"ClientMock",
"(",
")",
"client",
".",
"is_on",
"=",
"False",
"client",
".",
"brightness",
"=",
"20",
"entity",
",",
"_",
",",
"_",
"=",
"await",
... | [
111,
0
] | [
130,
48
] | python | en | ['en', 'en', 'en'] | True |
test_turn_off | (hass: HomeAssistant) | Test support of the light.turn_off service. | Test support of the light.turn_off service. | async def test_turn_off(hass: HomeAssistant):
"""Test support of the light.turn_off service."""
entity, _, _ = await _create_entries(hass)
assert hass.states.get(entity.entity_id).state == "on"
await hass.services.async_call(
"light", "turn_off", service_data={"entity_id": entity.entity_id}
... | [
"async",
"def",
"test_turn_off",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"entity",
",",
"_",
",",
"_",
"=",
"await",
"_create_entries",
"(",
"hass",
")",
"assert",
"hass",
".",
"states",
".",
"get",
"(",
"entity",
".",
"entity_id",
")",
".",
"stat... | [
133,
0
] | [
147,
46
] | python | en | ['en', 'en', 'en'] | True |
test_update_name | (hass: HomeAssistant) |
Validate device's name update behavior.
Validate that if device name is changed from the Twinkly app,
then the name of the entity is updated and it's also persisted,
so it can be restored when starting HA while Twinkly is offline.
|
Validate device's name update behavior. | async def test_update_name(hass: HomeAssistant):
"""
Validate device's name update behavior.
Validate that if device name is changed from the Twinkly app,
then the name of the entity is updated and it's also persisted,
so it can be restored when starting HA while Twinkly is offline.
"""
ent... | [
"async",
"def",
"test_update_name",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"entity",
",",
"_",
",",
"client",
"=",
"await",
"_create_entries",
"(",
"hass",
")",
"updated_config_entry",
"=",
"None",
"async",
"def",
"on_update",
"(",
"ha",
",",
"co",
"... | [
150,
0
] | [
178,
65
] | python | en | ['en', 'error', 'th'] | False |
test_unload | (hass: HomeAssistant) | Validate that entities can be unloaded from the UI. | Validate that entities can be unloaded from the UI. | async def test_unload(hass: HomeAssistant):
"""Validate that entities can be unloaded from the UI."""
_, _, client = await _create_entries(hass)
entry_id = client.id
assert await hass.config_entries.async_unload(entry_id) | [
"async",
"def",
"test_unload",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"_",
",",
"_",
",",
"client",
"=",
"await",
"_create_entries",
"(",
"hass",
")",
"entry_id",
"=",
"client",
".",
"id",
"assert",
"await",
"hass",
".",
"config_entries",
".",
"asy... | [
181,
0
] | [
187,
59
] | python | en | ['en', 'en', 'en'] | True |
async_check_srv_record | (hass: HomeAssistantType, host: str) | Check if the given host is a valid Minecraft SRV record. | Check if the given host is a valid Minecraft SRV record. | async def async_check_srv_record(hass: HomeAssistantType, host: str) -> Dict[str, Any]:
"""Check if the given host is a valid Minecraft SRV record."""
# Check if 'host' is a valid SRV record.
return_value = None
srv_records = None
try:
srv_records = await aiodns.DNSResolver().query(
... | [
"async",
"def",
"async_check_srv_record",
"(",
"hass",
":",
"HomeAssistantType",
",",
"host",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"# Check if 'host' is a valid SRV record.",
"return_value",
"=",
"None",
"srv_records",
"=",
"None",
"t... | [
12,
0
] | [
31,
23
] | python | en | ['en', 'en', 'en'] | True |
setup_fritzbox | (hass: HomeAssistantType, config: dict) | Set up mock AVM Fritz!Box. | Set up mock AVM Fritz!Box. | async def setup_fritzbox(hass: HomeAssistantType, config: dict):
"""Set up mock AVM Fritz!Box."""
assert await async_setup_component(hass, FB_DOMAIN, config)
await hass.async_block_till_done() | [
"async",
"def",
"setup_fritzbox",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"dict",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"FB_DOMAIN",
",",
"config",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")... | [
28,
0
] | [
31,
38
] | python | en | ['en', 'zu', 'en'] | True |
test_setup | (hass: HomeAssistantType, fritz: Mock) | Test setup of platform. | Test setup of platform. | async def test_setup(hass: HomeAssistantType, fritz: Mock):
"""Test setup of platform."""
device = FritzDeviceSensorMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
state = hass.states.get(ENTITY_ID)
assert state
assert state.state == "1.23"
as... | [
"async",
"def",
"test_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceSensorMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",
"await",
"setup... | [
34,
0
] | [
47,
69
] | python | en | ['en', 'da', 'en'] | True |
test_update | (hass: HomeAssistantType, fritz: Mock) | Test update with error. | Test update with error. | async def test_update(hass: HomeAssistantType, fritz: Mock):
"""Test update with error."""
device = FritzDeviceSensorMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
assert device.update.call_count == 0
assert fritz().login.call_count == 1
next_upd... | [
"async",
"def",
"test_update",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceSensorMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",
"await",
"setu... | [
50,
0
] | [
64,
40
] | python | en | ['en', 'de', 'en'] | True |
test_update_error | (hass: HomeAssistantType, fritz: Mock) | Test update with error. | Test update with error. | async def test_update_error(hass: HomeAssistantType, fritz: Mock):
"""Test update with error."""
device = FritzDeviceSensorMock()
device.update.side_effect = HTTPError("Boom")
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
assert device.update.call_count == ... | [
"async",
"def",
"test_update_error",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceSensorMock",
"(",
")",
"device",
".",
"update",
".",
"side_effect",
"=",
"HTTPError",
"(",
"\"Boom\"",
")",
"fritz",
"... | [
67,
0
] | [
82,
40
] | python | en | ['en', 'de', 'en'] | True |
clear_discovery_hash | (hass, discovery_hash) | Clear entry in ALREADY_DISCOVERED list. | Clear entry in ALREADY_DISCOVERED list. | def clear_discovery_hash(hass, discovery_hash):
"""Clear entry in ALREADY_DISCOVERED list."""
del hass.data[ALREADY_DISCOVERED][discovery_hash] | [
"def",
"clear_discovery_hash",
"(",
"hass",
",",
"discovery_hash",
")",
":",
"del",
"hass",
".",
"data",
"[",
"ALREADY_DISCOVERED",
"]",
"[",
"discovery_hash",
"]"
] | [
58,
0
] | [
60,
53
] | python | en | ['en', 'en', 'en'] | True |
set_discovery_hash | (hass, discovery_hash) | Clear entry in ALREADY_DISCOVERED list. | Clear entry in ALREADY_DISCOVERED list. | def set_discovery_hash(hass, discovery_hash):
"""Clear entry in ALREADY_DISCOVERED list."""
hass.data[ALREADY_DISCOVERED][discovery_hash] = {} | [
"def",
"set_discovery_hash",
"(",
"hass",
",",
"discovery_hash",
")",
":",
"hass",
".",
"data",
"[",
"ALREADY_DISCOVERED",
"]",
"[",
"discovery_hash",
"]",
"=",
"{",
"}"
] | [
63,
0
] | [
65,
54
] | python | en | ['en', 'en', 'en'] | True |
async_start | (
hass: HomeAssistantType, discovery_topic, config_entry=None
) | Start MQTT Discovery. | Start MQTT Discovery. | async def async_start(
hass: HomeAssistantType, discovery_topic, config_entry=None
) -> bool:
"""Start MQTT Discovery."""
mqtt_integrations = {}
async def async_entity_message_received(msg):
"""Process the received message."""
hass.data[LAST_DISCOVERY] = time.time()
payload = ms... | [
"async",
"def",
"async_start",
"(",
"hass",
":",
"HomeAssistantType",
",",
"discovery_topic",
",",
"config_entry",
"=",
"None",
")",
"->",
"bool",
":",
"mqtt_integrations",
"=",
"{",
"}",
"async",
"def",
"async_entity_message_received",
"(",
"msg",
")",
":",
"... | [
72,
0
] | [
231,
15
] | python | en | ['en', 'lb', 'ur'] | False |
async_stop | (hass: HomeAssistantType) | Stop MQTT Discovery. | Stop MQTT Discovery. | async def async_stop(hass: HomeAssistantType) -> bool:
"""Stop MQTT Discovery."""
if DISCOVERY_UNSUBSCRIBE in hass.data and hass.data[DISCOVERY_UNSUBSCRIBE]:
hass.data[DISCOVERY_UNSUBSCRIBE]()
hass.data[DISCOVERY_UNSUBSCRIBE] = None
if INTEGRATION_UNSUBSCRIBE in hass.data:
for key, u... | [
"async",
"def",
"async_stop",
"(",
"hass",
":",
"HomeAssistantType",
")",
"->",
"bool",
":",
"if",
"DISCOVERY_UNSUBSCRIBE",
"in",
"hass",
".",
"data",
"and",
"hass",
".",
"data",
"[",
"DISCOVERY_UNSUBSCRIBE",
"]",
":",
"hass",
".",
"data",
"[",
"DISCOVERY_UN... | [
234,
0
] | [
242,
55
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Find and return LightWave switches. | Find and return LightWave switches. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Find and return LightWave switches."""
if not discovery_info:
return
switches = []
lwlink = hass.data[LIGHTWAVE_LINK]
for device_id, device_config in discovery_info.items():
name = device_conf... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"not",
"discovery_info",
":",
"return",
"switches",
"=",
"[",
"]",
"lwlink",
"=",
"hass",
".",
"data",
"[",
"... | [
7,
0
] | [
19,
32
] | python | en | ['en', 'en', 'en'] | True |
LWRFSwitch.__init__ | (self, name, device_id, lwlink) | Initialize LWRFSwitch entity. | Initialize LWRFSwitch entity. | def __init__(self, name, device_id, lwlink):
"""Initialize LWRFSwitch entity."""
self._name = name
self._device_id = device_id
self._state = None
self._lwlink = lwlink | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"device_id",
",",
"lwlink",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_device_id",
"=",
"device_id",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_lwlink",
"=",
"lwlink"
] | [
25,
4
] | [
30,
29
] | python | en | ['en', 'pl', 'it'] | False |
LWRFSwitch.should_poll | (self) | No polling needed for a LightWave light. | No polling needed for a LightWave light. | def should_poll(self):
"""No polling needed for a LightWave light."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
33,
4
] | [
35,
20
] | python | en | ['en', 'en', 'en'] | True |
LWRFSwitch.name | (self) | Lightwave switch name. | Lightwave switch name. | def name(self):
"""Lightwave switch name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
38,
4
] | [
40,
25
] | python | en | ['en', 'da', 'en'] | True |
LWRFSwitch.is_on | (self) | Lightwave switch is on state. | Lightwave switch is on state. | def is_on(self):
"""Lightwave switch is on state."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
43,
4
] | [
45,
26
] | python | en | ['en', 'en', 'en'] | True |
LWRFSwitch.async_turn_on | (self, **kwargs) | Turn the LightWave switch on. | Turn the LightWave switch on. | async def async_turn_on(self, **kwargs):
"""Turn the LightWave switch on."""
self._state = True
self._lwlink.turn_on_switch(self._device_id, self._name)
self.async_write_ha_state() | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_state",
"=",
"True",
"self",
".",
"_lwlink",
".",
"turn_on_switch",
"(",
"self",
".",
"_device_id",
",",
"self",
".",
"_name",
")",
"self",
".",
"async_writ... | [
47,
4
] | [
51,
35
] | python | en | ['en', 'en', 'en'] | True |
LWRFSwitch.async_turn_off | (self, **kwargs) | Turn the LightWave switch off. | Turn the LightWave switch off. | async def async_turn_off(self, **kwargs):
"""Turn the LightWave switch off."""
self._state = False
self._lwlink.turn_off(self._device_id, self._name)
self.async_write_ha_state() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"_lwlink",
".",
"turn_off",
"(",
"self",
".",
"_device_id",
",",
"self",
".",
"_name",
")",
"self",
".",
"async_write_ha... | [
53,
4
] | [
57,
35
] | python | en | ['en', 'en', 'en'] | True |
store | (hass) | Fixture of a store that prevents writing on Home Assistant stop. | Fixture of a store that prevents writing on Home Assistant stop. | def store(hass):
"""Fixture of a store that prevents writing on Home Assistant stop."""
yield storage.Store(hass, MOCK_VERSION, MOCK_KEY) | [
"def",
"store",
"(",
"hass",
")",
":",
"yield",
"storage",
".",
"Store",
"(",
"hass",
",",
"MOCK_VERSION",
",",
"MOCK_KEY",
")"
] | [
25,
0
] | [
27,
53
] | python | en | ['en', 'en', 'en'] | True |
test_loading | (hass, store) | Test we can save and load data. | Test we can save and load data. | async def test_loading(hass, store):
"""Test we can save and load data."""
await store.async_save(MOCK_DATA)
data = await store.async_load()
assert data == MOCK_DATA | [
"async",
"def",
"test_loading",
"(",
"hass",
",",
"store",
")",
":",
"await",
"store",
".",
"async_save",
"(",
"MOCK_DATA",
")",
"data",
"=",
"await",
"store",
".",
"async_load",
"(",
")",
"assert",
"data",
"==",
"MOCK_DATA"
] | [
30,
0
] | [
34,
28
] | python | en | ['en', 'en', 'en'] | True |
test_custom_encoder | (hass) | Test we can save and load data. | Test we can save and load data. | async def test_custom_encoder(hass):
"""Test we can save and load data."""
class JSONEncoder(json.JSONEncoder):
"""Mock JSON encoder."""
def default(self, o):
"""Mock JSON encode method."""
return "9"
store = storage.Store(hass, MOCK_VERSION, MOCK_KEY, encoder=JSON... | [
"async",
"def",
"test_custom_encoder",
"(",
"hass",
")",
":",
"class",
"JSONEncoder",
"(",
"json",
".",
"JSONEncoder",
")",
":",
"\"\"\"Mock JSON encoder.\"\"\"",
"def",
"default",
"(",
"self",
",",
"o",
")",
":",
"\"\"\"Mock JSON encode method.\"\"\"",
"return",
... | [
37,
0
] | [
50,
22
] | python | en | ['en', 'en', 'en'] | True |
test_loading_non_existing | (hass, store) | Test we can save and load data. | Test we can save and load data. | async def test_loading_non_existing(hass, store):
"""Test we can save and load data."""
with patch("homeassistant.util.json.open", side_effect=FileNotFoundError):
data = await store.async_load()
assert data is None | [
"async",
"def",
"test_loading_non_existing",
"(",
"hass",
",",
"store",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.util.json.open\"",
",",
"side_effect",
"=",
"FileNotFoundError",
")",
":",
"data",
"=",
"await",
"store",
".",
"async_load",
"(",
")",
"asser... | [
53,
0
] | [
57,
23
] | python | en | ['en', 'en', 'en'] | True |
test_loading_parallel | (hass, store, hass_storage, caplog) | Test we can save and load data. | Test we can save and load data. | async def test_loading_parallel(hass, store, hass_storage, caplog):
"""Test we can save and load data."""
hass_storage[store.key] = {"version": MOCK_VERSION, "data": MOCK_DATA}
results = await asyncio.gather(store.async_load(), store.async_load())
assert results[0] is MOCK_DATA
assert results[1] i... | [
"async",
"def",
"test_loading_parallel",
"(",
"hass",
",",
"store",
",",
"hass_storage",
",",
"caplog",
")",
":",
"hass_storage",
"[",
"store",
".",
"key",
"]",
"=",
"{",
"\"version\"",
":",
"MOCK_VERSION",
",",
"\"data\"",
":",
"MOCK_DATA",
"}",
"results",
... | [
60,
0
] | [
68,
61
] | python | en | ['en', 'en', 'en'] | True |
test_saving_with_delay | (hass, store, hass_storage) | Test saving data after a delay. | Test saving data after a delay. | async def test_saving_with_delay(hass, store, hass_storage):
"""Test saving data after a delay."""
store.async_delay_save(lambda: MOCK_DATA, 1)
assert store.key not in hass_storage
async_fire_time_changed(hass, dt.utcnow() + timedelta(seconds=1))
await hass.async_block_till_done()
assert hass_s... | [
"async",
"def",
"test_saving_with_delay",
"(",
"hass",
",",
"store",
",",
"hass_storage",
")",
":",
"store",
".",
"async_delay_save",
"(",
"lambda",
":",
"MOCK_DATA",
",",
"1",
")",
"assert",
"store",
".",
"key",
"not",
"in",
"hass_storage",
"async_fire_time_c... | [
71,
0
] | [
82,
5
] | python | en | ['en', 'en', 'en'] | True |
test_saving_on_final_write | (hass, hass_storage) | Test delayed saves trigger when we quit Home Assistant. | Test delayed saves trigger when we quit Home Assistant. | async def test_saving_on_final_write(hass, hass_storage):
"""Test delayed saves trigger when we quit Home Assistant."""
store = storage.Store(hass, MOCK_VERSION, MOCK_KEY)
store.async_delay_save(lambda: MOCK_DATA, 5)
assert store.key not in hass_storage
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)... | [
"async",
"def",
"test_saving_on_final_write",
"(",
"hass",
",",
"hass_storage",
")",
":",
"store",
"=",
"storage",
".",
"Store",
"(",
"hass",
",",
"MOCK_VERSION",
",",
"MOCK_KEY",
")",
"store",
".",
"async_delay_save",
"(",
"lambda",
":",
"MOCK_DATA",
",",
"... | [
85,
0
] | [
105,
5
] | python | en | ['en', 'en', 'en'] | True |
test_not_delayed_saving_while_stopping | (hass, hass_storage) | Test delayed saves don't write after the stop event has fired. | Test delayed saves don't write after the stop event has fired. | async def test_not_delayed_saving_while_stopping(hass, hass_storage):
"""Test delayed saves don't write after the stop event has fired."""
store = storage.Store(hass, MOCK_VERSION, MOCK_KEY)
hass.bus.async_fire(EVENT_HOMEASSISTANT_STOP)
await hass.async_block_till_done()
hass.state = CoreState.stopp... | [
"async",
"def",
"test_not_delayed_saving_while_stopping",
"(",
"hass",
",",
"hass_storage",
")",
":",
"store",
"=",
"storage",
".",
"Store",
"(",
"hass",
",",
"MOCK_VERSION",
",",
"MOCK_KEY",
")",
"hass",
".",
"bus",
".",
"async_fire",
"(",
"EVENT_HOMEASSISTANT_... | [
108,
0
] | [
118,
40
] | python | en | ['en', 'en', 'en'] | True |
test_not_delayed_saving_after_stopping | (hass, hass_storage) | Test delayed saves don't write after stop if issued before stopping Home Assistant. | Test delayed saves don't write after stop if issued before stopping Home Assistant. | async def test_not_delayed_saving_after_stopping(hass, hass_storage):
"""Test delayed saves don't write after stop if issued before stopping Home Assistant."""
store = storage.Store(hass, MOCK_VERSION, MOCK_KEY)
store.async_delay_save(lambda: MOCK_DATA, 10)
assert store.key not in hass_storage
hass... | [
"async",
"def",
"test_not_delayed_saving_after_stopping",
"(",
"hass",
",",
"hass_storage",
")",
":",
"store",
"=",
"storage",
".",
"Store",
"(",
"hass",
",",
"MOCK_VERSION",
",",
"MOCK_KEY",
")",
"store",
".",
"async_delay_save",
"(",
"lambda",
":",
"MOCK_DATA"... | [
121,
0
] | [
134,
40
] | python | en | ['en', 'en', 'en'] | True |
test_not_saving_while_stopping | (hass, hass_storage) | Test saves don't write when stopping Home Assistant. | Test saves don't write when stopping Home Assistant. | async def test_not_saving_while_stopping(hass, hass_storage):
"""Test saves don't write when stopping Home Assistant."""
store = storage.Store(hass, MOCK_VERSION, MOCK_KEY)
hass.state = CoreState.stopping
await store.async_save(MOCK_DATA)
assert store.key not in hass_storage | [
"async",
"def",
"test_not_saving_while_stopping",
"(",
"hass",
",",
"hass_storage",
")",
":",
"store",
"=",
"storage",
".",
"Store",
"(",
"hass",
",",
"MOCK_VERSION",
",",
"MOCK_KEY",
")",
"hass",
".",
"state",
"=",
"CoreState",
".",
"stopping",
"await",
"st... | [
137,
0
] | [
142,
40
] | python | en | ['en', 'en', 'en'] | True |
test_loading_while_delay | (hass, store, hass_storage) | Test we load new data even if not written yet. | Test we load new data even if not written yet. | async def test_loading_while_delay(hass, store, hass_storage):
"""Test we load new data even if not written yet."""
await store.async_save({"delay": "no"})
assert hass_storage[store.key] == {
"version": MOCK_VERSION,
"key": MOCK_KEY,
"data": {"delay": "no"},
}
store.async_de... | [
"async",
"def",
"test_loading_while_delay",
"(",
"hass",
",",
"store",
",",
"hass_storage",
")",
":",
"await",
"store",
".",
"async_save",
"(",
"{",
"\"delay\"",
":",
"\"no\"",
"}",
")",
"assert",
"hass_storage",
"[",
"store",
".",
"key",
"]",
"==",
"{",
... | [
145,
0
] | [
162,
35
] | python | en | ['en', 'en', 'en'] | True |
test_writing_while_writing_delay | (hass, store, hass_storage) | Test a write while a write with delay is active. | Test a write while a write with delay is active. | async def test_writing_while_writing_delay(hass, store, hass_storage):
"""Test a write while a write with delay is active."""
store.async_delay_save(lambda: {"delay": "yes"}, 1)
assert store.key not in hass_storage
await store.async_save({"delay": "no"})
assert hass_storage[store.key] == {
"... | [
"async",
"def",
"test_writing_while_writing_delay",
"(",
"hass",
",",
"store",
",",
"hass_storage",
")",
":",
"store",
".",
"async_delay_save",
"(",
"lambda",
":",
"{",
"\"delay\"",
":",
"\"yes\"",
"}",
",",
"1",
")",
"assert",
"store",
".",
"key",
"not",
... | [
165,
0
] | [
185,
34
] | 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.