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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
UniFiDeviceTracker._make_disconnected | (self, *_) | No heart beat by device. | No heart beat by device. | def _make_disconnected(self, *_):
"""No heart beat by device."""
self._is_connected = False
self.async_write_ha_state() | [
"def",
"_make_disconnected",
"(",
"self",
",",
"*",
"_",
")",
":",
"self",
".",
"_is_connected",
"=",
"False",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
372,
4
] | [
375,
35
] | python | en | ['en', 'en', 'en'] | True |
UniFiDeviceTracker.is_connected | (self) | Return true if the device is connected to the network. | Return true if the device is connected to the network. | def is_connected(self):
"""Return true if the device is connected to the network."""
return self._is_connected | [
"def",
"is_connected",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_connected"
] | [
378,
4
] | [
380,
33
] | python | en | ['en', 'en', 'en'] | True |
UniFiDeviceTracker.source_type | (self) | Return the source type of the device. | Return the source type of the device. | def source_type(self):
"""Return the source type of the device."""
return SOURCE_TYPE_ROUTER | [
"def",
"source_type",
"(",
"self",
")",
":",
"return",
"SOURCE_TYPE_ROUTER"
] | [
383,
4
] | [
385,
33
] | python | en | ['en', 'en', 'en'] | True |
UniFiDeviceTracker.name | (self) | Return the name of the device. | Return the name of the device. | def name(self) -> str:
"""Return the name of the device."""
return self.device.name or self.device.model | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"device",
".",
"name",
"or",
"self",
".",
"device",
".",
"model"
] | [
388,
4
] | [
390,
52
] | python | en | ['en', 'en', 'en'] | True |
UniFiDeviceTracker.unique_id | (self) | Return a unique identifier for this device. | Return a unique identifier for this device. | def unique_id(self) -> str:
"""Return a unique identifier for this device."""
return self.device.mac | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"device",
".",
"mac"
] | [
393,
4
] | [
395,
30
] | python | en | ['en', 'en', 'en'] | True |
UniFiDeviceTracker.available | (self) | Return if controller is available. | Return if controller is available. | def available(self) -> bool:
"""Return if controller is available."""
return not self.device.disabled and self.controller.available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"not",
"self",
".",
"device",
".",
"disabled",
"and",
"self",
".",
"controller",
".",
"available"
] | [
398,
4
] | [
400,
69
] | python | en | ['en', 'en', 'en'] | True |
UniFiDeviceTracker.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
info = {
"connections": {(CONNECTION_NETWORK_MAC, self.device.mac)},
"manufacturer": ATTR_MANUFACTURER,
"model": self.device.model,
"sw_version": self.device.version,
}
... | [
"def",
"device_info",
"(",
"self",
")",
":",
"info",
"=",
"{",
"\"connections\"",
":",
"{",
"(",
"CONNECTION_NETWORK_MAC",
",",
"self",
".",
"device",
".",
"mac",
")",
"}",
",",
"\"manufacturer\"",
":",
"ATTR_MANUFACTURER",
",",
"\"model\"",
":",
"self",
"... | [
403,
4
] | [
415,
19
] | python | en | ['ro', 'fr', 'en'] | False |
UniFiDeviceTracker.async_update_device_registry | (self) | Update device registry. | Update device registry. | async def async_update_device_registry(self) -> None:
"""Update device registry."""
device_registry = await self.hass.helpers.device_registry.async_get_registry()
device_registry.async_get_or_create(
config_entry_id=self.controller.config_entry.entry_id, **self.device_info
) | [
"async",
"def",
"async_update_device_registry",
"(",
"self",
")",
"->",
"None",
":",
"device_registry",
"=",
"await",
"self",
".",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_get_registry",
"(",
")",
"device_registry",
".",
"async_get_or_create",
"... | [
417,
4
] | [
423,
9
] | python | en | ['fr', 'fy', 'en'] | False |
UniFiDeviceTracker.extra_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def extra_state_attributes(self):
"""Return the device state attributes."""
if self.device.state == 0:
return {}
attributes = {}
if self.device.has_fan:
attributes["fan_level"] = self.device.fan_level
if self.device.overheating:
attributes["... | [
"def",
"extra_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"device",
".",
"state",
"==",
"0",
":",
"return",
"{",
"}",
"attributes",
"=",
"{",
"}",
"if",
"self",
".",
"device",
".",
"has_fan",
":",
"attributes",
"[",
"\"fan_level\"",
"]... | [
426,
4
] | [
442,
25
] | python | en | ['en', 'en', 'en'] | True |
UniFiDeviceTracker.options_updated | (self) | Config entry options are updated, remove entity if option is disabled. | Config entry options are updated, remove entity if option is disabled. | async def options_updated(self) -> None:
"""Config entry options are updated, remove entity if option is disabled."""
if not self.controller.option_track_devices:
await self.remove_item({self.device.mac}) | [
"async",
"def",
"options_updated",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"controller",
".",
"option_track_devices",
":",
"await",
"self",
".",
"remove_item",
"(",
"{",
"self",
".",
"device",
".",
"mac",
"}",
")"
] | [
444,
4
] | [
447,
53
] | python | en | ['en', 'en', 'en'] | True |
create_api_device | (host) | Create an API Device. | Create an API Device. | def create_api_device(host):
"""Create an API Device."""
try:
device = pywilight.device_from_host(host)
except (
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,
) as err:
_LOGGER.error("Unable to access WiLight at %s (%s)", host, err)
return None... | [
"def",
"create_api_device",
"(",
"host",
")",
":",
"try",
":",
"device",
"=",
"pywilight",
".",
"device_from_host",
"(",
"host",
")",
"except",
"(",
"requests",
".",
"exceptions",
".",
"ConnectionError",
",",
"requests",
".",
"exceptions",
".",
"Timeout",
",... | [
91,
0
] | [
102,
17
] | python | en | ['en', 'haw', 'en'] | True |
WiLightParent.__init__ | (self, hass, config_entry) | Initialize the system. | Initialize the system. | def __init__(self, hass, config_entry):
"""Initialize the system."""
self._host = config_entry.data[CONF_HOST]
self._hass = hass
self._api = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config_entry",
")",
":",
"self",
".",
"_host",
"=",
"config_entry",
".",
"data",
"[",
"CONF_HOST",
"]",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_api",
"=",
"None"
] | [
17,
4
] | [
21,
24
] | python | en | ['en', 'en', 'en'] | True |
WiLightParent.host | (self) | Return the host of this parent. | Return the host of this parent. | def host(self):
"""Return the host of this parent."""
return self._host | [
"def",
"host",
"(",
"self",
")",
":",
"return",
"self",
".",
"_host"
] | [
24,
4
] | [
26,
25
] | python | en | ['en', 'en', 'en'] | True |
WiLightParent.api | (self) | Return the api of this parent. | Return the api of this parent. | def api(self):
"""Return the api of this parent."""
return self._api | [
"def",
"api",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api"
] | [
29,
4
] | [
31,
24
] | python | en | ['en', 'la', 'en'] | True |
WiLightParent.async_setup | (self) | Set up a WiLight Parent Device based on host parameter. | Set up a WiLight Parent Device based on host parameter. | async def async_setup(self):
"""Set up a WiLight Parent Device based on host parameter."""
host = self._host
hass = self._hass
api_device = await hass.async_add_executor_job(create_api_device, host)
if api_device is None:
return False
@callback
def ... | [
"async",
"def",
"async_setup",
"(",
"self",
")",
":",
"host",
"=",
"self",
".",
"_host",
"hass",
"=",
"self",
".",
"_hass",
"api_device",
"=",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"create_api_device",
",",
"host",
")",
"if",
"api_device",
"... | [
33,
4
] | [
81,
19
] | python | en | ['en', 'en', 'en'] | True |
develop._resolve_setup_path | (egg_base, install_dir, egg_path) |
Generate a path from egg_base back to '.' where the
setup script resides and ensure that path points to the
setup path from $install_dir/$egg_path.
|
Generate a path from egg_base back to '.' where the
setup script resides and ensure that path points to the
setup path from $install_dir/$egg_path.
| def _resolve_setup_path(egg_base, install_dir, egg_path):
"""
Generate a path from egg_base back to '.' where the
setup script resides and ensure that path points to the
setup path from $install_dir/$egg_path.
"""
path_to_setup = egg_base.replace(os.sep, '/').rstrip('/')
... | [
"def",
"_resolve_setup_path",
"(",
"egg_base",
",",
"install_dir",
",",
"egg_path",
")",
":",
"path_to_setup",
"=",
"egg_base",
".",
"replace",
"(",
"os",
".",
"sep",
",",
"'/'",
")",
".",
"rstrip",
"(",
"'/'",
")",
"if",
"path_to_setup",
"!=",
"os",
"."... | [
86,
4
] | [
103,
28
] | python | en | ['en', 'error', 'th'] | False |
filepath_from_subprocess_output | (output) |
Convert `bytes` in the encoding used by a subprocess into a filesystem-appropriate `str`.
Inherited from `exec_command`, and possibly incorrect.
|
Convert `bytes` in the encoding used by a subprocess into a filesystem-appropriate `str`. | def filepath_from_subprocess_output(output):
"""
Convert `bytes` in the encoding used by a subprocess into a filesystem-appropriate `str`.
Inherited from `exec_command`, and possibly incorrect.
"""
mylocale = locale.getpreferredencoding(False)
if mylocale is None:
mylocale = 'ascii'
... | [
"def",
"filepath_from_subprocess_output",
"(",
"output",
")",
":",
"mylocale",
"=",
"locale",
".",
"getpreferredencoding",
"(",
"False",
")",
"if",
"mylocale",
"is",
"None",
":",
"mylocale",
"=",
"'ascii'",
"output",
"=",
"output",
".",
"decode",
"(",
"mylocal... | [
62,
0
] | [
76,
17
] | python | en | ['en', 'error', 'th'] | False |
forward_bytes_to_stdout | (val) |
Forward bytes from a subprocess call to the console, without attempting to
decode them.
The assumption is that the subprocess call already returned bytes in
a suitable encoding.
|
Forward bytes from a subprocess call to the console, without attempting to
decode them. | def forward_bytes_to_stdout(val):
"""
Forward bytes from a subprocess call to the console, without attempting to
decode them.
The assumption is that the subprocess call already returned bytes in
a suitable encoding.
"""
if hasattr(sys.stdout, 'buffer'):
# use the underlying binary o... | [
"def",
"forward_bytes_to_stdout",
"(",
"val",
")",
":",
"if",
"hasattr",
"(",
"sys",
".",
"stdout",
",",
"'buffer'",
")",
":",
"# use the underlying binary output if there is one",
"sys",
".",
"stdout",
".",
"buffer",
".",
"write",
"(",
"val",
")",
"elif",
"ha... | [
79,
0
] | [
95,
62
] | python | en | ['en', 'error', 'th'] | False |
find_executable | (exe, path=None, _cache={}) | Return full path of a executable or None.
Symbolic links are not followed.
| Return full path of a executable or None. | def find_executable(exe, path=None, _cache={}):
"""Return full path of a executable or None.
Symbolic links are not followed.
"""
key = exe, path
try:
return _cache[key]
except KeyError:
pass
log.debug('find_executable(%r)' % exe)
orig_exe = exe
if path is None:
... | [
"def",
"find_executable",
"(",
"exe",
",",
"path",
"=",
"None",
",",
"_cache",
"=",
"{",
"}",
")",
":",
"key",
"=",
"exe",
",",
"path",
"try",
":",
"return",
"_cache",
"[",
"key",
"]",
"except",
"KeyError",
":",
"pass",
"log",
".",
"debug",
"(",
... | [
115,
0
] | [
162,
15
] | python | en | ['en', 'en', 'en'] | True |
exec_command | (command, execute_in='', use_shell=None, use_tee=None,
_with_python = 1, **env ) |
Return (status,output) of executed command.
.. deprecated:: 1.17
Use subprocess.Popen instead
Parameters
----------
command : str
A concatenated string of executable and arguments.
execute_in : str
Before running command ``cd execute_in`` and after ``cd -``.
use_sh... |
Return (status,output) of executed command. | def exec_command(command, execute_in='', use_shell=None, use_tee=None,
_with_python = 1, **env ):
"""
Return (status,output) of executed command.
.. deprecated:: 1.17
Use subprocess.Popen instead
Parameters
----------
command : str
A concatenated string of exec... | [
"def",
"exec_command",
"(",
"command",
",",
"execute_in",
"=",
"''",
",",
"use_shell",
"=",
"None",
",",
"use_tee",
"=",
"None",
",",
"_with_python",
"=",
"1",
",",
"*",
"*",
"env",
")",
":",
"# 2019-01-30, 1.17",
"warnings",
".",
"warn",
"(",
"'exec_com... | [
176,
0
] | [
249,
13
] | python | en | ['en', 'error', 'th'] | False |
_exec_command | (command, use_shell=None, use_tee = None, **env) |
Internal workhorse for exec_command().
|
Internal workhorse for exec_command().
| def _exec_command(command, use_shell=None, use_tee = None, **env):
"""
Internal workhorse for exec_command().
"""
if use_shell is None:
use_shell = os.name=='posix'
if use_tee is None:
use_tee = os.name=='posix'
if os.name == 'posix' and use_shell:
# On POSIX, subprocess... | [
"def",
"_exec_command",
"(",
"command",
",",
"use_shell",
"=",
"None",
",",
"use_tee",
"=",
"None",
",",
"*",
"*",
"env",
")",
":",
"if",
"use_shell",
"is",
"None",
":",
"use_shell",
"=",
"os",
".",
"name",
"==",
"'posix'",
"if",
"use_tee",
"is",
"No... | [
252,
0
] | [
302,
32
] | python | en | ['en', 'error', 'th'] | False |
_quote_arg | (arg) |
Quote the argument for safe use in a shell command line.
|
Quote the argument for safe use in a shell command line.
| def _quote_arg(arg):
"""
Quote the argument for safe use in a shell command line.
"""
# If there is a quote in the string, assume relevants parts of the
# string are already quoted (e.g. '-I"C:\\Program Files\\..."')
if '"' not in arg and ' ' in arg:
return '"%s"' % arg
return arg | [
"def",
"_quote_arg",
"(",
"arg",
")",
":",
"# If there is a quote in the string, assume relevants parts of the",
"# string are already quoted (e.g. '-I\"C:\\\\Program Files\\\\...\"')",
"if",
"'\"'",
"not",
"in",
"arg",
"and",
"' '",
"in",
"arg",
":",
"return",
"'\"%s\"'",
"%... | [
305,
0
] | [
313,
14
] | python | en | ['en', 'error', 'th'] | False |
one_line | (text) | Turns multiline PromQL string into a one line.
Useful to keep sane diffs for generated (*.json) dashboards.
| Turns multiline PromQL string into a one line. | def one_line(text):
"""Turns multiline PromQL string into a one line.
Useful to keep sane diffs for generated (*.json) dashboards.
"""
tokens = text.split('"')
for i, item in enumerate(tokens):
if not i % 2:
item = re.sub(r"\s+", "", item)
item = re.sub(",", ", ", it... | [
"def",
"one_line",
"(",
"text",
")",
":",
"tokens",
"=",
"text",
".",
"split",
"(",
"'\"'",
")",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"tokens",
")",
":",
"if",
"not",
"i",
"%",
"2",
":",
"item",
"=",
"re",
".",
"sub",
"(",
"r\"\\s+\... | [
98,
0
] | [
110,
27
] | python | en | ['en', 'en', 'en'] | True |
AppleReq.openapi_types | () |
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
|
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded | def openapi_types():
"""
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
Returns
openapi_types (dict): The key is attribute name
and the value is attribute type.
"""
retu... | [
"def",
"openapi_types",
"(",
")",
":",
"return",
"{",
"'cultivar'",
":",
"(",
"str",
",",
")",
",",
"# noqa: E501",
"'mealy'",
":",
"(",
"bool",
",",
")",
",",
"# noqa: E501",
"}"
] | [
64,
4
] | [
76,
9
] | python | en | ['en', 'error', 'th'] | False |
AppleReq.__init__ | (self, cultivar, *args, **kwargs) | AppleReq - a model defined in OpenAPI
Args:
cultivar (str):
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
raised if the wrong type is... | AppleReq - a model defined in OpenAPI | def __init__(self, cultivar, *args, **kwargs): # noqa: E501
"""AppleReq - a model defined in OpenAPI
Args:
cultivar (str):
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeE... | [
"def",
"__init__",
"(",
"self",
",",
"cultivar",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"_check_type",
"=",
"kwargs",
".",
"pop",
"(",
"'_check_type'",
",",
"True",
")",
"_spec_property_naming",
"=",
"kwargs",
".",
"pop",
"(... | [
100,
4
] | [
171,
46
] | python | en | ['en', 'fy', 'en'] | True |
WRT3200ACM.wait_for_boot | (self) | Power-cycle this device. | Power-cycle this device. | def wait_for_boot(self):
'''Power-cycle this device.'''
self.power.reset()
self.expect_exact('General initialization - Version: 1.0.0')
for not_used in range(10):
self.expect(pexpect.TIMEOUT, timeout=0.1)
self.sendline('echo FOO')
if 0 != self.expect(... | [
"def",
"wait_for_boot",
"(",
"self",
")",
":",
"self",
".",
"power",
".",
"reset",
"(",
")",
"self",
".",
"expect_exact",
"(",
"'General initialization - Version: 1.0.0'",
")",
"for",
"not_used",
"in",
"range",
"(",
"10",
")",
":",
"self",
".",
"expect",
"... | [
28,
4
] | [
42,
25
] | python | en | ['en', 'en', 'en'] | True |
async_setup_ha_cast | (
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
) | Set up Home Assistant Cast. | Set up Home Assistant Cast. | async def async_setup_ha_cast(
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
):
"""Set up Home Assistant Cast."""
user_id: str | None = entry.data.get("user_id")
user: auth.models.User | None = None
if user_id is not None:
user = await hass.auth.async_get_user(user_id)
if... | [
"async",
"def",
"async_setup_ha_cast",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"user_id",
":",
"str",
"|",
"None",
"=",
"entry",
".",
"data",
".",
"get",
"(",
"\"user_id\"",
")",
... | [
18,
0
] | [
73,
5
] | python | en | ['en', 'fr', 'en'] | True |
async_remove_user | (
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
) | Remove Home Assistant Cast user. | Remove Home Assistant Cast user. | async def async_remove_user(
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
):
"""Remove Home Assistant Cast user."""
user_id: str | None = entry.data.get("user_id")
if user_id is not None:
user = await hass.auth.async_get_user(user_id)
if user:
await hass.auth.... | [
"async",
"def",
"async_remove_user",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"user_id",
":",
"str",
"|",
"None",
"=",
"entry",
".",
"data",
".",
"get",
"(",
"\"user_id\"",
")",
"i... | [
76,
0
] | [
85,
51
] | python | en | ['fr', 'en', 'en'] | True |
_get_mro | (cls) |
Returns the bases classes for cls sorted by the MRO.
Works around an issue on Jython where inspect.getmro will not return all
base classes if multiple classes share the same name. Instead, this
function will return a tuple containing the class itself, and the contents
of cls.__bases__. See https:/... |
Returns the bases classes for cls sorted by the MRO. | def _get_mro(cls):
"""
Returns the bases classes for cls sorted by the MRO.
Works around an issue on Jython where inspect.getmro will not return all
base classes if multiple classes share the same name. Instead, this
function will return a tuple containing the class itself, and the contents
of ... | [
"def",
"_get_mro",
"(",
"cls",
")",
":",
"if",
"platform",
".",
"python_implementation",
"(",
")",
"==",
"\"Jython\"",
":",
"return",
"(",
"cls",
",",
")",
"+",
"cls",
".",
"__bases__",
"return",
"inspect",
".",
"getmro",
"(",
"cls",
")"
] | [
21,
0
] | [
32,
30
] | python | en | ['en', 'error', 'th'] | False |
get_unpatched_class | (cls) | Protect against re-patching the distutils if reloaded
Also ensures that no other distutils extension monkeypatched the distutils
first.
| Protect against re-patching the distutils if reloaded | def get_unpatched_class(cls):
"""Protect against re-patching the distutils if reloaded
Also ensures that no other distutils extension monkeypatched the distutils
first.
"""
external_bases = (
cls
for cls in _get_mro(cls)
if not cls.__module__.startswith('setuptools')
)
... | [
"def",
"get_unpatched_class",
"(",
"cls",
")",
":",
"external_bases",
"=",
"(",
"cls",
"for",
"cls",
"in",
"_get_mro",
"(",
"cls",
")",
"if",
"not",
"cls",
".",
"__module__",
".",
"startswith",
"(",
"'setuptools'",
")",
")",
"base",
"=",
"next",
"(",
"... | [
44,
0
] | [
59,
15
] | python | en | ['en', 'en', 'en'] | True |
_patch_distribution_metadata | () | Patch write_pkg_file and read_pkg_file for higher metadata standards | Patch write_pkg_file and read_pkg_file for higher metadata standards | def _patch_distribution_metadata():
"""Patch write_pkg_file and read_pkg_file for higher metadata standards"""
for attr in ('write_pkg_file', 'read_pkg_file', 'get_metadata_version'):
new_val = getattr(setuptools.dist, attr)
setattr(distutils.dist.DistributionMetadata, attr, new_val) | [
"def",
"_patch_distribution_metadata",
"(",
")",
":",
"for",
"attr",
"in",
"(",
"'write_pkg_file'",
",",
"'read_pkg_file'",
",",
"'get_metadata_version'",
")",
":",
"new_val",
"=",
"getattr",
"(",
"setuptools",
".",
"dist",
",",
"attr",
")",
"setattr",
"(",
"d... | [
101,
0
] | [
105,
67
] | python | en | ['en', 'en', 'en'] | True |
patch_func | (replacement, target_mod, func_name) |
Patch func_name in target_mod with replacement
Important - original must be resolved by name to avoid
patching an already patched function.
|
Patch func_name in target_mod with replacement | def patch_func(replacement, target_mod, func_name):
"""
Patch func_name in target_mod with replacement
Important - original must be resolved by name to avoid
patching an already patched function.
"""
original = getattr(target_mod, func_name)
# set the 'unpatched' attribute on the replaceme... | [
"def",
"patch_func",
"(",
"replacement",
",",
"target_mod",
",",
"func_name",
")",
":",
"original",
"=",
"getattr",
"(",
"target_mod",
",",
"func_name",
")",
"# set the 'unpatched' attribute on the replacement to",
"# point to the original.",
"vars",
"(",
"replacement",
... | [
108,
0
] | [
122,
47
] | python | en | ['en', 'error', 'th'] | False |
patch_for_msvc_specialized_compiler | () |
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
|
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
| def patch_for_msvc_specialized_compiler():
"""
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
"""
# import late to avoid circular imports on Python < 3.5
msvc = import_module('setuptools.msvc')
if platform.system() != 'Windows':
# Compilers only avail... | [
"def",
"patch_for_msvc_specialized_compiler",
"(",
")",
":",
"# import late to avoid circular imports on Python < 3.5",
"msvc",
"=",
"import_module",
"(",
"'setuptools.msvc'",
")",
"if",
"platform",
".",
"system",
"(",
")",
"!=",
"'Windows'",
":",
"# Compilers only availabl... | [
129,
0
] | [
176,
12
] | python | en | ['en', 'error', 'th'] | False |
ExampleLoginFlow.async_step_init | (
self, user_input: dict[str, str] | None = None
) | Handle the step of the form. | Handle the step of the form. | async def async_step_init(
self, user_input: dict[str, str] | None = None
) -> FlowResult:
"""Handle the step of the form."""
errors = {}
if user_input is not None:
try:
cast(ExampleAuthProvider, self._auth_provider).async_validate_login(
... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
":",
"dict",
"[",
"str",
",",
"str",
"]",
"|",
"None",
"=",
"None",
")",
"->",
"FlowResult",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"try",
":",
... | [
101,
4
] | [
125,
9
] | python | en | ['en', 'en', 'en'] | True |
BaseProtocolTest._make_user | (self, nick, uid, ts=None, sid=None, **kwargs) |
Creates a user for testing.
|
Creates a user for testing.
| def _make_user(self, nick, uid, ts=None, sid=None, **kwargs):
"""
Creates a user for testing.
"""
if ts is None:
ts = int(time.time())
userobj = User(self.p, nick, ts, uid, sid, **kwargs)
self.p.users[uid] = userobj
return userobj | [
"def",
"_make_user",
"(",
"self",
",",
"nick",
",",
"uid",
",",
"ts",
"=",
"None",
",",
"sid",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ts",
"is",
"None",
":",
"ts",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"userobj"... | [
55,
4
] | [
63,
22
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the lock platform. | Set up the lock platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the lock platform."""
client = hass.data[DOMAIN][config_entry.entry_id][DATA_CLIENT]
coordinator = hass.data[DOMAIN][config_entry.entry_id][DATA_COORDINATOR]
entities = []
for index, _ in enumerate(coordinator.data):
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"client",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"DATA_CLIENT",
"]",
"coordinator",
"=",
"hass"... | [
8,
0
] | [
18,
32
] | python | en | ['en', 'da', 'en'] | True |
MazdaLock.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self):
"""Return the name of the entity."""
vehicle_name = self.get_vehicle_name()
return f"{vehicle_name} Lock" | [
"def",
"name",
"(",
"self",
")",
":",
"vehicle_name",
"=",
"self",
".",
"get_vehicle_name",
"(",
")",
"return",
"f\"{vehicle_name} Lock\""
] | [
25,
4
] | [
28,
37
] | python | en | ['en', 'en', 'en'] | True |
MazdaLock.unique_id | (self) | Return a unique identifier for this entity. | Return a unique identifier for this entity. | def unique_id(self):
"""Return a unique identifier for this entity."""
return self.vin | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"vin"
] | [
31,
4
] | [
33,
23
] | python | en | ['en', 'fr', 'en'] | True |
MazdaLock.is_locked | (self) | Return true if lock is locked. | Return true if lock is locked. | def is_locked(self):
"""Return true if lock is locked."""
return self.client.get_assumed_lock_state(self.vehicle_id) | [
"def",
"is_locked",
"(",
"self",
")",
":",
"return",
"self",
".",
"client",
".",
"get_assumed_lock_state",
"(",
"self",
".",
"vehicle_id",
")"
] | [
36,
4
] | [
38,
66
] | python | en | ['en', 'mt', 'en'] | True |
MazdaLock.async_lock | (self, **kwargs) | Lock the vehicle doors. | Lock the vehicle doors. | async def async_lock(self, **kwargs):
"""Lock the vehicle doors."""
await self.client.lock_doors(self.vehicle_id)
self.async_write_ha_state() | [
"async",
"def",
"async_lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"client",
".",
"lock_doors",
"(",
"self",
".",
"vehicle_id",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
40,
4
] | [
44,
35
] | python | en | ['en', 'sr', 'en'] | True |
MazdaLock.async_unlock | (self, **kwargs) | Unlock the vehicle doors. | Unlock the vehicle doors. | async def async_unlock(self, **kwargs):
"""Unlock the vehicle doors."""
await self.client.unlock_doors(self.vehicle_id)
self.async_write_ha_state() | [
"async",
"def",
"async_unlock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"client",
".",
"unlock_doors",
"(",
"self",
".",
"vehicle_id",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
46,
4
] | [
50,
35
] | python | en | ['en', 'nl', 'en'] | True |
turn_on | (hass, entity_id=None, **service_data) | Turn specified entity on if possible.
This is a legacy helper method. Do not use it for new tests.
| Turn specified entity on if possible. | def turn_on(hass, entity_id=None, **service_data):
"""Turn specified entity on if possible.
This is a legacy helper method. Do not use it for new tests.
"""
if entity_id is not None:
service_data[ATTR_ENTITY_ID] = entity_id
hass.services.call(ha.DOMAIN, SERVICE_TURN_ON, service_data) | [
"def",
"turn_on",
"(",
"hass",
",",
"entity_id",
"=",
"None",
",",
"*",
"*",
"service_data",
")",
":",
"if",
"entity_id",
"is",
"not",
"None",
":",
"service_data",
"[",
"ATTR_ENTITY_ID",
"]",
"=",
"entity_id",
"hass",
".",
"services",
".",
"call",
"(",
... | [
48,
0
] | [
56,
64
] | python | en | ['en', 'en', 'en'] | True |
turn_off | (hass, entity_id=None, **service_data) | Turn specified entity off.
This is a legacy helper method. Do not use it for new tests.
| Turn specified entity off. | def turn_off(hass, entity_id=None, **service_data):
"""Turn specified entity off.
This is a legacy helper method. Do not use it for new tests.
"""
if entity_id is not None:
service_data[ATTR_ENTITY_ID] = entity_id
hass.services.call(ha.DOMAIN, SERVICE_TURN_OFF, service_data) | [
"def",
"turn_off",
"(",
"hass",
",",
"entity_id",
"=",
"None",
",",
"*",
"*",
"service_data",
")",
":",
"if",
"entity_id",
"is",
"not",
"None",
":",
"service_data",
"[",
"ATTR_ENTITY_ID",
"]",
"=",
"entity_id",
"hass",
".",
"services",
".",
"call",
"(",
... | [
59,
0
] | [
67,
65
] | python | en | ['en', 'en', 'en'] | True |
toggle | (hass, entity_id=None, **service_data) | Toggle specified entity.
This is a legacy helper method. Do not use it for new tests.
| Toggle specified entity. | def toggle(hass, entity_id=None, **service_data):
"""Toggle specified entity.
This is a legacy helper method. Do not use it for new tests.
"""
if entity_id is not None:
service_data[ATTR_ENTITY_ID] = entity_id
hass.services.call(ha.DOMAIN, SERVICE_TOGGLE, service_data) | [
"def",
"toggle",
"(",
"hass",
",",
"entity_id",
"=",
"None",
",",
"*",
"*",
"service_data",
")",
":",
"if",
"entity_id",
"is",
"not",
"None",
":",
"service_data",
"[",
"ATTR_ENTITY_ID",
"]",
"=",
"entity_id",
"hass",
".",
"services",
".",
"call",
"(",
... | [
70,
0
] | [
78,
63
] | python | en | ['en', 'en', 'en'] | True |
stop | (hass) | Stop Home Assistant.
This is a legacy helper method. Do not use it for new tests.
| Stop Home Assistant. | def stop(hass):
"""Stop Home Assistant.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(ha.DOMAIN, SERVICE_HOMEASSISTANT_STOP) | [
"def",
"stop",
"(",
"hass",
")",
":",
"hass",
".",
"services",
".",
"call",
"(",
"ha",
".",
"DOMAIN",
",",
"SERVICE_HOMEASSISTANT_STOP",
")"
] | [
81,
0
] | [
86,
61
] | python | en | ['en', 'en', 'en'] | True |
restart | (hass) | Stop Home Assistant.
This is a legacy helper method. Do not use it for new tests.
| Stop Home Assistant. | def restart(hass):
"""Stop Home Assistant.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(ha.DOMAIN, SERVICE_HOMEASSISTANT_RESTART) | [
"def",
"restart",
"(",
"hass",
")",
":",
"hass",
".",
"services",
".",
"call",
"(",
"ha",
".",
"DOMAIN",
",",
"SERVICE_HOMEASSISTANT_RESTART",
")"
] | [
89,
0
] | [
94,
64
] | python | en | ['en', 'en', 'en'] | True |
check_config | (hass) | Check the config files.
This is a legacy helper method. Do not use it for new tests.
| Check the config files. | def check_config(hass):
"""Check the config files.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(ha.DOMAIN, SERVICE_CHECK_CONFIG) | [
"def",
"check_config",
"(",
"hass",
")",
":",
"hass",
".",
"services",
".",
"call",
"(",
"ha",
".",
"DOMAIN",
",",
"SERVICE_CHECK_CONFIG",
")"
] | [
97,
0
] | [
102,
55
] | python | en | ['en', 'en', 'en'] | True |
reload_core_config | (hass) | Reload the core config.
This is a legacy helper method. Do not use it for new tests.
| Reload the core config. | def reload_core_config(hass):
"""Reload the core config.
This is a legacy helper method. Do not use it for new tests.
"""
hass.services.call(ha.DOMAIN, SERVICE_RELOAD_CORE_CONFIG) | [
"def",
"reload_core_config",
"(",
"hass",
")",
":",
"hass",
".",
"services",
".",
"call",
"(",
"ha",
".",
"DOMAIN",
",",
"SERVICE_RELOAD_CORE_CONFIG",
")"
] | [
105,
0
] | [
110,
61
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on_skips_domains_without_service | (hass, caplog) | Test if turn_on is blocking domain with no service. | Test if turn_on is blocking domain with no service. | async def test_turn_on_skips_domains_without_service(hass, caplog):
"""Test if turn_on is blocking domain with no service."""
await async_setup_component(hass, "homeassistant", {})
async_mock_service(hass, "light", SERVICE_TURN_ON)
hass.states.async_set("light.Bowl", STATE_ON)
hass.states.async_set(... | [
"async",
"def",
"test_turn_on_skips_domains_without_service",
"(",
"hass",
",",
"caplog",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"async_mock_service",
"(",
"hass",
",",
"\"light\"",
",",
"SERVICE_TURN_O... | [
238,
0
] | [
274,
5
] | python | en | ['en', 'en', 'en'] | True |
test_entity_update | (hass) | Test being able to call entity update. | Test being able to call entity update. | async def test_entity_update(hass):
"""Test being able to call entity update."""
await async_setup_component(hass, "homeassistant", {})
with patch(
"homeassistant.helpers.entity_component.async_update_entity",
return_value=None,
) as mock_update:
await hass.services.async_call(
... | [
"async",
"def",
"test_entity_update",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.helpers.entity_component.async_update_entity\"",
",",
"return_value",
"=",
... | [
277,
0
] | [
293,
61
] | python | en | ['en', 'en', 'en'] | True |
test_setting_location | (hass) | Test setting the location. | Test setting the location. | async def test_setting_location(hass):
"""Test setting the location."""
await async_setup_component(hass, "homeassistant", {})
events = async_capture_events(hass, EVENT_CORE_CONFIG_UPDATE)
# Just to make sure that we are updating values.
assert hass.config.latitude != 30
assert hass.config.longi... | [
"async",
"def",
"test_setting_location",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"events",
"=",
"async_capture_events",
"(",
"hass",
",",
"EVENT_CORE_CONFIG_UPDATE",
")",
"# Just to make sur... | [
296,
0
] | [
311,
38
] | python | en | ['en', 'en', 'en'] | True |
test_require_admin | (hass, hass_read_only_user) | Test services requiring admin. | Test services requiring admin. | async def test_require_admin(hass, hass_read_only_user):
"""Test services requiring admin."""
await async_setup_component(hass, "homeassistant", {})
for service in (
SERVICE_HOMEASSISTANT_RESTART,
SERVICE_HOMEASSISTANT_STOP,
SERVICE_CHECK_CONFIG,
SERVICE_RELOAD_CORE_CONFIG,
... | [
"async",
"def",
"test_require_admin",
"(",
"hass",
",",
"hass_read_only_user",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"for",
"service",
"in",
"(",
"SERVICE_HOMEASSISTANT_RESTART",
",",
"SERVICE_HOMEASSI... | [
314,
0
] | [
341,
9
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on_off_toggle_schema | (hass, hass_read_only_user) | Test the schemas for the turn on/off/toggle services. | Test the schemas for the turn on/off/toggle services. | async def test_turn_on_off_toggle_schema(hass, hass_read_only_user):
"""Test the schemas for the turn on/off/toggle services."""
await async_setup_component(hass, "homeassistant", {})
for service in SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE:
for invalid in None, "nothing", ENTITY_MATCH_ALL,... | [
"async",
"def",
"test_turn_on_off_toggle_schema",
"(",
"hass",
",",
"hass_read_only_user",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"for",
"service",
"in",
"SERVICE_TURN_ON",
",",
"SERVICE_TURN_OFF",
",",... | [
344,
0
] | [
357,
17
] | python | en | ['en', 'en', 'en'] | True |
test_not_allowing_recursion | (hass, caplog) | Test we do not allow recursion. | Test we do not allow recursion. | async def test_not_allowing_recursion(hass, caplog):
"""Test we do not allow recursion."""
await async_setup_component(hass, "homeassistant", {})
for service in SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE:
await hass.services.async_call(
ha.DOMAIN,
service,
... | [
"async",
"def",
"test_not_allowing_recursion",
"(",
"hass",
",",
"caplog",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"for",
"service",
"in",
"SERVICE_TURN_ON",
",",
"SERVICE_TURN_OFF",
",",
"SERVICE_TOGG... | [
360,
0
] | [
374,
18
] | python | en | ['en', 'en', 'en'] | True |
test_reload_config_entry_by_entity_id | (hass) | Test being able to reload a config entry by entity_id. | Test being able to reload a config entry by entity_id. | async def test_reload_config_entry_by_entity_id(hass):
"""Test being able to reload a config entry by entity_id."""
await async_setup_component(hass, "homeassistant", {})
entity_reg = mock_registry(hass)
entry1 = MockConfigEntry(domain="mockdomain")
entry1.add_to_hass(hass)
entry2 = MockConfigEn... | [
"async",
"def",
"test_reload_config_entry_by_entity_id",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"entity_reg",
"=",
"mock_registry",
"(",
"hass",
")",
"entry1",
"=",
"MockConfigEntry",
"("... | [
377,
0
] | [
414,
9
] | python | en | ['en', 'en', 'en'] | True |
test_reload_config_entry_by_entry_id | (hass) | Test being able to reload a config entry by config entry id. | Test being able to reload a config entry by config entry id. | async def test_reload_config_entry_by_entry_id(hass):
"""Test being able to reload a config entry by config entry id."""
await async_setup_component(hass, "homeassistant", {})
with patch(
"homeassistant.config_entries.ConfigEntries.async_reload",
return_value=None,
) as mock_reload:
... | [
"async",
"def",
"test_reload_config_entry_by_entry_id",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.config_entries.ConfigEntries.async_reload\"",
",",
"return_va... | [
417,
0
] | [
433,
80
] | python | en | ['en', 'en', 'en'] | True |
test_raises_when_db_upgrade_in_progress | (hass, service, caplog) | Test an exception is raised when the database migration is in progress. | Test an exception is raised when the database migration is in progress. | async def test_raises_when_db_upgrade_in_progress(hass, service, caplog):
"""Test an exception is raised when the database migration is in progress."""
await async_setup_component(hass, "homeassistant", {})
with pytest.raises(HomeAssistantError), patch(
"homeassistant.helpers.recorder.async_migrati... | [
"async",
"def",
"test_raises_when_db_upgrade_in_progress",
"(",
"hass",
",",
"service",
",",
"caplog",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"with",
"pytest",
".",
"raises",
"(",
"HomeAssistantError"... | [
439,
0
] | [
472,
50
] | python | en | ['en', 'en', 'en'] | True |
test_raises_when_config_is_invalid | (hass, caplog) | Test an exception is raised when the configuration is invalid. | Test an exception is raised when the configuration is invalid. | async def test_raises_when_config_is_invalid(hass, caplog):
"""Test an exception is raised when the configuration is invalid."""
await async_setup_component(hass, "homeassistant", {})
with pytest.raises(HomeAssistantError), patch(
"homeassistant.helpers.recorder.async_migration_in_progress",
... | [
"async",
"def",
"test_raises_when_config_is_invalid",
"(",
"hass",
",",
"caplog",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"with",
"pytest",
".",
"raises",
"(",
"HomeAssistantError",
")",
",",
"patch"... | [
475,
0
] | [
509,
49
] | python | en | ['en', 'en', 'en'] | True |
test_restart_homeassistant | (hass) | Test we can restart when there is no configuration error. | Test we can restart when there is no configuration error. | async def test_restart_homeassistant(hass):
"""Test we can restart when there is no configuration error."""
await async_setup_component(hass, "homeassistant", {})
with patch(
"homeassistant.config.async_check_ha_config_file", return_value=None
) as mock_check, patch(
"homeassistant.core.... | [
"async",
"def",
"test_restart_homeassistant",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.config.async_check_ha_config_file\"",
",",
"return_value",
"=",
"No... | [
512,
0
] | [
527,
34
] | python | en | ['en', 'en', 'en'] | True |
test_stop_homeassistant | (hass) | Test we can stop when there is a configuration error. | Test we can stop when there is a configuration error. | async def test_stop_homeassistant(hass):
"""Test we can stop when there is a configuration error."""
await async_setup_component(hass, "homeassistant", {})
with patch(
"homeassistant.config.async_check_ha_config_file", return_value=None
) as mock_check, patch(
"homeassistant.core.HomeAss... | [
"async",
"def",
"test_stop_homeassistant",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.config.async_check_ha_config_file\"",
",",
"return_value",
"=",
"None"... | [
530,
0
] | [
545,
34
] | python | en | ['en', 'en', 'en'] | True |
test_save_persistent_states | (hass) | Test we can call save_persistent_states. | Test we can call save_persistent_states. | async def test_save_persistent_states(hass):
"""Test we can call save_persistent_states."""
await async_setup_component(hass, "homeassistant", {})
with patch(
"homeassistant.helpers.restore_state.RestoreStateData.async_save_persistent_states",
return_value=None,
) as mock_save:
a... | [
"async",
"def",
"test_save_persistent_states",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
"with",
"patch",
"(",
"\"homeassistant.helpers.restore_state.RestoreStateData.async_save_persistent_states\"",
... | [
548,
0
] | [
560,
31
] | python | en | ['en', 'en', 'en'] | True |
TestComponentsCore.setUp | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setUp(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
assert asyncio.run_coroutine_threadsafe(
async_setup_component(self.hass, "homeassistant", {}), self.hass.loop
).result()
self.hass.states.set("light.Bowl", S... | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"assert",
"asyncio",
".",
"run_coroutine_threadsafe",
"(",
"async_setup_component",
"(",
"self",
".",
"hass",
",",
"\"homeassistant\"",
",",
"{",
"}",
")",
... | [
117,
4
] | [
126,
39
] | python | en | ['en', 'en', 'en'] | True |
TestComponentsCore.test_is_on | (self) | Test is_on method. | Test is_on method. | def test_is_on(self):
"""Test is_on method."""
assert comps.is_on(self.hass, "light.Bowl")
assert not comps.is_on(self.hass, "light.Ceiling")
assert comps.is_on(self.hass)
assert not comps.is_on(self.hass, "non_existing.entity") | [
"def",
"test_is_on",
"(",
"self",
")",
":",
"assert",
"comps",
".",
"is_on",
"(",
"self",
".",
"hass",
",",
"\"light.Bowl\"",
")",
"assert",
"not",
"comps",
".",
"is_on",
"(",
"self",
".",
"hass",
",",
"\"light.Ceiling\"",
")",
"assert",
"comps",
".",
... | [
128,
4
] | [
133,
64
] | python | en | ['en', 'et', 'en'] | True |
TestComponentsCore.test_turn_on_without_entities | (self) | Test turn_on method without entities. | Test turn_on method without entities. | def test_turn_on_without_entities(self):
"""Test turn_on method without entities."""
calls = mock_service(self.hass, "light", SERVICE_TURN_ON)
turn_on(self.hass)
self.hass.block_till_done()
assert len(calls) == 0 | [
"def",
"test_turn_on_without_entities",
"(",
"self",
")",
":",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"\"light\"",
",",
"SERVICE_TURN_ON",
")",
"turn_on",
"(",
"self",
".",
"hass",
")",
"self",
".",
"hass",
".",
"block_till_done",
"(",
... | [
135,
4
] | [
140,
30
] | python | en | ['en', 'en', 'en'] | True |
TestComponentsCore.test_turn_on | (self) | Test turn_on method. | Test turn_on method. | def test_turn_on(self):
"""Test turn_on method."""
calls = mock_service(self.hass, "light", SERVICE_TURN_ON)
turn_on(self.hass, "light.Ceiling")
self.hass.block_till_done()
assert len(calls) == 1 | [
"def",
"test_turn_on",
"(",
"self",
")",
":",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"\"light\"",
",",
"SERVICE_TURN_ON",
")",
"turn_on",
"(",
"self",
".",
"hass",
",",
"\"light.Ceiling\"",
")",
"self",
".",
"hass",
".",
"block_till_d... | [
142,
4
] | [
147,
30
] | python | en | ['en', 'et', 'en'] | True |
TestComponentsCore.test_turn_off | (self) | Test turn_off method. | Test turn_off method. | def test_turn_off(self):
"""Test turn_off method."""
calls = mock_service(self.hass, "light", SERVICE_TURN_OFF)
turn_off(self.hass, "light.Bowl")
self.hass.block_till_done()
assert len(calls) == 1 | [
"def",
"test_turn_off",
"(",
"self",
")",
":",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"\"light\"",
",",
"SERVICE_TURN_OFF",
")",
"turn_off",
"(",
"self",
".",
"hass",
",",
"\"light.Bowl\"",
")",
"self",
".",
"hass",
".",
"block_till_d... | [
149,
4
] | [
154,
30
] | python | en | ['en', 'et', 'en'] | True |
TestComponentsCore.test_toggle | (self) | Test toggle method. | Test toggle method. | def test_toggle(self):
"""Test toggle method."""
calls = mock_service(self.hass, "light", SERVICE_TOGGLE)
toggle(self.hass, "light.Bowl")
self.hass.block_till_done()
assert len(calls) == 1 | [
"def",
"test_toggle",
"(",
"self",
")",
":",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"\"light\"",
",",
"SERVICE_TOGGLE",
")",
"toggle",
"(",
"self",
".",
"hass",
",",
"\"light.Bowl\"",
")",
"self",
".",
"hass",
".",
"block_till_done",
... | [
156,
4
] | [
161,
30
] | python | en | ['en', 'et', 'en'] | True |
TestComponentsCore.test_reload_core_conf | (self) | Test reload core conf service. | Test reload core conf service. | def test_reload_core_conf(self):
"""Test reload core conf service."""
ent = entity.Entity()
ent.entity_id = "test.entity"
ent.hass = self.hass
ent.schedule_update_ha_state()
self.hass.block_till_done()
state = self.hass.states.get("test.entity")
assert st... | [
"def",
"test_reload_core_conf",
"(",
"self",
")",
":",
"ent",
"=",
"entity",
".",
"Entity",
"(",
")",
"ent",
".",
"entity_id",
"=",
"\"test.entity\"",
"ent",
".",
"hass",
"=",
"self",
".",
"hass",
"ent",
".",
"schedule_update_ha_state",
"(",
")",
"self",
... | [
164,
4
] | [
201,
55
] | python | en | ['en', 'it', 'en'] | True |
TestComponentsCore.test_reload_core_with_wrong_conf | (self, mock_process, mock_error) | Test reload core conf service. | Test reload core conf service. | def test_reload_core_with_wrong_conf(self, mock_process, mock_error):
"""Test reload core conf service."""
files = {config.YAML_CONFIG_FILE: yaml.dump(["invalid", "config"])}
with patch_yaml_files(files, True):
reload_core_config(self.hass)
self.hass.block_till_done()
... | [
"def",
"test_reload_core_with_wrong_conf",
"(",
"self",
",",
"mock_process",
",",
"mock_error",
")",
":",
"files",
"=",
"{",
"config",
".",
"YAML_CONFIG_FILE",
":",
"yaml",
".",
"dump",
"(",
"[",
"\"invalid\"",
",",
"\"config\"",
"]",
")",
"}",
"with",
"patc... | [
206,
4
] | [
214,
43
] | python | en | ['en', 'it', 'en'] | True |
TestComponentsCore.test_restart_homeassistant_wrong_conf | (self, mock_check, mock_restart) | Test stop service. | Test stop service. | def test_restart_homeassistant_wrong_conf(self, mock_check, mock_restart):
"""Test stop service."""
restart(self.hass)
self.hass.block_till_done()
assert mock_check.called
assert not mock_restart.called | [
"def",
"test_restart_homeassistant_wrong_conf",
"(",
"self",
",",
"mock_check",
",",
"mock_restart",
")",
":",
"restart",
"(",
"self",
".",
"hass",
")",
"self",
".",
"hass",
".",
"block_till_done",
"(",
")",
"assert",
"mock_check",
".",
"called",
"assert",
"no... | [
221,
4
] | [
226,
38
] | python | en | ['en', 'en', 'en'] | True |
TestComponentsCore.test_check_config | (self, mock_check, mock_stop) | Test stop service. | Test stop service. | def test_check_config(self, mock_check, mock_stop):
"""Test stop service."""
check_config(self.hass)
self.hass.block_till_done()
assert mock_check.called
assert not mock_stop.called | [
"def",
"test_check_config",
"(",
"self",
",",
"mock_check",
",",
"mock_stop",
")",
":",
"check_config",
"(",
"self",
".",
"hass",
")",
"self",
".",
"hass",
".",
"block_till_done",
"(",
")",
"assert",
"mock_check",
".",
"called",
"assert",
"not",
"mock_stop",... | [
230,
4
] | [
235,
35
] | python | en | ['en', 'en', 'en'] | True |
teardown | () | Stop everything that was started. | Stop everything that was started. | def teardown():
"""Stop everything that was started."""
dt_util.set_default_time_zone(DEFAULT_TIME_ZONE) | [
"def",
"teardown",
"(",
")",
":",
"dt_util",
".",
"set_default_time_zone",
"(",
"DEFAULT_TIME_ZONE",
")"
] | [
48,
0
] | [
50,
52
] | python | en | ['en', 'en', 'en'] | True |
test_track_point_in_time | (hass) | Test track point in time. | Test track point in time. | async def test_track_point_in_time(hass):
"""Test track point in time."""
before_birthday = datetime(1985, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC)
birthday_paulus = datetime(1986, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC)
after_birthday = datetime(1987, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC)
runs = []
asyn... | [
"async",
"def",
"test_track_point_in_time",
"(",
"hass",
")",
":",
"before_birthday",
"=",
"datetime",
"(",
"1985",
",",
"7",
",",
"9",
",",
"12",
",",
"0",
",",
"0",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"birthday_paulus",
"=",
"datetime",
"... | [
53,
0
] | [
93,
25
] | python | en | ['en', 'en', 'en'] | True |
test_track_point_in_time_drift_rearm | (hass) | Test tasks with the time rolling backwards. | Test tasks with the time rolling backwards. | async def test_track_point_in_time_drift_rearm(hass):
"""Test tasks with the time rolling backwards."""
specific_runs = []
now = dt_util.utcnow()
time_that_will_not_match_right_away = datetime(
now.year + 1, 5, 24, 21, 59, 55, tzinfo=dt_util.UTC
)
async_track_point_in_utc_time(
... | [
"async",
"def",
"test_track_point_in_time_drift_rearm",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"time_that_will_not_match_right_away",
"=",
"datetime",
"(",
"now",
".",
"year",
"+",
"1",
",",
"5",
... | [
96,
0
] | [
125,
34
] | python | en | ['en', 'en', 'en'] | True |
test_track_state_change_from_to_state_match | (hass) | Test track_state_change with from and to state matchers. | Test track_state_change with from and to state matchers. | async def test_track_state_change_from_to_state_match(hass):
"""Test track_state_change with from and to state matchers."""
from_and_to_state_runs = []
only_from_runs = []
only_to_runs = []
match_all_runs = []
no_to_from_specified_runs = []
def from_and_to_state_callback(entity_id, old_stat... | [
"async",
"def",
"test_track_state_change_from_to_state_match",
"(",
"hass",
")",
":",
"from_and_to_state_runs",
"=",
"[",
"]",
"only_from_runs",
"=",
"[",
"]",
"only_to_runs",
"=",
"[",
"]",
"match_all_runs",
"=",
"[",
"]",
"no_to_from_specified_runs",
"=",
"[",
"... | [
128,
0
] | [
209,
46
] | python | en | ['en', 'en', 'en'] | True |
test_track_state_change | (hass) | Test track_state_change. | Test track_state_change. | async def test_track_state_change(hass):
"""Test track_state_change."""
# 2 lists to track how often our callbacks get called
specific_runs = []
wildcard_runs = []
wildercard_runs = []
def specific_run_callback(entity_id, old_state, new_state):
specific_runs.append(1)
# This is the... | [
"async",
"def",
"test_track_state_change",
"(",
"hass",
")",
":",
"# 2 lists to track how often our callbacks get called",
"specific_runs",
"=",
"[",
"]",
"wildcard_runs",
"=",
"[",
"]",
"wildercard_runs",
"=",
"[",
"]",
"def",
"specific_run_callback",
"(",
"entity_id",... | [
212,
0
] | [
289,
36
] | python | en | ['en', 'en', 'en'] | False |
test_async_track_state_change_filtered | (hass) | Test async_track_state_change_filtered. | Test async_track_state_change_filtered. | async def test_async_track_state_change_filtered(hass):
"""Test async_track_state_change_filtered."""
single_entity_id_tracker = []
multiple_entity_id_tracker = []
@ha.callback
def single_run_callback(event):
old_state = event.data.get("old_state")
new_state = event.data.get("new_st... | [
"async",
"def",
"test_async_track_state_change_filtered",
"(",
"hass",
")",
":",
"single_entity_id_tracker",
"=",
"[",
"]",
"multiple_entity_id_tracker",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"single_run_callback",
"(",
"event",
")",
":",
"old_state",
... | [
292,
0
] | [
425,
31
] | python | en | ['en', 'en', 'en'] | False |
test_async_track_state_change_event | (hass) | Test async_track_state_change_event. | Test async_track_state_change_event. | async def test_async_track_state_change_event(hass):
"""Test async_track_state_change_event."""
single_entity_id_tracker = []
multiple_entity_id_tracker = []
@ha.callback
def single_run_callback(event):
old_state = event.data.get("old_state")
new_state = event.data.get("new_state")
... | [
"async",
"def",
"test_async_track_state_change_event",
"(",
"hass",
")",
":",
"single_entity_id_tracker",
"=",
"[",
"]",
"multiple_entity_id_tracker",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"single_run_callback",
"(",
"event",
")",
":",
"old_state",
"="... | [
428,
0
] | [
518,
18
] | python | en | ['en', 'en', 'en'] | False |
test_async_track_state_change_event_with_empty_list | (hass) | Test async_track_state_change_event passing an empty list of entities. | Test async_track_state_change_event passing an empty list of entities. | async def test_async_track_state_change_event_with_empty_list(hass):
"""Test async_track_state_change_event passing an empty list of entities."""
unsub_single = async_track_state_change_event(
hass, [], ha.callback(lambda event: None)
)
unsub_single2 = async_track_state_change_event(
has... | [
"async",
"def",
"test_async_track_state_change_event_with_empty_list",
"(",
"hass",
")",
":",
"unsub_single",
"=",
"async_track_state_change_event",
"(",
"hass",
",",
"[",
"]",
",",
"ha",
".",
"callback",
"(",
"lambda",
"event",
":",
"None",
")",
")",
"unsub_singl... | [
521,
0
] | [
531,
18
] | python | en | ['en', 'en', 'en'] | True |
test_async_track_state_added_domain | (hass) | Test async_track_state_added_domain. | Test async_track_state_added_domain. | async def test_async_track_state_added_domain(hass):
"""Test async_track_state_added_domain."""
single_entity_id_tracker = []
multiple_entity_id_tracker = []
@ha.callback
def single_run_callback(event):
old_state = event.data.get("old_state")
new_state = event.data.get("new_state")
... | [
"async",
"def",
"test_async_track_state_added_domain",
"(",
"hass",
")",
":",
"single_entity_id_tracker",
"=",
"[",
"]",
"multiple_entity_id_tracker",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"single_run_callback",
"(",
"event",
")",
":",
"old_state",
"="... | [
534,
0
] | [
613,
18
] | python | en | ['en', 'en', 'en'] | False |
test_async_track_state_added_domain_with_empty_list | (hass) | Test async_track_state_added_domain passing an empty list of domains. | Test async_track_state_added_domain passing an empty list of domains. | async def test_async_track_state_added_domain_with_empty_list(hass):
"""Test async_track_state_added_domain passing an empty list of domains."""
unsub_single = async_track_state_added_domain(
hass, [], ha.callback(lambda event: None)
)
unsub_single2 = async_track_state_added_domain(
hass... | [
"async",
"def",
"test_async_track_state_added_domain_with_empty_list",
"(",
"hass",
")",
":",
"unsub_single",
"=",
"async_track_state_added_domain",
"(",
"hass",
",",
"[",
"]",
",",
"ha",
".",
"callback",
"(",
"lambda",
"event",
":",
"None",
")",
")",
"unsub_singl... | [
616,
0
] | [
626,
18
] | python | en | ['en', 'en', 'en'] | True |
test_async_track_state_removed_domain_with_empty_list | (hass) | Test async_track_state_removed_domain passing an empty list of domains. | Test async_track_state_removed_domain passing an empty list of domains. | async def test_async_track_state_removed_domain_with_empty_list(hass):
"""Test async_track_state_removed_domain passing an empty list of domains."""
unsub_single = async_track_state_removed_domain(
hass, [], ha.callback(lambda event: None)
)
unsub_single2 = async_track_state_removed_domain(
... | [
"async",
"def",
"test_async_track_state_removed_domain_with_empty_list",
"(",
"hass",
")",
":",
"unsub_single",
"=",
"async_track_state_removed_domain",
"(",
"hass",
",",
"[",
"]",
",",
"ha",
".",
"callback",
"(",
"lambda",
"event",
":",
"None",
")",
")",
"unsub_s... | [
629,
0
] | [
639,
18
] | python | en | ['en', 'en', 'en'] | True |
test_async_track_state_removed_domain | (hass) | Test async_track_state_removed_domain. | Test async_track_state_removed_domain. | async def test_async_track_state_removed_domain(hass):
"""Test async_track_state_removed_domain."""
single_entity_id_tracker = []
multiple_entity_id_tracker = []
@ha.callback
def single_run_callback(event):
old_state = event.data.get("old_state")
new_state = event.data.get("new_stat... | [
"async",
"def",
"test_async_track_state_removed_domain",
"(",
"hass",
")",
":",
"single_entity_id_tracker",
"=",
"[",
"]",
"multiple_entity_id_tracker",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"single_run_callback",
"(",
"event",
")",
":",
"old_state",
"... | [
642,
0
] | [
721,
18
] | python | en | ['en', 'en', 'en'] | False |
test_async_track_state_removed_domain_match_all | (hass) | Test async_track_state_removed_domain with a match_all. | Test async_track_state_removed_domain with a match_all. | async def test_async_track_state_removed_domain_match_all(hass):
"""Test async_track_state_removed_domain with a match_all."""
single_entity_id_tracker = []
match_all_entity_id_tracker = []
@ha.callback
def single_run_callback(event):
old_state = event.data.get("old_state")
new_stat... | [
"async",
"def",
"test_async_track_state_removed_domain_match_all",
"(",
"hass",
")",
":",
"single_entity_id_tracker",
"=",
"[",
"]",
"match_all_entity_id_tracker",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"single_run_callback",
"(",
"event",
")",
":",
"old_... | [
724,
0
] | [
765,
48
] | python | en | ['en', 'en', 'en'] | True |
test_track_template | (hass) | Test tracking template. | Test tracking template. | async def test_track_template(hass):
"""Test tracking template."""
specific_runs = []
wildcard_runs = []
wildercard_runs = []
template_condition = Template("{{states.switch.test.state == 'on'}}", hass)
template_condition_var = Template(
"{{states.switch.test.state == 'on' and test == 5}... | [
"async",
"def",
"test_track_template",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"wildcard_runs",
"=",
"[",
"]",
"wildercard_runs",
"=",
"[",
"]",
"template_condition",
"=",
"Template",
"(",
"\"{{states.switch.test.state == 'on'}}\"",
",",
"hass",
")"... | [
768,
0
] | [
850,
44
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_error | (hass, caplog) | Test tracking template with error. | Test tracking template with error. | async def test_track_template_error(hass, caplog):
"""Test tracking template with error."""
template_error = Template("{{ (states.switch | lunch) > 0 }}", hass)
error_calls = []
@ha.callback
def error_callback(entity_id, old_state, new_state):
error_calls.append((entity_id, old_state, new_s... | [
"async",
"def",
"test_track_template_error",
"(",
"hass",
",",
"caplog",
")",
":",
"template_error",
"=",
"Template",
"(",
"\"{{ (states.switch | lunch) > 0 }}\"",
",",
"hass",
")",
"error_calls",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"error_callback",... | [
853,
0
] | [
881,
54
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_error_can_recover | (hass, caplog) | Test tracking template with error. | Test tracking template with error. | async def test_track_template_error_can_recover(hass, caplog):
"""Test tracking template with error."""
hass.states.async_set("switch.data_system", "cow", {"opmode": 0})
template_error = Template(
"{{ states.sensor.data_system.attributes['opmode'] == '0' }}", hass
)
error_calls = []
@ha... | [
"async",
"def",
"test_track_template_error_can_recover",
"(",
"hass",
",",
"caplog",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"switch.data_system\"",
",",
"\"cow\"",
",",
"{",
"\"opmode\"",
":",
"0",
"}",
")",
"template_error",
"=",
"Template",
... | [
884,
0
] | [
908,
46
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_time_change | (hass, caplog) | Test tracking template with time change. | Test tracking template with time change. | async def test_track_template_time_change(hass, caplog):
"""Test tracking template with time change."""
template_error = Template("{{ utcnow().minute % 2 == 0 }}", hass)
calls = []
@ha.callback
def error_callback(entity_id, old_state, new_state):
calls.append((entity_id, old_state, new_stat... | [
"async",
"def",
"test_track_template_time_change",
"(",
"hass",
",",
"caplog",
")",
":",
"template_error",
"=",
"Template",
"(",
"\"{{ utcnow().minute % 2 == 0 }}\"",
",",
"hass",
")",
"calls",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"error_callback",
... | [
911,
0
] | [
935,
41
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_result | (hass) | Test tracking template. | Test tracking template. | async def test_track_template_result(hass):
"""Test tracking template."""
specific_runs = []
wildcard_runs = []
wildercard_runs = []
template_condition = Template("{{states.sensor.test.state}}", hass)
template_condition_var = Template(
"{{(states.sensor.test.state|int) + test }}", hass
... | [
"async",
"def",
"test_track_template_result",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"wildcard_runs",
"=",
"[",
"]",
"wildercard_runs",
"=",
"[",
"]",
"template_condition",
"=",
"Template",
"(",
"\"{{states.sensor.test.state}}\"",
",",
"hass",
")",... | [
938,
0
] | [
1021,
36
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_result_complex | (hass) | Test tracking template. | Test tracking template. | async def test_track_template_result_complex(hass):
"""Test tracking template."""
specific_runs = []
template_complex_str = """
{% if states("sensor.domain") == "light" %}
{{ states.light | map(attribute='entity_id') | list }}
{% elif states("sensor.domain") == "lock" %}
{{ states.lock | map(attribute='... | [
"async",
"def",
"test_track_template_result_complex",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"template_complex_str",
"=",
"\"\"\"\n{% if states(\"sensor.domain\") == \"light\" %}\n {{ states.light | map(attribute='entity_id') | list }}\n{% elif states(\"sensor.domain\") ==... | [
1024,
0
] | [
1177,
5
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_result_with_wildcard | (hass) | Test tracking template with a wildcard. | Test tracking template with a wildcard. | async def test_track_template_result_with_wildcard(hass):
"""Test tracking template with a wildcard."""
specific_runs = []
template_complex_str = r"""
{% for state in states %}
{% if state.entity_id | regex_match('.*\.office_') %}
{{ state.entity_id }}={{ state.state }}
{% endif %}
{% endfor %}
""... | [
"async",
"def",
"test_track_template_result_with_wildcard",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"template_complex_str",
"=",
"r\"\"\"\n\n{% for state in states %}\n {% if state.entity_id | regex_match('.*\\.office_') %}\n {{ state.entity_id }}={{ state.state }}\n {%... | [
1180,
0
] | [
1218,
59
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_result_with_group | (hass) | Test tracking template with a group. | Test tracking template with a group. | async def test_track_template_result_with_group(hass):
"""Test tracking template with a group."""
hass.states.async_set("sensor.power_1", 0)
hass.states.async_set("sensor.power_2", 200.2)
hass.states.async_set("sensor.power_3", 400.4)
hass.states.async_set("sensor.power_4", 800.8)
assert await ... | [
"async",
"def",
"test_track_template_result_with_group",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.power_1\"",
",",
"0",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.power_2\"",
",",
"200.2",
")",
"hass",
".... | [
1221,
0
] | [
1291,
57
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_result_and_conditional | (hass) | Test tracking template with an and conditional. | Test tracking template with an and conditional. | async def test_track_template_result_and_conditional(hass):
"""Test tracking template with an and conditional."""
specific_runs = []
hass.states.async_set("light.a", "off")
hass.states.async_set("light.b", "off")
template_str = '{% if states.light.a.state == "on" and states.light.b.state == "on" %}o... | [
"async",
"def",
"test_track_template_result_and_conditional",
"(",
"hass",
")",
":",
"specific_runs",
"=",
"[",
"]",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"light.a\"",
",",
"\"off\"",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"light.b\"",
... | [
1294,
0
] | [
1354,
35
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_result_iterator | (hass) | Test tracking template. | Test tracking template. | async def test_track_template_result_iterator(hass):
"""Test tracking template."""
iterator_runs = []
@ha.callback
def iterator_callback(event, updates):
iterator_runs.append(updates.pop().result)
async_track_template_result(
hass,
[
TrackTemplate(
... | [
"async",
"def",
"test_track_template_result_iterator",
"(",
"hass",
")",
":",
"iterator_runs",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"iterator_callback",
"(",
"event",
",",
"updates",
")",
":",
"iterator_runs",
".",
"append",
"(",
"updates",
".",
... | [
1357,
0
] | [
1430,
44
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_result_errors | (hass, caplog) | Test tracking template with errors in the template. | Test tracking template with errors in the template. | async def test_track_template_result_errors(hass, caplog):
"""Test tracking template with errors in the template."""
template_syntax_error = Template("{{states.switch", hass)
template_not_exist = Template("{{states.switch.not_exist.state }}", hass)
syntax_error_runs = []
not_exist_runs = []
@... | [
"async",
"def",
"test_track_template_result_errors",
"(",
"hass",
",",
"caplog",
")",
":",
"template_syntax_error",
"=",
"Template",
"(",
"\"{{states.switch\"",
",",
"hass",
")",
"template_not_exist",
"=",
"Template",
"(",
"\"{{states.switch.not_exist.state }}\"",
",",
... | [
1433,
0
] | [
1513,
62
] | python | en | ['en', 'en', 'en'] | True |
test_static_string | (hass) | Test a static string. | Test a static string. | async def test_static_string(hass):
"""Test a static string."""
template_refresh = Template("{{ 'static' }}", hass)
refresh_runs = []
@ha.callback
def refresh_listener(event, updates):
refresh_runs.append(updates.pop().result)
info = async_track_template_result(
hass, [TrackTe... | [
"async",
"def",
"test_static_string",
"(",
"hass",
")",
":",
"template_refresh",
"=",
"Template",
"(",
"\"{{ 'static' }}\"",
",",
"hass",
")",
"refresh_runs",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"refresh_listener",
"(",
"event",
",",
"updates",
... | [
1516,
0
] | [
1533,
37
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_rate_limit | (hass) | Test template rate limit. | Test template rate limit. | async def test_track_template_rate_limit(hass):
"""Test template rate limit."""
template_refresh = Template("{{ states | count }}", hass)
refresh_runs = []
@ha.callback
def refresh_listener(event, updates):
refresh_runs.append(updates.pop().result)
info = async_track_template_result(
... | [
"async",
"def",
"test_track_template_rate_limit",
"(",
"hass",
")",
":",
"template_refresh",
"=",
"Template",
"(",
"\"{{ states | count }}\"",
",",
"hass",
")",
"refresh_runs",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"refresh_listener",
"(",
"event",
"... | [
1536,
0
] | [
1586,
39
] | python | en | ['it', 'en', 'en'] | True |
test_track_template_rate_limit_suppress_listener | (hass) | Test template rate limit will suppress the listener during the rate limit. | Test template rate limit will suppress the listener during the rate limit. | async def test_track_template_rate_limit_suppress_listener(hass):
"""Test template rate limit will suppress the listener during the rate limit."""
template_refresh = Template("{{ states | count }}", hass)
refresh_runs = []
@ha.callback
def refresh_listener(event, updates):
refresh_runs.app... | [
"async",
"def",
"test_track_template_rate_limit_suppress_listener",
"(",
"hass",
")",
":",
"template_refresh",
"=",
"Template",
"(",
"\"{{ states | count }}\"",
",",
"hass",
")",
"refresh_runs",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"refresh_listener",
"... | [
1589,
0
] | [
1681,
39
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_rate_limit_five | (hass) | Test template rate limit of 5 seconds. | Test template rate limit of 5 seconds. | async def test_track_template_rate_limit_five(hass):
"""Test template rate limit of 5 seconds."""
template_refresh = Template("{{ states | count }}", hass)
refresh_runs = []
@ha.callback
def refresh_listener(event, updates):
refresh_runs.append(updates.pop().result)
info = async_track... | [
"async",
"def",
"test_track_template_rate_limit_five",
"(",
"hass",
")",
":",
"template_refresh",
"=",
"Template",
"(",
"\"{{ states | count }}\"",
",",
"hass",
")",
"refresh_runs",
"=",
"[",
"]",
"@",
"ha",
".",
"callback",
"def",
"refresh_listener",
"(",
"event"... | [
1684,
0
] | [
1714,
33
] | python | en | ['en', 'en', 'en'] | True |
test_track_template_has_default_rate_limit | (hass) | Test template has a rate limit by default. | Test template has a rate limit by default. | async def test_track_template_has_default_rate_limit(hass):
"""Test template has a rate limit by default."""
hass.states.async_set("sensor.zero", "any")
template_refresh = Template("{{ states | list | count }}", hass)
refresh_runs = []
@ha.callback
def refresh_listener(event, updates):
... | [
"async",
"def",
"test_track_template_has_default_rate_limit",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.zero\"",
",",
"\"any\"",
")",
"template_refresh",
"=",
"Template",
"(",
"\"{{ states | list | count }}\"",
",",
"hass",
")",
... | [
1717,
0
] | [
1748,
33
] | 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.