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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
report | (shas, meta) |
Cluster rule to compare ntp.conf files across a cluster
``shas`` is a Pandas DataFrame for the facts for each host
by the fact ``ntp_sha256``. See
https://pandas.pydata.org/pandas-docs/stable/api.html#dataframe
for information on available attributes and methods.
``meta`` is a dictionary tha... |
Cluster rule to compare ntp.conf files across a cluster | def report(shas, meta):
"""
Cluster rule to compare ntp.conf files across a cluster
``shas`` is a Pandas DataFrame for the facts for each host
by the fact ``ntp_sha256``. See
https://pandas.pydata.org/pandas-docs/stable/api.html#dataframe
for information on available attributes and methods.
... | [
"def",
"report",
"(",
"shas",
",",
"meta",
")",
":",
"num_members",
"=",
"meta",
".",
"num_members",
"uniq",
"=",
"shas",
".",
"sha",
".",
"unique",
"(",
")",
"if",
"len",
"(",
"shas",
")",
"!=",
"num_members",
"or",
"len",
"(",
"uniq",
")",
"!=",
... | [
49,
0
] | [
74,
88
] | python | en | ['en', 'error', 'th'] | False |
test_request_json | () | Test a JSON request. | Test a JSON request. | async def test_request_json():
"""Test a JSON request."""
request = aiohttp.MockRequest(b'{"hello": 2}', mock_source="test")
assert request.status == 200
assert await request.json() == {"hello": 2} | [
"async",
"def",
"test_request_json",
"(",
")",
":",
"request",
"=",
"aiohttp",
".",
"MockRequest",
"(",
"b'{\"hello\": 2}'",
",",
"mock_source",
"=",
"\"test\"",
")",
"assert",
"request",
".",
"status",
"==",
"200",
"assert",
"await",
"request",
".",
"json",
... | [
5,
0
] | [
9,
47
] | python | en | ['en', 'fr', 'en'] | True |
test_request_text | () | Test a JSON request. | Test a JSON request. | async def test_request_text():
"""Test a JSON request."""
request = aiohttp.MockRequest(b"hello", status=201, mock_source="test")
assert request.status == 201
assert await request.text() == "hello" | [
"async",
"def",
"test_request_text",
"(",
")",
":",
"request",
"=",
"aiohttp",
".",
"MockRequest",
"(",
"b\"hello\"",
",",
"status",
"=",
"201",
",",
"mock_source",
"=",
"\"test\"",
")",
"assert",
"request",
".",
"status",
"==",
"201",
"assert",
"await",
"... | [
12,
0
] | [
16,
42
] | python | en | ['en', 'fr', 'en'] | True |
test_request_post_query | () | Test a JSON request. | Test a JSON request. | async def test_request_post_query():
"""Test a JSON request."""
request = aiohttp.MockRequest(
b"hello=2&post=true", query_string="get=true", method="POST", mock_source="test"
)
assert request.method == "POST"
assert await request.post() == {"hello": "2", "post": "true"}
assert request.q... | [
"async",
"def",
"test_request_post_query",
"(",
")",
":",
"request",
"=",
"aiohttp",
".",
"MockRequest",
"(",
"b\"hello=2&post=true\"",
",",
"query_string",
"=",
"\"get=true\"",
",",
"method",
"=",
"\"POST\"",
",",
"mock_source",
"=",
"\"test\"",
")",
"assert",
... | [
19,
0
] | [
26,
43
] | python | en | ['en', 'fr', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) | Set up IPP sensor based on a config entry. | Set up IPP sensor based on a config entry. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up IPP sensor based on a config entry."""
coordinator: IPPDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
# config flow sets this to either UUID, serial num... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
",",
")",
"->",
"None",
":",
"coordinator",
":",
"IPPDataUpdateCoordinator",
"=",
"hass",
".",
"data",
... | [
29,
0
] | [
53,
37
] | python | en | ['en', 'da', 'en'] | True |
IPPSensor.__init__ | (
self,
*,
coordinator: IPPDataUpdateCoordinator,
enabled_default: bool = True,
entry_id: str,
unique_id: str,
icon: str,
key: str,
name: str,
unit_of_measurement: str | None = None,
) | Initialize IPP sensor. | Initialize IPP sensor. | def __init__(
self,
*,
coordinator: IPPDataUpdateCoordinator,
enabled_default: bool = True,
entry_id: str,
unique_id: str,
icon: str,
key: str,
name: str,
unit_of_measurement: str | None = None,
) -> None:
"""Initialize IPP sens... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"coordinator",
":",
"IPPDataUpdateCoordinator",
",",
"enabled_default",
":",
"bool",
"=",
"True",
",",
"entry_id",
":",
"str",
",",
"unique_id",
":",
"str",
",",
"icon",
":",
"str",
",",
"key",
":",
"str",
... | [
59,
4
] | [
83,
9
] | python | en | ['en', 'ro', 'it'] | False |
IPPMarkerSensor.__init__ | (
self,
entry_id: str,
unique_id: str,
coordinator: IPPDataUpdateCoordinator,
marker_index: int,
) | Initialize IPP marker sensor. | Initialize IPP marker sensor. | def __init__(
self,
entry_id: str,
unique_id: str,
coordinator: IPPDataUpdateCoordinator,
marker_index: int,
) -> None:
"""Initialize IPP marker sensor."""
self.marker_index = marker_index
super().__init__(
coordinator=coordinator,
... | [
"def",
"__init__",
"(",
"self",
",",
"entry_id",
":",
"str",
",",
"unique_id",
":",
"str",
",",
"coordinator",
":",
"IPPDataUpdateCoordinator",
",",
"marker_index",
":",
"int",
",",
")",
"->",
"None",
":",
"self",
".",
"marker_index",
"=",
"marker_index",
... | [
89,
4
] | [
107,
9
] | python | en | ['en', 'fy', 'it'] | False |
IPPMarkerSensor.extra_state_attributes | (self) | Return the state attributes of the entity. | Return the state attributes of the entity. | def extra_state_attributes(self) -> dict[str, Any] | None:
"""Return the state attributes of the entity."""
return {
ATTR_MARKER_HIGH_LEVEL: self.coordinator.data.markers[
self.marker_index
].high_level,
ATTR_MARKER_LOW_LEVEL: self.coordinator.data.mar... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
"->",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
":",
"return",
"{",
"ATTR_MARKER_HIGH_LEVEL",
":",
"self",
".",
"coordinator",
".",
"data",
".",
"markers",
"[",
"self",
".",
"marker_index",
"]",
... | [
110,
4
] | [
122,
9
] | python | en | ['en', 'en', 'en'] | True |
IPPMarkerSensor.native_value | (self) | Return the state of the sensor. | Return the state of the sensor. | def native_value(self) -> int | None:
"""Return the state of the sensor."""
level = self.coordinator.data.markers[self.marker_index].level
if level >= 0:
return level
return None | [
"def",
"native_value",
"(",
"self",
")",
"->",
"int",
"|",
"None",
":",
"level",
"=",
"self",
".",
"coordinator",
".",
"data",
".",
"markers",
"[",
"self",
".",
"marker_index",
"]",
".",
"level",
"if",
"level",
">=",
"0",
":",
"return",
"level",
"ret... | [
125,
4
] | [
132,
19
] | python | en | ['en', 'en', 'en'] | True |
IPPPrinterSensor.__init__ | (
self, entry_id: str, unique_id: str, coordinator: IPPDataUpdateCoordinator
) | Initialize IPP printer sensor. | Initialize IPP printer sensor. | def __init__(
self, entry_id: str, unique_id: str, coordinator: IPPDataUpdateCoordinator
) -> None:
"""Initialize IPP printer sensor."""
super().__init__(
coordinator=coordinator,
entry_id=entry_id,
unique_id=unique_id,
icon="mdi:printer",
... | [
"def",
"__init__",
"(",
"self",
",",
"entry_id",
":",
"str",
",",
"unique_id",
":",
"str",
",",
"coordinator",
":",
"IPPDataUpdateCoordinator",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
"=",
"coordinator",
",",
"entry_... | [
138,
4
] | [
150,
9
] | python | en | ['en', 'pt', 'it'] | False |
IPPPrinterSensor.extra_state_attributes | (self) | Return the state attributes of the entity. | Return the state attributes of the entity. | def extra_state_attributes(self) -> dict[str, Any] | None:
"""Return the state attributes of the entity."""
return {
ATTR_INFO: self.coordinator.data.info.printer_info,
ATTR_SERIAL: self.coordinator.data.info.serial,
ATTR_LOCATION: self.coordinator.data.info.location,... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
"->",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
":",
"return",
"{",
"ATTR_INFO",
":",
"self",
".",
"coordinator",
".",
"data",
".",
"info",
".",
"printer_info",
",",
"ATTR_SERIAL",
":",
"self",
... | [
153,
4
] | [
163,
9
] | python | en | ['en', 'en', 'en'] | True |
IPPPrinterSensor.native_value | (self) | Return the state of the sensor. | Return the state of the sensor. | def native_value(self) -> str:
"""Return the state of the sensor."""
return self.coordinator.data.state.printer_state | [
"def",
"native_value",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
".",
"state",
".",
"printer_state"
] | [
166,
4
] | [
168,
56
] | python | en | ['en', 'en', 'en'] | True |
IPPUptimeSensor.__init__ | (
self, entry_id: str, unique_id: str, coordinator: IPPDataUpdateCoordinator
) | Initialize IPP uptime sensor. | Initialize IPP uptime sensor. | def __init__(
self, entry_id: str, unique_id: str, coordinator: IPPDataUpdateCoordinator
) -> None:
"""Initialize IPP uptime sensor."""
super().__init__(
coordinator=coordinator,
enabled_default=False,
entry_id=entry_id,
unique_id=unique_id,
... | [
"def",
"__init__",
"(",
"self",
",",
"entry_id",
":",
"str",
",",
"unique_id",
":",
"str",
",",
"coordinator",
":",
"IPPDataUpdateCoordinator",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
"=",
"coordinator",
",",
"enable... | [
176,
4
] | [
188,
9
] | python | en | ['en', 'ro', 'en'] | True |
IPPUptimeSensor.native_value | (self) | Return the state of the sensor. | Return the state of the sensor. | def native_value(self) -> str:
"""Return the state of the sensor."""
uptime = utcnow() - timedelta(seconds=self.coordinator.data.info.uptime)
return uptime.replace(microsecond=0).isoformat() | [
"def",
"native_value",
"(",
"self",
")",
"->",
"str",
":",
"uptime",
"=",
"utcnow",
"(",
")",
"-",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"coordinator",
".",
"data",
".",
"info",
".",
"uptime",
")",
"return",
"uptime",
".",
"replace",
"(",
"m... | [
191,
4
] | [
194,
56
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the notification service. | Get the notification service. | def get_service(hass, config, discovery_info=None):
"""Get the notification service."""
connection_string = config[CONF_CONNECTION_STRING]
queue_name = config.get(CONF_QUEUE_NAME)
topic_name = config.get(CONF_TOPIC_NAME)
# Library can do synchronous IO when creating the clients.
# Passes in loo... | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"connection_string",
"=",
"config",
"[",
"CONF_CONNECTION_STRING",
"]",
"queue_name",
"=",
"config",
".",
"get",
"(",
"CONF_QUEUE_NAME",
")",
"topic_name",
"=",
"co... | [
48,
0
] | [
73,
48
] | python | en | ['en', 'en', 'en'] | True |
ServiceBusNotificationService.__init__ | (self, client) | Initialize the service. | Initialize the service. | def __init__(self, client):
"""Initialize the service."""
self._client = client | [
"def",
"__init__",
"(",
"self",
",",
"client",
")",
":",
"self",
".",
"_client",
"=",
"client"
] | [
79,
4
] | [
81,
29
] | python | en | ['en', 'en', 'en'] | True |
ServiceBusNotificationService.async_send_message | (self, message, **kwargs) | Send a message. | Send a message. | async def async_send_message(self, message, **kwargs):
"""Send a message."""
dto = {ATTR_ASB_MESSAGE: message}
if ATTR_TITLE in kwargs:
dto[ATTR_ASB_TITLE] = kwargs[ATTR_TITLE]
if ATTR_TARGET in kwargs:
dto[ATTR_ASB_TARGET] = kwargs[ATTR_TARGET]
data = k... | [
"async",
"def",
"async_send_message",
"(",
"self",
",",
"message",
",",
"*",
"*",
"kwargs",
")",
":",
"dto",
"=",
"{",
"ATTR_ASB_MESSAGE",
":",
"message",
"}",
"if",
"ATTR_TITLE",
"in",
"kwargs",
":",
"dto",
"[",
"ATTR_ASB_TITLE",
"]",
"=",
"kwargs",
"["... | [
83,
4
] | [
105,
13
] | python | en | ['en', 'lb', 'en'] | True |
async_at_start | (
hass: HomeAssistant, at_start_cb: Callable[[HomeAssistant], Awaitable]
) | Execute something when Home Assistant is started.
Will execute it now if Home Assistant is already started.
| Execute something when Home Assistant is started. | def async_at_start(
hass: HomeAssistant, at_start_cb: Callable[[HomeAssistant], Awaitable]
) -> None:
"""Execute something when Home Assistant is started.
Will execute it now if Home Assistant is already started.
"""
if hass.is_running:
hass.async_create_task(at_start_cb(hass))
retu... | [
"def",
"async_at_start",
"(",
"hass",
":",
"HomeAssistant",
",",
"at_start_cb",
":",
"Callable",
"[",
"[",
"HomeAssistant",
"]",
",",
"Awaitable",
"]",
")",
"->",
"None",
":",
"if",
"hass",
".",
"is_running",
":",
"hass",
".",
"async_create_task",
"(",
"at... | [
9,
0
] | [
24,
73
] | python | en | ['en', 'en', 'en'] | True |
ForecastSolarFlowHandler.async_get_options_flow | (
config_entry: ConfigEntry,
) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(
config_entry: ConfigEntry,
) -> ForecastSolarOptionFlowHandler:
"""Get the options flow for this handler."""
return ForecastSolarOptionFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
":",
"ConfigEntry",
",",
")",
"->",
"ForecastSolarOptionFlowHandler",
":",
"return",
"ForecastSolarOptionFlowHandler",
"(",
"config_entry",
")"
] | [
29,
4
] | [
33,
59
] | python | en | ['en', 'en', 'en'] | True |
ForecastSolarFlowHandler.async_step_user | (
self, user_input: dict[str, Any] | None = None
) | Handle a flow initiated by the user. | Handle a flow initiated by the user. | async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Handle a flow initiated by the user."""
if user_input is not None:
return self.async_create_entry(
title=user_input[CONF_NAME],
data={
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry"... | [
35,
4
] | [
75,
9
] | python | en | ['en', 'en', 'en'] | True |
ForecastSolarOptionFlowHandler.__init__ | (self, config_entry: ConfigEntry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
81,
4
] | [
83,
40
] | python | en | ['en', 'en', 'en'] | True |
ForecastSolarOptionFlowHandler.async_step_init | (
self, user_input: dict[str, Any] | None = None
) | Manage the options. | Manage the options. | async def async_step_init(
self, user_input: dict[str, Any] | None = None
) -> FlowResult:
"""Manage the options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
return self.async_show_form(
step_id="init",
... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry"... | [
85,
4
] | [
122,
9
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) | Set up motionEye from a config entry. | Set up motionEye from a config entry. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up motionEye from a config entry."""
entry_data = hass.data[DOMAIN][entry.entry_id]
@callback
def camera_add(camera: dict[str, Any]) -> None:
"""Add a new motionEy... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
")",
"->",
"None",
":",
"entry_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
... | [
56,
0
] | [
81,
51
] | python | en | ['en', 'en', 'en'] | True |
MotionEyeMjpegCamera.__init__ | (
self,
config_entry_id: str,
username: str,
password: str,
camera: dict[str, Any],
client: MotionEyeClient,
coordinator: DataUpdateCoordinator,
options: MappingProxyType[str, str],
) | Initialize a MJPEG camera. | Initialize a MJPEG camera. | def __init__(
self,
config_entry_id: str,
username: str,
password: str,
camera: dict[str, Any],
client: MotionEyeClient,
coordinator: DataUpdateCoordinator,
options: MappingProxyType[str, str],
) -> None:
"""Initialize a MJPEG camera."""
... | [
"def",
"__init__",
"(",
"self",
",",
"config_entry_id",
":",
"str",
",",
"username",
":",
"str",
",",
"password",
":",
"str",
",",
"camera",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
",",
"client",
":",
"MotionEyeClient",
",",
"coordinator",
":",
"Data... | [
87,
4
] | [
120,
9
] | python | cs | ['en', 'cs', 'it'] | False |
MotionEyeMjpegCamera._get_mjpeg_camera_properties_for_camera | (
self, camera: dict[str, Any]
) | Convert a motionEye camera to MjpegCamera internal properties. | Convert a motionEye camera to MjpegCamera internal properties. | def _get_mjpeg_camera_properties_for_camera(
self, camera: dict[str, Any]
) -> dict[str, Any]:
"""Convert a motionEye camera to MjpegCamera internal properties."""
auth = None
if camera.get(KEY_STREAMING_AUTH_MODE) in (
HTTP_BASIC_AUTHENTICATION,
HTTP_DIGEST_A... | [
"def",
"_get_mjpeg_camera_properties_for_camera",
"(",
"self",
",",
"camera",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"dict",
"[",
"str",
",",
"Any",
"]",
":",
"auth",
"=",
"None",
"if",
"camera",
".",
"get",
"(",
"KEY_STREAMING_AUTH_MODE",
... | [
123,
4
] | [
141,
9
] | python | en | ['en', 'ny', 'en'] | True |
MotionEyeMjpegCamera._set_mjpeg_camera_state_for_camera | (self, camera: dict[str, Any]) | Set the internal state to match the given camera. | Set the internal state to match the given camera. | def _set_mjpeg_camera_state_for_camera(self, camera: dict[str, Any]) -> None:
"""Set the internal state to match the given camera."""
# Sets the state of the underlying (inherited) MjpegCamera based on the updated
# MotionEye camera dictionary.
properties = self._get_mjpeg_camera_proper... | [
"def",
"_set_mjpeg_camera_state_for_camera",
"(",
"self",
",",
"camera",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"# Sets the state of the underlying (inherited) MjpegCamera based on the updated",
"# MotionEye camera dictionary.",
"properties",
"=",
... | [
144,
4
] | [
158,
83
] | python | en | ['en', 'en', 'en'] | True |
MotionEyeMjpegCamera._is_acceptable_streaming_camera | (self) | Determine if a camera is streaming/usable. | Determine if a camera is streaming/usable. | def _is_acceptable_streaming_camera(self) -> bool:
"""Determine if a camera is streaming/usable."""
return is_acceptable_camera(
self._camera
) and MotionEyeClient.is_camera_streaming(self._camera) | [
"def",
"_is_acceptable_streaming_camera",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"is_acceptable_camera",
"(",
"self",
".",
"_camera",
")",
"and",
"MotionEyeClient",
".",
"is_camera_streaming",
"(",
"self",
".",
"_camera",
")"
] | [
160,
4
] | [
164,
63
] | python | en | ['en', 'en', 'en'] | True |
MotionEyeMjpegCamera.available | (self) | Return if entity is available. | Return if entity is available. | def available(self) -> bool:
"""Return if entity is available."""
return super().available and self._is_acceptable_streaming_camera() | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"super",
"(",
")",
".",
"available",
"and",
"self",
".",
"_is_acceptable_streaming_camera",
"(",
")"
] | [
167,
4
] | [
169,
75
] | python | en | ['en', 'en', 'en'] | True |
MotionEyeMjpegCamera._handle_coordinator_update | (self) | Handle updated data from the coordinator. | Handle updated data from the coordinator. | def _handle_coordinator_update(self) -> None:
"""Handle updated data from the coordinator."""
self._camera = get_camera_from_cameras(self._camera_id, self.coordinator.data)
if self._camera and self._is_acceptable_streaming_camera():
self._set_mjpeg_camera_state_for_camera(self._camer... | [
"def",
"_handle_coordinator_update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_camera",
"=",
"get_camera_from_cameras",
"(",
"self",
".",
"_camera_id",
",",
"self",
".",
"coordinator",
".",
"data",
")",
"if",
"self",
".",
"_camera",
"and",
"self",
... | [
172,
4
] | [
180,
44
] | python | en | ['en', 'en', 'en'] | True |
MotionEyeMjpegCamera.brand | (self) | Return the camera brand. | Return the camera brand. | def brand(self) -> str:
"""Return the camera brand."""
return MOTIONEYE_MANUFACTURER | [
"def",
"brand",
"(",
"self",
")",
"->",
"str",
":",
"return",
"MOTIONEYE_MANUFACTURER"
] | [
183,
4
] | [
185,
37
] | python | en | ['en', 'bs', 'en'] | True |
MotionEyeMjpegCamera.motion_detection_enabled | (self) | Return the camera motion detection status. | Return the camera motion detection status. | def motion_detection_enabled(self) -> bool:
"""Return the camera motion detection status."""
return self._motion_detection_enabled | [
"def",
"motion_detection_enabled",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_motion_detection_enabled"
] | [
188,
4
] | [
190,
45
] | python | en | ['en', 'en', 'en'] | True |
verify_redirect_uri | (hass, client_id, redirect_uri) | Verify that the client and redirect uri match. | Verify that the client and redirect uri match. | async def verify_redirect_uri(hass, client_id, redirect_uri):
"""Verify that the client and redirect uri match."""
try:
client_id_parts = _parse_client_id(client_id)
except ValueError:
return False
redirect_parts = _parse_url(redirect_uri)
# Verify redirect url and client url have ... | [
"async",
"def",
"verify_redirect_uri",
"(",
"hass",
",",
"client_id",
",",
"redirect_uri",
")",
":",
"try",
":",
"client_id_parts",
"=",
"_parse_client_id",
"(",
"client_id",
")",
"except",
"ValueError",
":",
"return",
"False",
"redirect_parts",
"=",
"_parse_url",... | [
14,
0
] | [
43,
40
] | python | en | ['en', 'en', 'en'] | True |
fetch_redirect_uris | (hass, url) | Find link tag with redirect_uri values.
IndieAuth 4.2.2
The client SHOULD publish one or more <link> tags or Link HTTP headers with
a rel attribute of redirect_uri at the client_id URL.
We limit to the first 10kB of the page.
We do not implement extracting redirect uris from headers.
| Find link tag with redirect_uri values. | async def fetch_redirect_uris(hass, url):
"""Find link tag with redirect_uri values.
IndieAuth 4.2.2
The client SHOULD publish one or more <link> tags or Link HTTP headers with
a rel attribute of redirect_uri at the client_id URL.
We limit to the first 10kB of the page.
We do not implement e... | [
"async",
"def",
"fetch_redirect_uris",
"(",
"hass",
",",
"url",
")",
":",
"parser",
"=",
"LinkTagParser",
"(",
"\"redirect_uri\"",
")",
"chunks",
"=",
"0",
"try",
":",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
")",
"as",
"session",
":",
"async... | [
66,
0
] | [
107,
58
] | python | en | ['en', 'en', 'en'] | True |
verify_client_id | (client_id) | Verify that the client id is valid. | Verify that the client id is valid. | def verify_client_id(client_id):
"""Verify that the client id is valid."""
try:
_parse_client_id(client_id)
return True
except ValueError:
return False | [
"def",
"verify_client_id",
"(",
"client_id",
")",
":",
"try",
":",
"_parse_client_id",
"(",
"client_id",
")",
"return",
"True",
"except",
"ValueError",
":",
"return",
"False"
] | [
110,
0
] | [
116,
20
] | python | en | ['en', 'en', 'en'] | True |
_parse_url | (url) | Parse a url in parts and canonicalize according to IndieAuth. | Parse a url in parts and canonicalize according to IndieAuth. | def _parse_url(url):
"""Parse a url in parts and canonicalize according to IndieAuth."""
parts = urlparse(url)
# Canonicalize a url according to IndieAuth 3.2.
# SHOULD convert the hostname to lowercase
parts = parts._replace(netloc=parts.netloc.lower())
# If a URL with no path component is e... | [
"def",
"_parse_url",
"(",
"url",
")",
":",
"parts",
"=",
"urlparse",
"(",
"url",
")",
"# Canonicalize a url according to IndieAuth 3.2.",
"# SHOULD convert the hostname to lowercase",
"parts",
"=",
"parts",
".",
"_replace",
"(",
"netloc",
"=",
"parts",
".",
"netloc",
... | [
119,
0
] | [
133,
16
] | python | en | ['en', 'en', 'en'] | True |
_parse_client_id | (client_id) | Test if client id is a valid URL according to IndieAuth section 3.2.
https://indieauth.spec.indieweb.org/#client-identifier
| Test if client id is a valid URL according to IndieAuth section 3.2. | def _parse_client_id(client_id):
"""Test if client id is a valid URL according to IndieAuth section 3.2.
https://indieauth.spec.indieweb.org/#client-identifier
"""
parts = _parse_url(client_id)
# Client identifier URLs
# MUST have either an https or http scheme
if parts.scheme not in ("htt... | [
"def",
"_parse_client_id",
"(",
"client_id",
")",
":",
"parts",
"=",
"_parse_url",
"(",
"client_id",
")",
"# Client identifier URLs",
"# MUST have either an https or http scheme",
"if",
"parts",
".",
"scheme",
"not",
"in",
"(",
"\"http\"",
",",
"\"https\"",
")",
":"... | [
136,
0
] | [
200,
76
] | python | en | ['en', 'en', 'en'] | True |
LinkTagParser.__init__ | (self, rel) | Initialize a link tag parser. | Initialize a link tag parser. | def __init__(self, rel):
"""Initialize a link tag parser."""
super().__init__()
self.rel = rel
self.found = [] | [
"def",
"__init__",
"(",
"self",
",",
"rel",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"rel",
"=",
"rel",
"self",
".",
"found",
"=",
"[",
"]"
] | [
49,
4
] | [
53,
23
] | python | en | ['en', 'en', 'it'] | True |
LinkTagParser.handle_starttag | (self, tag, attrs) | Handle finding a start tag. | Handle finding a start tag. | def handle_starttag(self, tag, attrs):
"""Handle finding a start tag."""
if tag != "link":
return
attrs = dict(attrs)
if attrs.get("rel") == self.rel:
self.found.append(attrs.get("href")) | [
"def",
"handle_starttag",
"(",
"self",
",",
"tag",
",",
"attrs",
")",
":",
"if",
"tag",
"!=",
"\"link\"",
":",
"return",
"attrs",
"=",
"dict",
"(",
"attrs",
")",
"if",
"attrs",
".",
"get",
"(",
"\"rel\"",
")",
"==",
"self",
".",
"rel",
":",
"self",... | [
55,
4
] | [
63,
48
] | python | en | ['en', 'en', 'en'] | True |
test_import_from_yaml | (hass) | Test import from YAML. | Test import from YAML. | async def test_import_from_yaml(hass) -> None:
"""Test import from YAML."""
with _patch_version(), _patch_status(), _patch_history(), _patch_async_setup_entry():
assert await async_setup_component(hass, DOMAIN, {DOMAIN: YAML_CONFIG})
await hass.async_block_till_done()
entries = hass.config_... | [
"async",
"def",
"test_import_from_yaml",
"(",
"hass",
")",
"->",
"None",
":",
"with",
"_patch_version",
"(",
")",
",",
"_patch_status",
"(",
")",
",",
"_patch_history",
"(",
")",
",",
"_patch_async_setup_entry",
"(",
")",
":",
"assert",
"await",
"async_setup_c... | [
23,
0
] | [
34,
45
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass, nzbget_api) | Test successful unload of entry. | Test successful unload of entry. | async def test_unload_entry(hass, nzbget_api):
"""Test successful unload of entry."""
entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id)
awai... | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
",",
"nzbget_api",
")",
":",
"entry",
"=",
"await",
"init_integration",
"(",
"hass",
")",
"assert",
"len",
"(",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"DOMAIN",
")",
")",
"==",
"1",
"asse... | [
37,
0
] | [
48,
36
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_raises_entry_not_ready | (hass) | Test that it throws ConfigEntryNotReady when exception occurs during setup. | Test that it throws ConfigEntryNotReady when exception occurs during setup. | async def test_async_setup_raises_entry_not_ready(hass):
"""Test that it throws ConfigEntryNotReady when exception occurs during setup."""
config_entry = MockConfigEntry(domain=DOMAIN, data=ENTRY_CONFIG)
config_entry.add_to_hass(hass)
with _patch_version(), patch(
"homeassistant.components.nzbg... | [
"async",
"def",
"test_async_setup_raises_entry_not_ready",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"ENTRY_CONFIG",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"with",
"_patch_ver... | [
51,
0
] | [
62,
61
] | python | en | ['en', 'en', 'en'] | True |
filesys_decode | (path) |
Ensure that the given path is decoded,
NONE when no expected encoding works
|
Ensure that the given path is decoded,
NONE when no expected encoding works
| def filesys_decode(path):
"""
Ensure that the given path is decoded,
NONE when no expected encoding works
"""
if isinstance(path, str):
return path
fs_enc = sys.getfilesystemencoding() or 'utf-8'
candidates = fs_enc, 'utf-8'
for enc in candidates:
try:
retu... | [
"def",
"filesys_decode",
"(",
"path",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"return",
"path",
"fs_enc",
"=",
"sys",
".",
"getfilesystemencoding",
"(",
")",
"or",
"'utf-8'",
"candidates",
"=",
"fs_enc",
",",
"'utf-8'",
"for",
"e... | [
17,
0
] | [
33,
20
] | python | en | ['en', 'error', 'th'] | False |
try_encode | (string, enc) | turn unicode encoding into a functional routine | turn unicode encoding into a functional routine | def try_encode(string, enc):
"turn unicode encoding into a functional routine"
try:
return string.encode(enc)
except UnicodeEncodeError:
return None | [
"def",
"try_encode",
"(",
"string",
",",
"enc",
")",
":",
"try",
":",
"return",
"string",
".",
"encode",
"(",
"enc",
")",
"except",
"UnicodeEncodeError",
":",
"return",
"None"
] | [
36,
0
] | [
41,
19
] | python | en | ['en', 'en', 'en'] | True |
async_validate_config_item | (hass, config, full_config=None) | Validate config item. | Validate config item. | async def async_validate_config_item(hass, config, full_config=None):
"""Validate config item."""
if blueprint.is_blueprint_instance_config(config):
blueprints = async_get_blueprints(hass)
return await blueprints.async_inputs_from_config(config)
config = PLATFORM_SCHEMA(config)
config[... | [
"async",
"def",
"async_validate_config_item",
"(",
"hass",
",",
"config",
",",
"full_config",
"=",
"None",
")",
":",
"if",
"blueprint",
".",
"is_blueprint_instance_config",
"(",
"config",
")",
":",
"blueprints",
"=",
"async_get_blueprints",
"(",
"hass",
")",
"re... | [
65,
0
] | [
89,
17
] | python | en | ['en', 'la', 'en'] | True |
_try_async_validate_config_item | (hass, config, full_config=None) | Validate config item. | Validate config item. | async def _try_async_validate_config_item(hass, config, full_config=None):
"""Validate config item."""
raw_config = None
with suppress(ValueError):
raw_config = dict(config)
try:
config = await async_validate_config_item(hass, config, full_config)
except (
vol.Invalid,
... | [
"async",
"def",
"_try_async_validate_config_item",
"(",
"hass",
",",
"config",
",",
"full_config",
"=",
"None",
")",
":",
"raw_config",
"=",
"None",
"with",
"suppress",
"(",
"ValueError",
")",
":",
"raw_config",
"=",
"dict",
"(",
"config",
")",
"try",
":",
... | [
98,
0
] | [
120,
17
] | python | en | ['en', 'la', 'en'] | True |
async_validate_config | (hass, config) | Validate config. | Validate config. | async def async_validate_config(hass, config):
"""Validate config."""
automations = list(
filter(
lambda x: x is not None,
await asyncio.gather(
*(
_try_async_validate_config_item(hass, p_config, config)
for _, p_config in c... | [
"async",
"def",
"async_validate_config",
"(",
"hass",
",",
"config",
")",
":",
"automations",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
"is",
"not",
"None",
",",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"(",
"_try_async_validate_config_... | [
123,
0
] | [
142,
17
] | python | en | ['en', 'la', 'it'] | False |
test_google_entity_sync_serialize_with_local_sdk | (hass) | Test sync serialize attributes of a GoogleEntity. | Test sync serialize attributes of a GoogleEntity. | async def test_google_entity_sync_serialize_with_local_sdk(hass):
"""Test sync serialize attributes of a GoogleEntity."""
hass.states.async_set("light.ceiling_lights", "off")
hass.config.api = Mock(port=1234, use_ssl=True)
await async_process_ha_core_config(
hass,
{"external_url": "https... | [
"async",
"def",
"test_google_entity_sync_serialize_with_local_sdk",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"light.ceiling_lights\"",
",",
"\"off\"",
")",
"hass",
".",
"config",
".",
"api",
"=",
"Mock",
"(",
"port",
"=",
"1234",
... | [
25,
0
] | [
67,
49
] | python | en | ['en', 'en', 'en'] | True |
test_config_local_sdk | (hass, hass_client) | Test the local SDK. | Test the local SDK. | async def test_config_local_sdk(hass, hass_client):
"""Test the local SDK."""
command_events = async_capture_events(hass, EVENT_COMMAND_RECEIVED)
turn_on_calls = async_mock_service(hass, "light", "turn_on")
hass.states.async_set("light.ceiling_lights", "off")
assert await async_setup_component(hass... | [
"async",
"def",
"test_config_local_sdk",
"(",
"hass",
",",
"hass_client",
")",
":",
"command_events",
"=",
"async_capture_events",
"(",
"hass",
",",
"EVENT_COMMAND_RECEIVED",
")",
"turn_on_calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"\"light\"",
",",
"\"tur... | [
70,
0
] | [
129,
35
] | python | en | ['en', 'en', 'en'] | True |
test_config_local_sdk_if_disabled | (hass, hass_client) | Test the local SDK. | Test the local SDK. | async def test_config_local_sdk_if_disabled(hass, hass_client):
"""Test the local SDK."""
assert await async_setup_component(hass, "webhook", {})
config = MockConfig(
hass=hass,
local_sdk_webhook_id="mock-webhook-id",
local_sdk_user_id="mock-user-id",
enabled=False,
)
... | [
"async",
"def",
"test_config_local_sdk_if_disabled",
"(",
"hass",
",",
"hass_client",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"webhook\"",
",",
"{",
"}",
")",
"config",
"=",
"MockConfig",
"(",
"hass",
"=",
"hass",
",",
"local_... | [
132,
0
] | [
162,
35
] | python | en | ['en', 'en', 'en'] | True |
test_agent_user_id_storage | (hass, hass_storage) | Test a disconnect message. | Test a disconnect message. | async def test_agent_user_id_storage(hass, hass_storage):
"""Test a disconnect message."""
hass_storage["google_assistant"] = {
"version": 1,
"key": "google_assistant",
"data": {"agent_user_ids": {"agent_1": {}}},
}
store = helpers.GoogleConfigStore(hass)
await store.async_... | [
"async",
"def",
"test_agent_user_id_storage",
"(",
"hass",
",",
"hass_storage",
")",
":",
"hass_storage",
"[",
"\"google_assistant\"",
"]",
"=",
"{",
"\"version\"",
":",
"1",
",",
"\"key\"",
":",
"\"google_assistant\"",
",",
"\"data\"",
":",
"{",
"\"agent_user_ids... | [
165,
0
] | [
197,
65
] | python | en | ['it', 'en', 'en'] | True |
test_agent_user_id_connect | () | Test the connection and disconnection of users. | Test the connection and disconnection of users. | async def test_agent_user_id_connect():
"""Test the connection and disconnection of users."""
config = MockConfig()
store = config._store
await config.async_connect_agent_user("agent_2")
assert store.add_agent_user_id.call_args == call("agent_2")
await config.async_connect_agent_user("agent_1"... | [
"async",
"def",
"test_agent_user_id_connect",
"(",
")",
":",
"config",
"=",
"MockConfig",
"(",
")",
"store",
"=",
"config",
".",
"_store",
"await",
"config",
".",
"async_connect_agent_user",
"(",
"\"agent_2\"",
")",
"assert",
"store",
".",
"add_agent_user_id",
"... | [
200,
0
] | [
215,
63
] | python | en | ['en', 'en', 'en'] | True |
test_report_state_all | (agents) | Test a disconnect message. | Test a disconnect message. | async def test_report_state_all(agents):
"""Test a disconnect message."""
config = MockConfig(agent_user_ids=agents)
data = {}
with patch.object(config, "async_report_state") as mock:
await config.async_report_state_all(data)
assert sorted(mock.mock_calls) == sorted(call(data, agent) for... | [
"async",
"def",
"test_report_state_all",
"(",
"agents",
")",
":",
"config",
"=",
"MockConfig",
"(",
"agent_user_ids",
"=",
"agents",
")",
"data",
"=",
"{",
"}",
"with",
"patch",
".",
"object",
"(",
"config",
",",
"\"async_report_state\"",
")",
"as",
"mock",
... | [
219,
0
] | [
225,
87
] | python | en | ['it', 'en', 'en'] | True |
test_sync_entities_all | (agents, result) | Test sync entities . | Test sync entities . | async def test_sync_entities_all(agents, result):
"""Test sync entities ."""
config = MockConfig(agent_user_ids=set(agents.keys()))
with patch.object(
config,
"async_sync_entities",
side_effect=lambda agent_user_id: agents[agent_user_id],
) as mock:
res = await config.asy... | [
"async",
"def",
"test_sync_entities_all",
"(",
"agents",
",",
"result",
")",
":",
"config",
"=",
"MockConfig",
"(",
"agent_user_ids",
"=",
"set",
"(",
"agents",
".",
"keys",
"(",
")",
")",
")",
"with",
"patch",
".",
"object",
"(",
"config",
",",
"\"async... | [
232,
0
] | [
242,
28
] | python | en | ['fr', 'en', 'it'] | False |
test_supported_features_string | (caplog) | Test bad supported features. | Test bad supported features. | def test_supported_features_string(caplog):
"""Test bad supported features."""
entity = helpers.GoogleEntity(
None, None, State("test.entity_id", "on", {"supported_features": "invalid"})
)
assert entity.is_supported() is False
assert "Entity test.entity_id contains invalid supported_features... | [
"def",
"test_supported_features_string",
"(",
"caplog",
")",
":",
"entity",
"=",
"helpers",
".",
"GoogleEntity",
"(",
"None",
",",
"None",
",",
"State",
"(",
"\"test.entity_id\"",
",",
"\"on\"",
",",
"{",
"\"supported_features\"",
":",
"\"invalid\"",
"}",
")",
... | [
245,
0
] | [
251,
84
] | python | en | ['en', 'en', 'en'] | True |
device_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"device_reg",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
25,
0
] | [
27,
37
] | python | en | ['en', 'fy', 'en'] | True |
entity_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"entity_reg",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
31,
0
] | [
33,
30
] | python | en | ['en', 'fy', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
37,
0
] | [
39,
57
] | python | en | ['en', 'en', 'en'] | True |
test_get_triggers | (hass, device_reg, entity_reg) | Test we get the expected triggers from a switch. | Test we get the expected triggers from a switch. | async def test_get_triggers(hass, device_reg, entity_reg):
"""Test we get the expected triggers from a switch."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id,
co... | [
"async",
"def",
"test_get_triggers",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
... | [
42,
0
] | [
68,
40
] | python | en | ['en', 'en', 'en'] | True |
test_get_trigger_capabilities | (hass, device_reg, entity_reg) | Test we get the expected capabilities from a switch trigger. | Test we get the expected capabilities from a switch trigger. | async def test_get_trigger_capabilities(hass, device_reg, entity_reg):
"""Test we get the expected capabilities from a switch trigger."""
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_en... | [
"async",
"def",
"test_get_trigger_capabilities",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test\"",
",",
"data",
"=",
"{",
"}",
")",
"config_entry",
".",
"add_to_hass",
"(",
"has... | [
71,
0
] | [
90,
52
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_state_change | (hass, calls, enable_custom_integrations) | Test for turn_on and turn_off triggers firing. | Test for turn_on and turn_off triggers firing. | async def test_if_fires_on_state_change(hass, calls, enable_custom_integrations):
"""Test for turn_on and turn_off triggers firing."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await hass... | [
"async",
"def",
"test_if_fires_on_state_change",
"(",
"hass",
",",
"calls",
",",
"enable_custom_integrations",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"awa... | [
93,
0
] | [
175,
5
] | python | en | ['en', 'en', 'en'] | True |
test_if_fires_on_state_change_with_for | (
hass, calls, enable_custom_integrations
) | Test for triggers firing with delay. | Test for triggers firing with delay. | async def test_if_fires_on_state_change_with_for(
hass, calls, enable_custom_integrations
):
"""Test for triggers firing with delay."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
await... | [
"async",
"def",
"test_if_fires_on_state_change_with_for",
"(",
"hass",
",",
"calls",
",",
"enable_custom_integrations",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert... | [
178,
0
] | [
236,
5
] | python | en | ['en', 'en', 'en'] | True |
create_grid | (resX, resY, resZ, b_min=np.array([0, 0, 0]), b_max=np.array([1, 1, 1]), transform=None) |
Create a dense grid of given resolution and bounding box
:param resX: resolution along X axis
:param resY: resolution along Y axis
:param resZ: resolution along Z axis
:param b_min: vec3 (x_min, y_min, z_min) bounding box corner
:param b_max: vec3 (x_max, y_max, z_max) bounding box corner
:... |
Create a dense grid of given resolution and bounding box
:param resX: resolution along X axis
:param resY: resolution along Y axis
:param resZ: resolution along Z axis
:param b_min: vec3 (x_min, y_min, z_min) bounding box corner
:param b_max: vec3 (x_max, y_max, z_max) bounding box corner
:... | def create_grid(resX, resY, resZ, b_min=np.array([0, 0, 0]), b_max=np.array([1, 1, 1]), transform=None):
'''
Create a dense grid of given resolution and bounding box
:param resX: resolution along X axis
:param resY: resolution along Y axis
:param resZ: resolution along Z axis
:param b_min: vec3 ... | [
"def",
"create_grid",
"(",
"resX",
",",
"resY",
",",
"resZ",
",",
"b_min",
"=",
"np",
".",
"array",
"(",
"[",
"0",
",",
"0",
",",
"0",
"]",
")",
",",
"b_max",
"=",
"np",
".",
"array",
"(",
"[",
"1",
",",
"1",
",",
"1",
"]",
")",
",",
"tra... | [
3,
0
] | [
26,
32
] | python | en | ['en', 'error', 'th'] | False |
test_collect_support_info_support_diag_dump | (support_diag_dump, subprocess) |
collect_suppport_info_method callse _support_diag_dump method.
|
collect_suppport_info_method callse _support_diag_dump method.
| def test_collect_support_info_support_diag_dump(support_diag_dump, subprocess):
"""
collect_suppport_info_method callse _support_diag_dump method.
"""
config = Mock()
support = InsightsSupport(config)
support.collect_support_info()
support_diag_dump.assert_called_once_with() | [
"def",
"test_collect_support_info_support_diag_dump",
"(",
"support_diag_dump",
",",
"subprocess",
")",
":",
"config",
"=",
"Mock",
"(",
")",
"support",
"=",
"InsightsSupport",
"(",
"config",
")",
"support",
".",
"collect_support_info",
"(",
")",
"support_diag_dump",
... | [
10,
0
] | [
18,
47
] | python | en | ['en', 'error', 'th'] | False |
test_support_diag_dump_insights_connection | (insights_connection, registration_check, isfile, popen, statvfs) |
_support_diag_dump method instantiates InsightsConnection with InsightsConfig.
|
_support_diag_dump method instantiates InsightsConnection with InsightsConfig.
| def test_support_diag_dump_insights_connection(insights_connection, registration_check, isfile, popen, statvfs):
"""
_support_diag_dump method instantiates InsightsConnection with InsightsConfig.
"""
config = Mock(**{"return_value.auto_config": "", "proxy": "", "offline": False})
support = InsightsS... | [
"def",
"test_support_diag_dump_insights_connection",
"(",
"insights_connection",
",",
"registration_check",
",",
"isfile",
",",
"popen",
",",
"statvfs",
")",
":",
"config",
"=",
"Mock",
"(",
"*",
"*",
"{",
"\"return_value.auto_config\"",
":",
"\"\"",
",",
"\"proxy\"... | [
26,
0
] | [
34,
55
] | python | en | ['en', 'error', 'th'] | False |
test_registration_check_called_for_support | (registration_check, InsightsConnection) |
Check registration when doing --support
|
Check registration when doing --support
| def test_registration_check_called_for_support(registration_check, InsightsConnection):
'''
Check registration when doing --support
'''
support = InsightsSupport(InsightsConfig(offline=False))
support.collect_support_info()
registration_check.assert_called_once() | [
"def",
"test_registration_check_called_for_support",
"(",
"registration_check",
",",
"InsightsConnection",
")",
":",
"support",
"=",
"InsightsSupport",
"(",
"InsightsConfig",
"(",
"offline",
"=",
"False",
")",
")",
"support",
".",
"collect_support_info",
"(",
")",
"re... | [
39,
0
] | [
45,
43
] | python | en | ['en', 'error', 'th'] | False |
test_support_diag_dump_offline | (test_connection, registration_check, InsightsConnection) |
Check registration when doing --support
|
Check registration when doing --support
| def test_support_diag_dump_offline(test_connection, registration_check, InsightsConnection):
'''
Check registration when doing --support
'''
support = InsightsSupport(InsightsConfig(offline=True))
support.collect_support_info()
InsightsConnection.assert_not_called()
registration_check.as... | [
"def",
"test_support_diag_dump_offline",
"(",
"test_connection",
",",
"registration_check",
",",
"InsightsConnection",
")",
":",
"support",
"=",
"InsightsSupport",
"(",
"InsightsConfig",
"(",
"offline",
"=",
"True",
")",
")",
"support",
".",
"collect_support_info",
"(... | [
51,
0
] | [
59,
39
] | python | en | ['en', 'error', 'th'] | False |
test_registration_check_unregistered | (write_unregistered_file, write_registered_file, _, __) |
Ensure that connection function is called and files are written.
|
Ensure that connection function is called and files are written.
| def test_registration_check_unregistered(write_unregistered_file, write_registered_file, _, __):
'''
Ensure that connection function is called and files are written.
'''
config = Mock(base_url=None, legacy_upload=False)
conn = InsightsConnection(config)
conn.api_registration_check = Mock(return_... | [
"def",
"test_registration_check_unregistered",
"(",
"write_unregistered_file",
",",
"write_registered_file",
",",
"_",
",",
"__",
")",
":",
"config",
"=",
"Mock",
"(",
"base_url",
"=",
"None",
",",
"legacy_upload",
"=",
"False",
")",
"conn",
"=",
"InsightsConnecti... | [
66,
0
] | [
76,
48
] | python | en | ['en', 'error', 'th'] | False |
test_registration_check_registered | (write_unregistered_file, write_registered_file, _, __) |
Ensure that connection function is called and files are written.
|
Ensure that connection function is called and files are written.
| def test_registration_check_registered(write_unregistered_file, write_registered_file, _, __):
'''
Ensure that connection function is called and files are written.
'''
config = Mock(base_url=None, legacy_upload=False)
conn = InsightsConnection(config)
conn.api_registration_check = Mock(return_va... | [
"def",
"test_registration_check_registered",
"(",
"write_unregistered_file",
",",
"write_registered_file",
",",
"_",
",",
"__",
")",
":",
"config",
"=",
"Mock",
"(",
"base_url",
"=",
"None",
",",
"legacy_upload",
"=",
"False",
")",
"conn",
"=",
"InsightsConnection... | [
83,
0
] | [
93,
47
] | python | en | ['en', 'error', 'th'] | False |
test_registration_check_legacy_unregistered | (_, __) |
Ensure that connection function is called and data processed.
|
Ensure that connection function is called and data processed.
| def test_registration_check_legacy_unregistered(_, __):
'''
Ensure that connection function is called and data processed.
'''
config = Mock(base_url=None, legacy_upload=True)
conn = InsightsConnection(config)
conn.api_registration_check = Mock(return_value=None)
assert isinstance(registratio... | [
"def",
"test_registration_check_legacy_unregistered",
"(",
"_",
",",
"__",
")",
":",
"config",
"=",
"Mock",
"(",
"base_url",
"=",
"None",
",",
"legacy_upload",
"=",
"True",
")",
"conn",
"=",
"InsightsConnection",
"(",
"config",
")",
"conn",
".",
"api_registrat... | [
98,
0
] | [
108,
35
] | python | en | ['en', 'error', 'th'] | False |
test_registration_check_legacy_registered_then_unregistered | (_, __) |
Ensure that connection function is called and data processed.
|
Ensure that connection function is called and data processed.
| def test_registration_check_legacy_registered_then_unregistered(_, __):
'''
Ensure that connection function is called and data processed.
'''
config = Mock(base_url=None, legacy_upload=True)
conn = InsightsConnection(config)
conn.api_registration_check = Mock(return_value='datestring')
asser... | [
"def",
"test_registration_check_legacy_registered_then_unregistered",
"(",
"_",
",",
"__",
")",
":",
"config",
"=",
"Mock",
"(",
"base_url",
"=",
"None",
",",
"legacy_upload",
"=",
"True",
")",
"conn",
"=",
"InsightsConnection",
"(",
"config",
")",
"conn",
".",
... | [
113,
0
] | [
123,
35
] | python | en | ['en', 'error', 'th'] | False |
test_registration_check_legacy_registered | (_, __) |
Ensure that connection function is called and data processed.
|
Ensure that connection function is called and data processed.
| def test_registration_check_legacy_registered(_, __):
'''
Ensure that connection function is called and data processed.
'''
config = Mock(base_url=None, legacy_upload=True)
conn = InsightsConnection(config)
conn.api_registration_check = Mock(return_value=True)
check = registration_check(conn... | [
"def",
"test_registration_check_legacy_registered",
"(",
"_",
",",
"__",
")",
":",
"config",
"=",
"Mock",
"(",
"base_url",
"=",
"None",
",",
"legacy_upload",
"=",
"True",
")",
"conn",
"=",
"InsightsConnection",
"(",
"config",
")",
"conn",
".",
"api_registratio... | [
128,
0
] | [
137,
34
] | python | en | ['en', 'error', 'th'] | False |
test_switch_turn_on_off | (hass: HomeAssistant) | Test turning the light on. | Test turning the light on. | async def test_switch_turn_on_off(hass: HomeAssistant) -> None:
"""Test turning the light on."""
client = create_mock_client()
client.async_send_set_component = AsyncMock(return_value=True)
client.components = TEST_COMPONENTS
# Setup component switch.
register_test_entity(
hass,
... | [
"async",
"def",
"test_switch_turn_on_off",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"client",
".",
"async_send_set_component",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"client",
"."... | [
54,
0
] | [
120,
37
] | python | en | ['en', 'en', 'en'] | True |
test_switch_has_correct_entities | (hass: HomeAssistant) | Test that the correct switch entities are created. | Test that the correct switch entities are created. | async def test_switch_has_correct_entities(hass: HomeAssistant) -> None:
"""Test that the correct switch entities are created."""
client = create_mock_client()
client.components = TEST_COMPONENTS
# Setup component switch.
for component in TEST_COMPONENTS:
name = slugify(KEY_COMPONENTID_TO_N... | [
"async",
"def",
"test_switch_has_correct_entities",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"client",
".",
"components",
"=",
"TEST_COMPONENTS",
"# Setup component switch.",
"for",
"component",
"in",
... | [
123,
0
] | [
143,
65
] | python | en | ['en', 'en', 'en'] | True |
test_device_info | (hass: HomeAssistant) | Verify device information includes expected details. | Verify device information includes expected details. | async def test_device_info(hass: HomeAssistant) -> None:
"""Verify device information includes expected details."""
client = create_mock_client()
client.components = TEST_COMPONENTS
for component in TEST_COMPONENTS:
name = slugify(KEY_COMPONENTID_TO_NAME[str(component["name"])])
registe... | [
"async",
"def",
"test_device_info",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"client",
".",
"components",
"=",
"TEST_COMPONENTS",
"for",
"component",
"in",
"TEST_COMPONENTS",
":",
"name",
"=",
"s... | [
146,
0
] | [
183,
48
] | python | en | ['es', 'en', 'en'] | True |
test_switches_can_be_enabled | (hass: HomeAssistant) | Verify switches can be enabled. | Verify switches can be enabled. | async def test_switches_can_be_enabled(hass: HomeAssistant) -> None:
"""Verify switches can be enabled."""
client = create_mock_client()
client.components = TEST_COMPONENTS
await setup_test_config_entry(hass, hyperion_client=client)
entity_registry = er.async_get(hass)
for component in TEST_CO... | [
"async",
"def",
"test_switches_can_be_enabled",
"(",
"hass",
":",
"HomeAssistant",
")",
"->",
"None",
":",
"client",
"=",
"create_mock_client",
"(",
")",
"client",
".",
"components",
"=",
"TEST_COMPONENTS",
"await",
"setup_test_config_entry",
"(",
"hass",
",",
"hy... | [
186,
0
] | [
222,
27
] | python | en | ['en', 'en', 'en'] | True |
drop_hints_from_glyphs | (font) | Drops the hints from a font's glyphs. | Drops the hints from a font's glyphs. | def drop_hints_from_glyphs(font):
"""Drops the hints from a font's glyphs."""
glyf_table = font["glyf"]
for glyph_index in range(len(glyf_table.glyphOrder)):
glyph_name = glyf_table.glyphOrder[glyph_index]
glyph = glyf_table[glyph_name]
if glyph.numberOfContours > 0:
if g... | [
"def",
"drop_hints_from_glyphs",
"(",
"font",
")",
":",
"glyf_table",
"=",
"font",
"[",
"\"glyf\"",
"]",
"for",
"glyph_index",
"in",
"range",
"(",
"len",
"(",
"glyf_table",
".",
"glyphOrder",
")",
")",
":",
"glyph_name",
"=",
"glyf_table",
".",
"glyphOrder",... | [
26,
0
] | [
34,
57
] | python | en | ['en', 'en', 'en'] | True |
drop_tables | (font, tables) | Drops the listed tables from a font. | Drops the listed tables from a font. | def drop_tables(font, tables):
"""Drops the listed tables from a font."""
for table in tables:
if table in font:
del font[table] | [
"def",
"drop_tables",
"(",
"font",
",",
"tables",
")",
":",
"for",
"table",
"in",
"tables",
":",
"if",
"table",
"in",
"font",
":",
"del",
"font",
"[",
"table",
"]"
] | [
37,
0
] | [
41,
27
] | python | en | ['en', 'en', 'en'] | True |
main | (argv) | Drop the hints from the first file specified and save as second. | Drop the hints from the first file specified and save as second. | def main(argv):
"""Drop the hints from the first file specified and save as second."""
font = ttLib.TTFont(argv[1])
drop_hints_from_glyphs(font)
drop_tables(font, ["cvt ", "fpgm", "hdmx", "LTSH", "prep", "VDMX"])
font.save(argv[2]) | [
"def",
"main",
"(",
"argv",
")",
":",
"font",
"=",
"ttLib",
".",
"TTFont",
"(",
"argv",
"[",
"1",
"]",
")",
"drop_hints_from_glyphs",
"(",
"font",
")",
"drop_tables",
"(",
"font",
",",
"[",
"\"cvt \"",
",",
"\"fpgm\"",
",",
"\"hdmx\"",
",",
"\"LTSH\"",... | [
44,
0
] | [
51,
22
] | python | en | ['en', 'en', 'en'] | True |
mock_is_entity_recorded | () | Mock recorder.is_entity_recorded. | Mock recorder.is_entity_recorded. | def mock_is_entity_recorded():
"""Mock recorder.is_entity_recorded."""
mocks = {}
with patch(
"homeassistant.components.recorder.is_entity_recorded",
side_effect=lambda hass, entity_id: mocks.get(entity_id, True),
):
yield mocks | [
"def",
"mock_is_entity_recorded",
"(",
")",
":",
"mocks",
"=",
"{",
"}",
"with",
"patch",
"(",
"\"homeassistant.components.recorder.is_entity_recorded\"",
",",
"side_effect",
"=",
"lambda",
"hass",
",",
"entity_id",
":",
"mocks",
".",
"get",
"(",
"entity_id",
",",... | [
12,
0
] | [
20,
19
] | python | en | ['en', 'en', 'en'] | False |
mock_energy_manager | (hass) | Set up energy. | Set up energy. | async def mock_energy_manager(hass):
"""Set up energy."""
await async_init_recorder_component(hass)
assert await async_setup_component(hass, "energy", {"energy": {}})
manager = await async_get_manager(hass)
manager.data = manager.default_preferences()
return manager | [
"async",
"def",
"mock_energy_manager",
"(",
"hass",
")",
":",
"await",
"async_init_recorder_component",
"(",
"hass",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"energy\"",
",",
"{",
"\"energy\"",
":",
"{",
"}",
"}",
")",
"manager",
"=... | [
24,
0
] | [
30,
18
] | python | en | ['en', 'zu', 'en'] | True |
test_validation_empty_config | (hass) | Test validating an empty config. | Test validating an empty config. | async def test_validation_empty_config(hass):
"""Test validating an empty config."""
assert (await validate.async_validate(hass)).as_dict() == {
"energy_sources": [],
"device_consumption": [],
} | [
"async",
"def",
"test_validation_empty_config",
"(",
"hass",
")",
":",
"assert",
"(",
"await",
"validate",
".",
"async_validate",
"(",
"hass",
")",
")",
".",
"as_dict",
"(",
")",
"==",
"{",
"\"energy_sources\"",
":",
"[",
"]",
",",
"\"device_consumption\"",
... | [
33,
0
] | [
38,
5
] | python | en | ['en', 'en', 'en'] | True |
test_validation | (hass, mock_energy_manager) | Test validating success. | Test validating success. | async def test_validation(hass, mock_energy_manager):
"""Test validating success."""
for key in ("device_cons", "battery_import", "battery_export", "solar_production"):
hass.states.async_set(
f"sensor.{key}",
"123",
{"unit_of_measurement": "kWh", "state_class": "total... | [
"async",
"def",
"test_validation",
"(",
"hass",
",",
"mock_energy_manager",
")",
":",
"for",
"key",
"in",
"(",
"\"device_cons\"",
",",
"\"battery_import\"",
",",
"\"battery_export\"",
",",
"\"solar_production\"",
")",
":",
"hass",
".",
"states",
".",
"async_set",
... | [
41,
0
] | [
66,
5
] | python | en | ['nl', 'ky', 'en'] | False |
test_validation_device_consumption_entity_missing | (hass, mock_energy_manager) | Test validating missing stat for device. | Test validating missing stat for device. | async def test_validation_device_consumption_entity_missing(hass, mock_energy_manager):
"""Test validating missing stat for device."""
await mock_energy_manager.async_update(
{"device_consumption": [{"stat_consumption": "sensor.not_exist"}]}
)
assert (await validate.async_validate(hass)).as_dict... | [
"async",
"def",
"test_validation_device_consumption_entity_missing",
"(",
"hass",
",",
"mock_energy_manager",
")",
":",
"await",
"mock_energy_manager",
".",
"async_update",
"(",
"{",
"\"device_consumption\"",
":",
"[",
"{",
"\"stat_consumption\"",
":",
"\"sensor.not_exist\"... | [
69,
0
] | [
85,
5
] | python | en | ['da', 'en', 'en'] | True |
test_validation_device_consumption_entity_unavailable | (
hass, mock_energy_manager
) | Test validating missing stat for device. | Test validating missing stat for device. | async def test_validation_device_consumption_entity_unavailable(
hass, mock_energy_manager
):
"""Test validating missing stat for device."""
await mock_energy_manager.async_update(
{"device_consumption": [{"stat_consumption": "sensor.unavailable"}]}
)
hass.states.async_set("sensor.unavailabl... | [
"async",
"def",
"test_validation_device_consumption_entity_unavailable",
"(",
"hass",
",",
"mock_energy_manager",
")",
":",
"await",
"mock_energy_manager",
".",
"async_update",
"(",
"{",
"\"device_consumption\"",
":",
"[",
"{",
"\"stat_consumption\"",
":",
"\"sensor.unavail... | [
88,
0
] | [
108,
5
] | python | en | ['da', 'en', 'en'] | True |
test_validation_device_consumption_entity_non_numeric | (
hass, mock_energy_manager
) | Test validating missing stat for device. | Test validating missing stat for device. | async def test_validation_device_consumption_entity_non_numeric(
hass, mock_energy_manager
):
"""Test validating missing stat for device."""
await mock_energy_manager.async_update(
{"device_consumption": [{"stat_consumption": "sensor.non_numeric"}]}
)
hass.states.async_set("sensor.non_numeri... | [
"async",
"def",
"test_validation_device_consumption_entity_non_numeric",
"(",
"hass",
",",
"mock_energy_manager",
")",
":",
"await",
"mock_energy_manager",
".",
"async_update",
"(",
"{",
"\"device_consumption\"",
":",
"[",
"{",
"\"stat_consumption\"",
":",
"\"sensor.non_num... | [
111,
0
] | [
131,
5
] | python | en | ['da', 'en', 'en'] | True |
test_validation_device_consumption_entity_unexpected_unit | (
hass, mock_energy_manager
) | Test validating missing stat for device. | Test validating missing stat for device. | async def test_validation_device_consumption_entity_unexpected_unit(
hass, mock_energy_manager
):
"""Test validating missing stat for device."""
await mock_energy_manager.async_update(
{"device_consumption": [{"stat_consumption": "sensor.unexpected_unit"}]}
)
hass.states.async_set(
"... | [
"async",
"def",
"test_validation_device_consumption_entity_unexpected_unit",
"(",
"hass",
",",
"mock_energy_manager",
")",
":",
"await",
"mock_energy_manager",
".",
"async_update",
"(",
"{",
"\"device_consumption\"",
":",
"[",
"{",
"\"stat_consumption\"",
":",
"\"sensor.une... | [
134,
0
] | [
158,
5
] | python | en | ['da', 'en', 'en'] | True |
test_validation_device_consumption_recorder_not_tracked | (
hass, mock_energy_manager, mock_is_entity_recorded
) | Test validating device based on untracked entity. | Test validating device based on untracked entity. | async def test_validation_device_consumption_recorder_not_tracked(
hass, mock_energy_manager, mock_is_entity_recorded
):
"""Test validating device based on untracked entity."""
mock_is_entity_recorded["sensor.not_recorded"] = False
await mock_energy_manager.async_update(
{"device_consumption": [... | [
"async",
"def",
"test_validation_device_consumption_recorder_not_tracked",
"(",
"hass",
",",
"mock_energy_manager",
",",
"mock_is_entity_recorded",
")",
":",
"mock_is_entity_recorded",
"[",
"\"sensor.not_recorded\"",
"]",
"=",
"False",
"await",
"mock_energy_manager",
".",
"as... | [
161,
0
] | [
181,
5
] | python | en | ['en', 'en', 'en'] | True |
test_validation_solar | (hass, mock_energy_manager) | Test validating missing stat for device. | Test validating missing stat for device. | async def test_validation_solar(hass, mock_energy_manager):
"""Test validating missing stat for device."""
await mock_energy_manager.async_update(
{
"energy_sources": [
{"type": "solar", "stat_energy_from": "sensor.solar_production"}
]
}
)
hass.sta... | [
"async",
"def",
"test_validation_solar",
"(",
"hass",
",",
"mock_energy_manager",
")",
":",
"await",
"mock_energy_manager",
".",
"async_update",
"(",
"{",
"\"energy_sources\"",
":",
"[",
"{",
"\"type\"",
":",
"\"solar\"",
",",
"\"stat_energy_from\"",
":",
"\"sensor.... | [
184,
0
] | [
210,
5
] | python | en | ['da', 'en', 'en'] | True |
test_validation_battery | (hass, mock_energy_manager) | Test validating missing stat for device. | Test validating missing stat for device. | async def test_validation_battery(hass, mock_energy_manager):
"""Test validating missing stat for device."""
await mock_energy_manager.async_update(
{
"energy_sources": [
{
"type": "battery",
"stat_energy_from": "sensor.battery_import",... | [
"async",
"def",
"test_validation_battery",
"(",
"hass",
",",
"mock_energy_manager",
")",
":",
"await",
"mock_energy_manager",
".",
"async_update",
"(",
"{",
"\"energy_sources\"",
":",
"[",
"{",
"\"type\"",
":",
"\"battery\"",
",",
"\"stat_energy_from\"",
":",
"\"sen... | [
213,
0
] | [
253,
5
] | python | en | ['da', 'en', 'en'] | True |
test_validation_grid | (hass, mock_energy_manager, mock_is_entity_recorded) | Test validating grid with sensors for energy and cost/compensation. | Test validating grid with sensors for energy and cost/compensation. | async def test_validation_grid(hass, mock_energy_manager, mock_is_entity_recorded):
"""Test validating grid with sensors for energy and cost/compensation."""
mock_is_entity_recorded["sensor.grid_cost_1"] = False
mock_is_entity_recorded["sensor.grid_compensation_1"] = False
await mock_energy_manager.asyn... | [
"async",
"def",
"test_validation_grid",
"(",
"hass",
",",
"mock_energy_manager",
",",
"mock_is_entity_recorded",
")",
":",
"mock_is_entity_recorded",
"[",
"\"sensor.grid_cost_1\"",
"]",
"=",
"False",
"mock_is_entity_recorded",
"[",
"\"sensor.grid_compensation_1\"",
"]",
"="... | [
256,
0
] | [
318,
5
] | python | en | ['en', 'en', 'en'] | True |
test_validation_grid_price_not_exist | (hass, mock_energy_manager) | Test validating grid with price entity that does not exist. | Test validating grid with price entity that does not exist. | async def test_validation_grid_price_not_exist(hass, mock_energy_manager):
"""Test validating grid with price entity that does not exist."""
hass.states.async_set(
"sensor.grid_consumption_1",
"10.10",
{"unit_of_measurement": "kWh", "state_class": "total_increasing"},
)
hass.stat... | [
"async",
"def",
"test_validation_grid_price_not_exist",
"(",
"hass",
",",
"mock_energy_manager",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.grid_consumption_1\"",
",",
"\"10.10\"",
",",
"{",
"\"unit_of_measurement\"",
":",
"\"kWh\"",
",",
"\"sta... | [
321,
0
] | [
371,
5
] | python | en | ['en', 'en', 'en'] | True |
test_validation_grid_price_errors | (
hass, mock_energy_manager, state, unit, expected
) | Test validating grid with price data that gives errors. | Test validating grid with price data that gives errors. | async def test_validation_grid_price_errors(
hass, mock_energy_manager, state, unit, expected
):
"""Test validating grid with price data that gives errors."""
hass.states.async_set(
"sensor.grid_consumption_1",
"10.10",
{"unit_of_measurement": "kWh", "state_class": "total_increasing"... | [
"async",
"def",
"test_validation_grid_price_errors",
"(",
"hass",
",",
"mock_energy_manager",
",",
"state",
",",
"unit",
",",
"expected",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.grid_consumption_1\"",
",",
"\"10.10\"",
",",
"{",
"\"unit_o... | [
397,
0
] | [
436,
5
] | python | en | ['en', 'en', 'en'] | True |
test_validation_gas | (hass, mock_energy_manager, mock_is_entity_recorded) | Test validating gas with sensors for energy and cost/compensation. | Test validating gas with sensors for energy and cost/compensation. | async def test_validation_gas(hass, mock_energy_manager, mock_is_entity_recorded):
"""Test validating gas with sensors for energy and cost/compensation."""
mock_is_entity_recorded["sensor.gas_cost_1"] = False
mock_is_entity_recorded["sensor.gas_compensation_1"] = False
await mock_energy_manager.async_up... | [
"async",
"def",
"test_validation_gas",
"(",
"hass",
",",
"mock_energy_manager",
",",
"mock_is_entity_recorded",
")",
":",
"mock_is_entity_recorded",
"[",
"\"sensor.gas_cost_1\"",
"]",
"=",
"False",
"mock_is_entity_recorded",
"[",
"\"sensor.gas_compensation_1\"",
"]",
"=",
... | [
439,
0
] | [
492,
5
] | python | en | ['en', 'en', 'en'] | True |
setup_rainforest_200 | (hass) | Set up rainforest. | Set up rainforest. | async def setup_rainforest_200(hass):
"""Set up rainforest."""
MockConfigEntry(
domain="rainforest_eagle",
data={
CONF_CLOUD_ID: MOCK_CLOUD_ID,
CONF_HOST: "192.168.1.55",
CONF_INSTALL_CODE: "abcdefgh",
CONF_HARDWARE_ADDRESS: "mock-hw-address",
... | [
"async",
"def",
"setup_rainforest_200",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"rainforest_eagle\"",
",",
"data",
"=",
"{",
"CONF_CLOUD_ID",
":",
"MOCK_CLOUD_ID",
",",
"CONF_HOST",
":",
"\"192.168.1.55\"",
",",
"CONF_INSTALL_CODE",
":",
"\... | [
54,
0
] | [
75,
38
] | python | en | ['en', 'lb', 'en'] | True |
setup_rainforest_100 | (hass) | Set up rainforest. | Set up rainforest. | async def setup_rainforest_100(hass):
"""Set up rainforest."""
MockConfigEntry(
domain="rainforest_eagle",
data={
CONF_CLOUD_ID: MOCK_CLOUD_ID,
CONF_HOST: "192.168.1.55",
CONF_INSTALL_CODE: "abcdefgh",
CONF_HARDWARE_ADDRESS: None,
CONF_... | [
"async",
"def",
"setup_rainforest_100",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"\"rainforest_eagle\"",
",",
"data",
"=",
"{",
"CONF_CLOUD_ID",
":",
"MOCK_CLOUD_ID",
",",
"CONF_HOST",
":",
"\"192.168.1.55\"",
",",
"CONF_INSTALL_CODE",
":",
"\... | [
79,
0
] | [
109,
25
] | python | en | ['en', 'lb', 'en'] | True |
test_sensors_200 | (hass, setup_rainforest_200) | Test the sensors. | Test the sensors. | async def test_sensors_200(hass, setup_rainforest_200):
"""Test the sensors."""
assert len(hass.states.async_all()) == 3
demand = hass.states.get("sensor.eagle_200_meter_power_demand")
assert demand is not None
assert demand.state == "1.152000"
assert demand.attributes["unit_of_measurement"] ==... | [
"async",
"def",
"test_sensors_200",
"(",
"hass",
",",
"setup_rainforest_200",
")",
":",
"assert",
"len",
"(",
"hass",
".",
"states",
".",
"async_all",
"(",
")",
")",
"==",
"3",
"demand",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"sensor.eagle_200_mete... | [
112,
0
] | [
142,
63
] | python | en | ['en', 'sq', 'en'] | True |
test_sensors_100 | (hass, setup_rainforest_100) | Test the sensors. | Test the sensors. | async def test_sensors_100(hass, setup_rainforest_100):
"""Test the sensors."""
assert len(hass.states.async_all()) == 3
demand = hass.states.get("sensor.eagle_200_meter_power_demand")
assert demand is not None
assert demand.state == "1.152000"
assert demand.attributes["unit_of_measurement"] ==... | [
"async",
"def",
"test_sensors_100",
"(",
"hass",
",",
"setup_rainforest_100",
")",
":",
"assert",
"len",
"(",
"hass",
".",
"states",
".",
"async_all",
"(",
")",
")",
"==",
"3",
"demand",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"sensor.eagle_200_mete... | [
145,
0
] | [
162,
62
] | python | en | ['en', 'sq', 'en'] | True |
create_user | (user) | Create user
This can only be done by the logged in user. # noqa: E501
:param user: Created user object
:type user: dict | bytes
:rtype: None
| Create user | def create_user(user): # noqa: E501
"""Create user
This can only be done by the logged in user. # noqa: E501
:param user: Created user object
:type user: dict | bytes
:rtype: None
"""
if connexion.request.is_json:
user = User.from_dict(connexion.request.get_json()) # noqa: E501
... | [
"def",
"create_user",
"(",
"user",
")",
":",
"# noqa: E501",
"if",
"connexion",
".",
"request",
".",
"is_json",
":",
"user",
"=",
"User",
".",
"from_dict",
"(",
"connexion",
".",
"request",
".",
"get_json",
"(",
")",
")",
"# noqa: E501",
"return",
"'do som... | [
7,
0
] | [
19,
27
] | python | en | ['en', 'la', 'en'] | False |
create_users_with_array_input | (user) | Creates list of users with given input array
# noqa: E501
:param user: List of user objects
:type user: list | bytes
:rtype: None
| Creates list of users with given input array | def create_users_with_array_input(user): # noqa: E501
"""Creates list of users with given input array
# noqa: E501
:param user: List of user objects
:type user: list | bytes
:rtype: None
"""
if connexion.request.is_json:
user = [User.from_dict(d) for d in connexion.request.get_j... | [
"def",
"create_users_with_array_input",
"(",
"user",
")",
":",
"# noqa: E501",
"if",
"connexion",
".",
"request",
".",
"is_json",
":",
"user",
"=",
"[",
"User",
".",
"from_dict",
"(",
"d",
")",
"for",
"d",
"in",
"connexion",
".",
"request",
".",
"get_json"... | [
22,
0
] | [
34,
27
] | python | en | ['en', 'en', 'en'] | True |
create_users_with_list_input | (user) | Creates list of users with given input array
# noqa: E501
:param user: List of user objects
:type user: list | bytes
:rtype: None
| Creates list of users with given input array | def create_users_with_list_input(user): # noqa: E501
"""Creates list of users with given input array
# noqa: E501
:param user: List of user objects
:type user: list | bytes
:rtype: None
"""
if connexion.request.is_json:
user = [User.from_dict(d) for d in connexion.request.get_js... | [
"def",
"create_users_with_list_input",
"(",
"user",
")",
":",
"# noqa: E501",
"if",
"connexion",
".",
"request",
".",
"is_json",
":",
"user",
"=",
"[",
"User",
".",
"from_dict",
"(",
"d",
")",
"for",
"d",
"in",
"connexion",
".",
"request",
".",
"get_json",... | [
37,
0
] | [
49,
27
] | 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.