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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
NADtcp.is_volume_muted | (self) | Boolean if volume is currently muted. | Boolean if volume is currently muted. | def is_volume_muted(self):
"""Boolean if volume is currently muted."""
return self._mute | [
"def",
"is_volume_muted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_mute"
] | [
249,
4
] | [
251,
25
] | python | en | ['en', 'en', 'en'] | True |
NADtcp.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_NAD | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_NAD"
] | [
254,
4
] | [
256,
26
] | python | en | ['en', 'en', 'en'] | True |
NADtcp.turn_off | (self) | Turn the media player off. | Turn the media player off. | def turn_off(self):
"""Turn the media player off."""
self._nad_receiver.power_off() | [
"def",
"turn_off",
"(",
"self",
")",
":",
"self",
".",
"_nad_receiver",
".",
"power_off",
"(",
")"
] | [
258,
4
] | [
260,
38
] | python | en | ['en', 'en', 'en'] | True |
NADtcp.turn_on | (self) | Turn the media player on. | Turn the media player on. | def turn_on(self):
"""Turn the media player on."""
self._nad_receiver.power_on() | [
"def",
"turn_on",
"(",
"self",
")",
":",
"self",
".",
"_nad_receiver",
".",
"power_on",
"(",
")"
] | [
262,
4
] | [
264,
37
] | python | en | ['en', 'en', 'en'] | True |
NADtcp.volume_up | (self) | Step volume up in the configured increments. | Step volume up in the configured increments. | def volume_up(self):
"""Step volume up in the configured increments."""
self._nad_receiver.set_volume(self._nad_volume + 2 * self._volume_step) | [
"def",
"volume_up",
"(",
"self",
")",
":",
"self",
".",
"_nad_receiver",
".",
"set_volume",
"(",
"self",
".",
"_nad_volume",
"+",
"2",
"*",
"self",
".",
"_volume_step",
")"
] | [
266,
4
] | [
268,
79
] | python | en | ['en', 'en', 'en'] | True |
NADtcp.volume_down | (self) | Step volume down in the configured increments. | Step volume down in the configured increments. | def volume_down(self):
"""Step volume down in the configured increments."""
self._nad_receiver.set_volume(self._nad_volume - 2 * self._volume_step) | [
"def",
"volume_down",
"(",
"self",
")",
":",
"self",
".",
"_nad_receiver",
".",
"set_volume",
"(",
"self",
".",
"_nad_volume",
"-",
"2",
"*",
"self",
".",
"_volume_step",
")"
] | [
270,
4
] | [
272,
79
] | python | en | ['en', 'en', 'en'] | True |
NADtcp.set_volume_level | (self, volume) | Set volume level, range 0..1. | Set volume level, range 0..1. | def set_volume_level(self, volume):
"""Set volume level, range 0..1."""
nad_volume_to_set = int(
round(volume * (self._max_vol - self._min_vol) + self._min_vol)
)
self._nad_receiver.set_volume(nad_volume_to_set) | [
"def",
"set_volume_level",
"(",
"self",
",",
"volume",
")",
":",
"nad_volume_to_set",
"=",
"int",
"(",
"round",
"(",
"volume",
"*",
"(",
"self",
".",
"_max_vol",
"-",
"self",
".",
"_min_vol",
")",
"+",
"self",
".",
"_min_vol",
")",
")",
"self",
".",
... | [
274,
4
] | [
279,
56
] | python | en | ['fr', 'zu', 'en'] | False |
NADtcp.mute_volume | (self, mute) | Mute (true) or unmute (false) media player. | Mute (true) or unmute (false) media player. | def mute_volume(self, mute):
"""Mute (true) or unmute (false) media player."""
if mute:
self._nad_receiver.mute()
else:
self._nad_receiver.unmute() | [
"def",
"mute_volume",
"(",
"self",
",",
"mute",
")",
":",
"if",
"mute",
":",
"self",
".",
"_nad_receiver",
".",
"mute",
"(",
")",
"else",
":",
"self",
".",
"_nad_receiver",
".",
"unmute",
"(",
")"
] | [
281,
4
] | [
286,
39
] | python | en | ['en', 'la', 'it'] | False |
NADtcp.select_source | (self, source) | Select input source. | Select input source. | def select_source(self, source):
"""Select input source."""
self._nad_receiver.select_source(source) | [
"def",
"select_source",
"(",
"self",
",",
"source",
")",
":",
"self",
".",
"_nad_receiver",
".",
"select_source",
"(",
"source",
")"
] | [
288,
4
] | [
290,
48
] | python | en | ['fr', 'su', 'en'] | False |
NADtcp.source | (self) | Name of the current input source. | Name of the current input source. | def source(self):
"""Name of the current input source."""
return self._source | [
"def",
"source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_source"
] | [
293,
4
] | [
295,
27
] | python | en | ['en', 'en', 'en'] | True |
NADtcp.source_list | (self) | List of available input sources. | List of available input sources. | def source_list(self):
"""List of available input sources."""
return self._nad_receiver.available_sources() | [
"def",
"source_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_nad_receiver",
".",
"available_sources",
"(",
")"
] | [
298,
4
] | [
300,
53
] | python | en | ['en', 'en', 'en'] | True |
NADtcp.update | (self) | Get the latest details from the device. | Get the latest details from the device. | def update(self):
"""Get the latest details from the device."""
try:
nad_status = self._nad_receiver.status()
except OSError:
return
if nad_status is None:
return
# Update on/off state
if nad_status["power"]:
self._state = ... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"nad_status",
"=",
"self",
".",
"_nad_receiver",
".",
"status",
"(",
")",
"except",
"OSError",
":",
"return",
"if",
"nad_status",
"is",
"None",
":",
"return",
"# Update on/off state",
"if",
"nad_status",
... | [
302,
4
] | [
325,
43
] | python | en | ['en', 'en', 'en'] | True |
NADtcp.nad_vol_to_internal_vol | (self, nad_volume) | Convert nad volume range (0-200) to internal volume range.
Takes into account configured min and max volume.
| Convert nad volume range (0-200) to internal volume range. | def nad_vol_to_internal_vol(self, nad_volume):
"""Convert nad volume range (0-200) to internal volume range.
Takes into account configured min and max volume.
"""
if nad_volume < self._min_vol:
volume_internal = 0.0
elif nad_volume > self._max_vol:
volume... | [
"def",
"nad_vol_to_internal_vol",
"(",
"self",
",",
"nad_volume",
")",
":",
"if",
"nad_volume",
"<",
"self",
".",
"_min_vol",
":",
"volume_internal",
"=",
"0.0",
"elif",
"nad_volume",
">",
"self",
".",
"_max_vol",
":",
"volume_internal",
"=",
"1.0",
"else",
... | [
327,
4
] | [
340,
30
] | python | en | ['en', 'jv', 'en'] | True |
SetEnvVar | (env_var, value) | Sets/unsets an environment variable to a given value. | Sets/unsets an environment variable to a given value. | def SetEnvVar(env_var, value):
"""Sets/unsets an environment variable to a given value."""
if value is not None:
environ[env_var] = value
elif env_var in environ:
del environ[env_var] | [
"def",
"SetEnvVar",
"(",
"env_var",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"environ",
"[",
"env_var",
"]",
"=",
"value",
"elif",
"env_var",
"in",
"environ",
":",
"del",
"environ",
"[",
"env_var",
"]"
] | [
61,
0
] | [
67,
24
] | python | en | ['en', 'en', 'en'] | True |
_ParseAndStripGTestFlags | (argv) | Parses and strips Google Test flags from argv. This is idempotent. | Parses and strips Google Test flags from argv. This is idempotent. | def _ParseAndStripGTestFlags(argv):
"""Parses and strips Google Test flags from argv. This is idempotent."""
# Suppresses the lint complaint about a global variable since we need it
# here to maintain module-wide state.
global _gtest_flags_are_parsed # pylint: disable=W0603
if _gtest_flags_are_parsed:
... | [
"def",
"_ParseAndStripGTestFlags",
"(",
"argv",
")",
":",
"# Suppresses the lint complaint about a global variable since we need it",
"# here to maintain module-wide state.",
"global",
"_gtest_flags_are_parsed",
"# pylint: disable=W0603",
"if",
"_gtest_flags_are_parsed",
":",
"return",
... | [
82,
0
] | [
108,
14
] | python | en | ['en', 'en', 'en'] | True |
GetFlag | (flag) | Returns the value of the given flag. | Returns the value of the given flag. | def GetFlag(flag):
"""Returns the value of the given flag."""
# In case GetFlag() is called before Main(), we always call
# _ParseAndStripGTestFlags() here to make sure the --gtest_* flags
# are parsed.
_ParseAndStripGTestFlags(sys.argv)
return _flag_map[flag] | [
"def",
"GetFlag",
"(",
"flag",
")",
":",
"# In case GetFlag() is called before Main(), we always call",
"# _ParseAndStripGTestFlags() here to make sure the --gtest_* flags",
"# are parsed.",
"_ParseAndStripGTestFlags",
"(",
"sys",
".",
"argv",
")",
"return",
"_flag_map",
"[",
"fl... | [
111,
0
] | [
119,
24
] | python | en | ['en', 'en', 'en'] | True |
GetSourceDir | () | Returns the absolute path of the directory where the .py files are. | Returns the absolute path of the directory where the .py files are. | def GetSourceDir():
"""Returns the absolute path of the directory where the .py files are."""
return os.path.abspath(GetFlag('source_dir')) | [
"def",
"GetSourceDir",
"(",
")",
":",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"GetFlag",
"(",
"'source_dir'",
")",
")"
] | [
122,
0
] | [
125,
47
] | python | en | ['en', 'en', 'en'] | True |
GetBuildDir | () | Returns the absolute path of the directory where the test binaries are. | Returns the absolute path of the directory where the test binaries are. | def GetBuildDir():
"""Returns the absolute path of the directory where the test binaries are."""
return os.path.abspath(GetFlag('build_dir')) | [
"def",
"GetBuildDir",
"(",
")",
":",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"GetFlag",
"(",
"'build_dir'",
")",
")"
] | [
128,
0
] | [
131,
46
] | python | en | ['en', 'en', 'en'] | True |
GetTestExecutablePath | (executable_name, build_dir=None) | Returns the absolute path of the test binary given its name.
The function will print a message and abort the program if the resulting file
doesn't exist.
Args:
executable_name: name of the test binary that the test script runs.
build_dir: directory where to look for executables, by default
... | Returns the absolute path of the test binary given its name. | def GetTestExecutablePath(executable_name, build_dir=None):
"""Returns the absolute path of the test binary given its name.
The function will print a message and abort the program if the resulting file
doesn't exist.
Args:
executable_name: name of the test binary that the test script runs.
build_dir: ... | [
"def",
"GetTestExecutablePath",
"(",
"executable_name",
",",
"build_dir",
"=",
"None",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"build_dir",
"or",
"GetBuildDir",
"(",
")",
",",
"executable_name",
... | [
150,
0
] | [
178,
13
] | python | en | ['en', 'en', 'en'] | True |
GetExitStatus | (exit_code) | Returns the argument to exit(), or -1 if exit() wasn't called.
Args:
exit_code: the result value of os.system(command).
| Returns the argument to exit(), or -1 if exit() wasn't called. | def GetExitStatus(exit_code):
"""Returns the argument to exit(), or -1 if exit() wasn't called.
Args:
exit_code: the result value of os.system(command).
"""
if os.name == 'nt':
# On Windows, os.WEXITSTATUS() doesn't work and os.system() returns
# the argument to exit() directly.
return exit_co... | [
"def",
"GetExitStatus",
"(",
"exit_code",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"# On Windows, os.WEXITSTATUS() doesn't work and os.system() returns",
"# the argument to exit() directly.",
"return",
"exit_code",
"else",
":",
"# On Unix, os.WEXITSTATUS() must be ... | [
181,
0
] | [
198,
15
] | python | en | ['en', 'en', 'en'] | True |
Main | () | Runs the unit test. | Runs the unit test. | def Main():
"""Runs the unit test."""
# We must call _ParseAndStripGTestFlags() before calling
# unittest.main(). Otherwise the latter will be confused by the
# --gtest_* flags.
_ParseAndStripGTestFlags(sys.argv)
# The tested binaries should not be writing XML output files unless the
# script explicitly... | [
"def",
"Main",
"(",
")",
":",
"# We must call _ParseAndStripGTestFlags() before calling",
"# unittest.main(). Otherwise the latter will be confused by the",
"# --gtest_* flags.",
"_ParseAndStripGTestFlags",
"(",
"sys",
".",
"argv",
")",
"# The tested binaries should not be writing XML o... | [
301,
0
] | [
313,
21
] | python | en | ['en', 'fr', 'en'] | True |
Subprocess.__init__ | (self, command, working_dir=None, capture_stderr=True, env=None) | Changes into a specified directory, if provided, and executes a command.
Restores the old directory afterwards.
Args:
command: The command to run, in the form of sys.argv.
working_dir: The directory to change into.
capture_stderr: Determines whether to capture stderr in the output ... | Changes into a specified directory, if provided, and executes a command. | def __init__(self, command, working_dir=None, capture_stderr=True, env=None):
"""Changes into a specified directory, if provided, and executes a command.
Restores the old directory afterwards.
Args:
command: The command to run, in the form of sys.argv.
working_dir: The directory to c... | [
"def",
"__init__",
"(",
"self",
",",
"command",
",",
"working_dir",
"=",
"None",
",",
"capture_stderr",
"=",
"True",
",",
"env",
"=",
"None",
")",
":",
"# The subprocess module is the preferrable way of running programs",
"# since it is available and behaves consistently on... | [
202,
2
] | [
298,
40
] | python | en | ['en', 'en', 'en'] | True |
test_creating_entry_sets_up_climate_discovery | (hass) | Test setting up Hisense AEH-W4A1 loads the climate component. | Test setting up Hisense AEH-W4A1 loads the climate component. | async def test_creating_entry_sets_up_climate_discovery(hass):
"""Test setting up Hisense AEH-W4A1 loads the climate component."""
with patch(
"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.discovery",
return_value=["1.2.3.4"],
), patch(
"homeassistant.components.hisen... | [
"async",
"def",
"test_creating_entry_sets_up_climate_discovery",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.discovery\"",
",",
"return_value",
"=",
"[",
"\"1.2.3.4\"",
"]",
",",
")",
",",
"patch",
"(",
"\"h... | [
10,
0
] | [
31,
42
] | python | en | ['en', 'en', 'en'] | True |
test_configuring_hisense_w4a1_create_entry | (hass) | Test that specifying config will create an entry. | Test that specifying config will create an entry. | async def test_configuring_hisense_w4a1_create_entry(hass):
"""Test that specifying config will create an entry."""
with patch(
"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.check",
return_value=True,
), patch(
"homeassistant.components.hisense_aehw4a1.async_setup_ent... | [
"async",
"def",
"test_configuring_hisense_w4a1_create_entry",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.check\"",
",",
"return_value",
"=",
"True",
",",
")",
",",
"patch",
"(",
"\"homeassistant.components.hise... | [
34,
0
] | [
50,
42
] | python | en | ['en', 'en', 'en'] | True |
test_configuring_hisense_w4a1_not_creates_entry_for_device_not_found | (hass) | Test that specifying config will not create an entry. | Test that specifying config will not create an entry. | async def test_configuring_hisense_w4a1_not_creates_entry_for_device_not_found(hass):
"""Test that specifying config will not create an entry."""
with patch(
"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.check",
side_effect=exceptions.ConnectionError,
), patch(
"homea... | [
"async",
"def",
"test_configuring_hisense_w4a1_not_creates_entry_for_device_not_found",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hisense_aehw4a1.config_flow.AehW4a1.check\"",
",",
"side_effect",
"=",
"exceptions",
".",
"ConnectionError",
",",
")",
... | [
53,
0
] | [
69,
42
] | python | en | ['en', 'en', 'en'] | True |
test_configuring_hisense_w4a1_not_creates_entry_for_empty_import | (hass) | Test that specifying config will not create an entry. | Test that specifying config will not create an entry. | async def test_configuring_hisense_w4a1_not_creates_entry_for_empty_import(hass):
"""Test that specifying config will not create an entry."""
with patch(
"homeassistant.components.hisense_aehw4a1.async_setup_entry",
return_value=True,
) as mock_setup:
await async_setup_component(hass... | [
"async",
"def",
"test_configuring_hisense_w4a1_not_creates_entry_for_empty_import",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hisense_aehw4a1.async_setup_entry\"",
",",
"return_value",
"=",
"True",
",",
")",
"as",
"mock_setup",
":",
"await",
"... | [
72,
0
] | [
81,
42
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the Nextcloud integration. | Set up the Nextcloud integration. | def setup(hass, config):
"""Set up the Nextcloud integration."""
# Fetch Nextcloud Monitor api data
conf = config[DOMAIN]
try:
ncm = NextcloudMonitor(conf[CONF_URL], conf[CONF_USERNAME], conf[CONF_PASSWORD])
except NextcloudMonitorError:
_LOGGER.error("Nextcloud setup failed - Check... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"# Fetch Nextcloud Monitor api data",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"try",
":",
"ncm",
"=",
"NextcloudMonitor",
"(",
"conf",
"[",
"CONF_URL",
"]",
",",
"conf",
"[",
"CONF_USERNAME",
"]",
",... | [
91,
0
] | [
121,
15
] | python | en | ['en', 'su', 'en'] | True |
get_data_points | (api_data, key_path="", leaf=False) | Use Recursion to discover data-points and values.
Get dictionary of data-points by recursing through dict returned by api until
the dictionary value does not contain another dictionary and use the
resulting path of dictionary keys and resulting value as the name/value
for the data-point.
returns: ... | Use Recursion to discover data-points and values. | def get_data_points(api_data, key_path="", leaf=False):
"""Use Recursion to discover data-points and values.
Get dictionary of data-points by recursing through dict returned by api until
the dictionary value does not contain another dictionary and use the
resulting path of dictionary keys and resulting... | [
"def",
"get_data_points",
"(",
"api_data",
",",
"key_path",
"=",
"\"\"",
",",
"leaf",
"=",
"False",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"api_data",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
... | [
125,
0
] | [
147,
17
] | python | en | ['en', 'en', 'en'] | True |
hassio_env | () | Fixture to inject hassio env. | Fixture to inject hassio env. | def hassio_env():
"""Fixture to inject hassio env."""
with patch.dict(os.environ, {"HASSIO": "127.0.0.1"}), patch(
"homeassistant.components.hassio.HassIO.is_connected",
return_value={"result": "ok", "data": {}},
), patch.dict(os.environ, {"HASSIO_TOKEN": HASSIO_TOKEN}), patch(
"home... | [
"def",
"hassio_env",
"(",
")",
":",
"with",
"patch",
".",
"dict",
"(",
"os",
".",
"environ",
",",
"{",
"\"HASSIO\"",
":",
"\"127.0.0.1\"",
"}",
")",
",",
"patch",
"(",
"\"homeassistant.components.hassio.HassIO.is_connected\"",
",",
"return_value",
"=",
"{",
"\... | [
14,
0
] | [
23,
13
] | python | en | ['en', 'en', 'en'] | True |
hassio_stubs | (hassio_env, hass, hass_client, aioclient_mock) | Create mock hassio http client. | Create mock hassio http client. | def hassio_stubs(hassio_env, hass, hass_client, aioclient_mock):
"""Create mock hassio http client."""
with patch(
"homeassistant.components.hassio.HassIO.update_hass_api",
return_value={"result": "ok"},
) as hass_api, patch(
"homeassistant.components.hassio.HassIO.update_hass_timezo... | [
"def",
"hassio_stubs",
"(",
"hassio_env",
",",
"hass",
",",
"hass_client",
",",
"aioclient_mock",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.hassio.HassIO.update_hass_api\"",
",",
"return_value",
"=",
"{",
"\"result\"",
":",
"\"ok\"",
"}",
",",
")",... | [
27,
0
] | [
42,
35
] | python | en | ['en', 'en', 'en'] | True |
hassio_client | (hassio_stubs, hass, hass_client) | Return a Hass.io HTTP client. | Return a Hass.io HTTP client. | def hassio_client(hassio_stubs, hass, hass_client):
"""Return a Hass.io HTTP client."""
return hass.loop.run_until_complete(hass_client()) | [
"def",
"hassio_client",
"(",
"hassio_stubs",
",",
"hass",
",",
"hass_client",
")",
":",
"return",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"hass_client",
"(",
")",
")"
] | [
46,
0
] | [
48,
54
] | python | en | ['es', 'en', 'en'] | True |
hassio_noauth_client | (hassio_stubs, hass, aiohttp_client) | Return a Hass.io HTTP client without auth. | Return a Hass.io HTTP client without auth. | def hassio_noauth_client(hassio_stubs, hass, aiohttp_client):
"""Return a Hass.io HTTP client without auth."""
return hass.loop.run_until_complete(aiohttp_client(hass.http.app)) | [
"def",
"hassio_noauth_client",
"(",
"hassio_stubs",
",",
"hass",
",",
"aiohttp_client",
")",
":",
"return",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"aiohttp_client",
"(",
"hass",
".",
"http",
".",
"app",
")",
")"
] | [
52,
0
] | [
54,
70
] | python | en | ['en', 'en', 'en'] | True |
hassio_client_supervisor | (hass, aiohttp_client, hassio_stubs) | Return an authenticated HTTP client. | Return an authenticated HTTP client. | async def hassio_client_supervisor(hass, aiohttp_client, hassio_stubs):
"""Return an authenticated HTTP client."""
access_token = hass.auth.async_create_access_token(hassio_stubs)
return await aiohttp_client(
hass.http.app,
headers={"Authorization": f"Bearer {access_token}"},
) | [
"async",
"def",
"hassio_client_supervisor",
"(",
"hass",
",",
"aiohttp_client",
",",
"hassio_stubs",
")",
":",
"access_token",
"=",
"hass",
".",
"auth",
".",
"async_create_access_token",
"(",
"hassio_stubs",
")",
"return",
"await",
"aiohttp_client",
"(",
"hass",
"... | [
58,
0
] | [
64,
5
] | python | en | ['en', 'en', 'en'] | True |
hassio_handler | (hass, aioclient_mock) | Create mock hassio handler. | Create mock hassio handler. | def hassio_handler(hass, aioclient_mock):
"""Create mock hassio handler."""
async def get_client_session():
return hass.helpers.aiohttp_client.async_get_clientsession()
websession = hass.loop.run_until_complete(get_client_session())
with patch.dict(os.environ, {"HASSIO_TOKEN": HASSIO_TOKEN}):... | [
"def",
"hassio_handler",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"async",
"def",
"get_client_session",
"(",
")",
":",
"return",
"hass",
".",
"helpers",
".",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
")",
"websession",
"=",
"hass",
".",
"loop... | [
68,
0
] | [
77,
56
] | python | en | ['en', 'xh', 'en'] | True |
Marshaller.marshal | (self, o, use_value_list=False) |
Packages the return from a parser for easy use in a rule.
|
Packages the return from a parser for easy use in a rule.
| def marshal(self, o, use_value_list=False):
"""
Packages the return from a parser for easy use in a rule.
"""
if o is None:
return
elif isinstance(o, dict):
if use_value_list:
for k, v in o.items():
o[k] = [v]
... | [
"def",
"marshal",
"(",
"self",
",",
"o",
",",
"use_value_list",
"=",
"False",
")",
":",
"if",
"o",
"is",
"None",
":",
"return",
"elif",
"isinstance",
"(",
"o",
",",
"dict",
")",
":",
"if",
"use_value_list",
":",
"for",
"k",
",",
"v",
"in",
"o",
"... | [
18,
4
] | [
36,
81
] | python | en | ['en', 'error', 'th'] | False |
get_service | (hass, config, discovery_info=None) | Return the notify service. | Return the notify service. | def get_service(hass, config, discovery_info=None):
"""Return the notify service."""
username = config.get(CONF_USERNAME)
password = config.get(CONF_PASSWORD)
url = config.get(CONF_URL)
room = config.get(CONF_ROOM)
try:
return RocketChatNotificationService(url, username, password, roo... | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"username",
"=",
"config",
".",
"get",
"(",
"CONF_USERNAME",
")",
"password",
"=",
"config",
".",
"get",
"(",
"CONF_PASSWORD",
")",
"url",
"=",
"config",
".",... | [
37,
0
] | [
54,
15
] | python | en | ['en', 'en', 'en'] | True |
RocketChatNotificationService.__init__ | (self, url, username, password, room) | Initialize the service. | Initialize the service. | def __init__(self, url, username, password, room):
"""Initialize the service."""
self._room = room
self._server = RocketChat(username, password, server_url=url) | [
"def",
"__init__",
"(",
"self",
",",
"url",
",",
"username",
",",
"password",
",",
"room",
")",
":",
"self",
".",
"_room",
"=",
"room",
"self",
".",
"_server",
"=",
"RocketChat",
"(",
"username",
",",
"password",
",",
"server_url",
"=",
"url",
")"
] | [
60,
4
] | [
64,
69
] | python | en | ['en', 'en', 'en'] | True |
RocketChatNotificationService.send_message | (self, message="", **kwargs) | Send a message to Rocket.Chat. | Send a message to Rocket.Chat. | def send_message(self, message="", **kwargs):
"""Send a message to Rocket.Chat."""
data = kwargs.get(ATTR_DATA) or {}
resp = self._server.chat_post_message(message, channel=self._room, **data)
if resp.status_code == HTTP_OK:
success = resp.json()["success"]
if not... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_DATA",
")",
"or",
"{",
"}",
"resp",
"=",
"self",
".",
"_server",
".",
"chat_post_message",
"(",
"message... | [
66,
4
] | [
77,
13
] | python | en | ['en', 'en', 'en'] | True |
test_setup | (hass) | Test setting up from configuration.yaml. | Test setting up from configuration.yaml. | async def test_setup(hass):
"""Test setting up from configuration.yaml."""
conf = {
DOMAIN: {
CONF_API_KEY: "123456",
CONF_YAML_API_TOKEN: "AbCDeF",
CONF_CURRENCIES: [GOOD_CURRENCY, GOOD_CURRENCY_2],
CONF_EXCHANGE_RATES: [GOOD_EXCHANGE_RATE, GOOD_EXCHANGE_... | [
"async",
"def",
"test_setup",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"DOMAIN",
":",
"{",
"CONF_API_KEY",
":",
"\"123456\"",
",",
"CONF_YAML_API_TOKEN",
":",
"\"AbCDeF\"",
",",
"CONF_CURRENCIES",
":",
"[",
"GOOD_CURRENCY",
",",
"GOOD_CURRENCY_2",
"]",
",",
... | [
30,
0
] | [
58,
9
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass) | Test successful unload of entry. | Test successful unload of entry. | async def test_unload_entry(hass):
"""Test successful unload of entry."""
with patch(
"coinbase.wallet.client.Client.get_current_user",
return_value=mock_get_current_user(),
), patch(
"coinbase.wallet.client.Client.get_accounts",
new=mocked_get_accounts,
), patch(
... | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"coinbase.wallet.client.Client.get_current_user\"",
",",
"return_value",
"=",
"mock_get_current_user",
"(",
")",
",",
")",
",",
"patch",
"(",
"\"coinbase.wallet.client.Client.get_accounts\... | [
61,
0
] | [
82,
36
] | python | en | ['en', 'en', 'en'] | True |
test_option_updates | (hass: HomeAssistant) | Test handling option updates. | Test handling option updates. | async def test_option_updates(hass: HomeAssistant):
"""Test handling option updates."""
with patch(
"coinbase.wallet.client.Client.get_current_user",
return_value=mock_get_current_user(),
), patch(
"coinbase.wallet.client.Client.get_accounts", new=mocked_get_accounts
), patch(
... | [
"async",
"def",
"test_option_updates",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"with",
"patch",
"(",
"\"coinbase.wallet.client.Client.get_current_user\"",
",",
"return_value",
"=",
"mock_get_current_user",
"(",
")",
",",
")",
",",
"patch",
"(",
"\"coinbase.wallet... | [
85,
0
] | [
160,
44
] | python | de | ['de', 'de', 'en'] | True |
test_ignore_vaults_wallets | (hass: HomeAssistant) | Test vaults are ignored in wallet sensors. | Test vaults are ignored in wallet sensors. | async def test_ignore_vaults_wallets(hass: HomeAssistant):
"""Test vaults are ignored in wallet sensors."""
with patch(
"coinbase.wallet.client.Client.get_current_user",
return_value=mock_get_current_user(),
), patch(
"coinbase.wallet.client.Client.get_accounts", new=mocked_get_acco... | [
"async",
"def",
"test_ignore_vaults_wallets",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"with",
"patch",
"(",
"\"coinbase.wallet.client.Client.get_current_user\"",
",",
"return_value",
"=",
"mock_get_current_user",
"(",
")",
",",
")",
",",
"patch",
"(",
"\"coinbase... | [
163,
0
] | [
184,
65
] | python | en | ['en', 'en', 'en'] | True |
print_names | (families) | Write the names of the families in sorted order. | Write the names of the families in sorted order. | def print_names(families):
"""Write the names of the families in sorted order."""
family_names = [family.name for family in families.values()]
for name in sorted(family_names):
print(name) | [
"def",
"print_names",
"(",
"families",
")",
":",
"family_names",
"=",
"[",
"family",
".",
"name",
"for",
"family",
"in",
"families",
".",
"values",
"(",
")",
"]",
"for",
"name",
"in",
"sorted",
"(",
"family_names",
")",
":",
"print",
"(",
"name",
")"
] | [
24,
0
] | [
28,
19
] | python | en | ['en', 'en', 'en'] | True |
BasePlatform.__init__ | (self, hub: ModbusHub, entry: dict[str, Any]) | Initialize the Modbus binary sensor. | Initialize the Modbus binary sensor. | def __init__(self, hub: ModbusHub, entry: dict[str, Any]) -> None:
"""Initialize the Modbus binary sensor."""
self._hub = hub
# temporary fix,
# make sure slave is always defined to avoid an error in pymodbus
# attr(in_waiting) not defined.
# see issue #657 and PR #660 in... | [
"def",
"__init__",
"(",
"self",
",",
"hub",
":",
"ModbusHub",
",",
"entry",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"self",
".",
"_hub",
"=",
"hub",
"# temporary fix,",
"# make sure slave is always defined to avoid an error in pymodbus"... | [
62,
4
] | [
82,
50
] | python | en | ['en', 'pl', 'en'] | True |
BasePlatform.async_update | (self, now=None) | Virtual function to be overwritten. | Virtual function to be overwritten. | async def async_update(self, now=None):
"""Virtual function to be overwritten.""" | [
"async",
"def",
"async_update",
"(",
"self",
",",
"now",
"=",
"None",
")",
":"
] | [
85,
4
] | [
86,
49
] | python | en | ['en', 'en', 'en'] | True |
BasePlatform.async_base_added_to_hass | (self) | Handle entity which will be added. | Handle entity which will be added. | async def async_base_added_to_hass(self):
"""Handle entity which will be added."""
if self._scan_interval > 0:
cancel_func = async_track_time_interval(
self.hass, self.async_update, timedelta(seconds=self._scan_interval)
)
self._hub.entity_timers.appen... | [
"async",
"def",
"async_base_added_to_hass",
"(",
"self",
")",
":",
"if",
"self",
".",
"_scan_interval",
">",
"0",
":",
"cancel_func",
"=",
"async_track_time_interval",
"(",
"self",
".",
"hass",
",",
"self",
".",
"async_update",
",",
"timedelta",
"(",
"seconds"... | [
88,
4
] | [
94,
55
] | python | en | ['en', 'en', 'en'] | True |
BaseStructPlatform.__init__ | (self, hub: ModbusHub, config: dict) | Initialize the switch. | Initialize the switch. | def __init__(self, hub: ModbusHub, config: dict) -> None:
"""Initialize the switch."""
super().__init__(hub, config)
self._swap = config[CONF_SWAP]
self._data_type = config[CONF_DATA_TYPE]
self._structure = config.get(CONF_STRUCTURE)
self._precision = config[CONF_PRECISIO... | [
"def",
"__init__",
"(",
"self",
",",
"hub",
":",
"ModbusHub",
",",
"config",
":",
"dict",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hub",
",",
"config",
")",
"self",
".",
"_swap",
"=",
"config",
"[",
"CONF_SWAP",
"]",
"self"... | [
100,
4
] | [
109,
40
] | python | en | ['en', 'en', 'en'] | True |
BaseStructPlatform._swap_registers | (self, registers) | Do swap as needed. | Do swap as needed. | def _swap_registers(self, registers):
"""Do swap as needed."""
if self._swap in (CONF_SWAP_BYTE, CONF_SWAP_WORD_BYTE):
# convert [12][34] --> [21][43]
for i, register in enumerate(registers):
registers[i] = int.from_bytes(
register.to_bytes(2, ... | [
"def",
"_swap_registers",
"(",
"self",
",",
"registers",
")",
":",
"if",
"self",
".",
"_swap",
"in",
"(",
"CONF_SWAP_BYTE",
",",
"CONF_SWAP_WORD_BYTE",
")",
":",
"# convert [12][34] --> [21][43]",
"for",
"i",
",",
"register",
"in",
"enumerate",
"(",
"registers",... | [
111,
4
] | [
124,
24
] | python | en | ['en', 'en', 'en'] | True |
BaseStructPlatform.unpack_structure_result | (self, registers) | Convert registers to proper result. | Convert registers to proper result. | def unpack_structure_result(self, registers):
"""Convert registers to proper result."""
registers = self._swap_registers(registers)
byte_string = b"".join([x.to_bytes(2, byteorder="big") for x in registers])
if self._data_type == DATA_TYPE_STRING:
return byte_string.decode()... | [
"def",
"unpack_structure_result",
"(",
"self",
",",
"registers",
")",
":",
"registers",
"=",
"self",
".",
"_swap_registers",
"(",
"registers",
")",
"byte_string",
"=",
"b\"\"",
".",
"join",
"(",
"[",
"x",
".",
"to_bytes",
"(",
"2",
",",
"byteorder",
"=",
... | [
126,
4
] | [
161,
50
] | python | en | ['en', 'en', 'en'] | True |
BaseSwitch.__init__ | (self, hub: ModbusHub, config: dict) | Initialize the switch. | Initialize the switch. | def __init__(self, hub: ModbusHub, config: dict) -> None:
"""Initialize the switch."""
config[CONF_INPUT_TYPE] = ""
super().__init__(hub, config)
self._attr_is_on = False
convert = {
CALL_TYPE_REGISTER_HOLDING: (
CALL_TYPE_REGISTER_HOLDING,
... | [
"def",
"__init__",
"(",
"self",
",",
"hub",
":",
"ModbusHub",
",",
"config",
":",
"dict",
")",
"->",
"None",
":",
"config",
"[",
"CONF_INPUT_TYPE",
"]",
"=",
"\"\"",
"super",
"(",
")",
".",
"__init__",
"(",
"hub",
",",
"config",
")",
"self",
".",
"... | [
167,
4
] | [
209,
39
] | python | en | ['en', 'en', 'en'] | True |
BaseSwitch.async_added_to_hass | (self) | Handle entity which will be added. | Handle entity which will be added. | async def async_added_to_hass(self):
"""Handle entity which will be added."""
await self.async_base_added_to_hass()
state = await self.async_get_last_state()
if state:
self._attr_is_on = state.state == STATE_ON | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"self",
".",
"async_base_added_to_hass",
"(",
")",
"state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"if",
"state",
":",
"self",
".",
"_attr_is_on",
"=",
"state",
".",... | [
211,
4
] | [
216,
54
] | python | en | ['en', 'en', 'en'] | True |
BaseSwitch.async_turn | (self, command) | Evaluate switch result. | Evaluate switch result. | async def async_turn(self, command):
"""Evaluate switch result."""
result = await self._hub.async_pymodbus_call(
self._slave, self._address, command, self._write_type
)
if result is None:
self._attr_available = False
self.async_write_ha_state()
... | [
"async",
"def",
"async_turn",
"(",
"self",
",",
"command",
")",
":",
"result",
"=",
"await",
"self",
".",
"_hub",
".",
"async_pymodbus_call",
"(",
"self",
".",
"_slave",
",",
"self",
".",
"_address",
",",
"command",
",",
"self",
".",
"_write_type",
")",
... | [
218,
4
] | [
237,
37
] | python | en | ['en', 'en', 'en'] | True |
BaseSwitch.async_turn_off | (self, **kwargs) | Set switch off. | Set switch off. | async def async_turn_off(self, **kwargs):
"""Set switch off."""
await self.async_turn(self._command_off) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"async_turn",
"(",
"self",
".",
"_command_off",
")"
] | [
239,
4
] | [
241,
48
] | python | en | ['en', 'ja', 'en'] | True |
BaseSwitch.async_update | (self, now=None) | Update the entity state. | Update the entity state. | async def async_update(self, now=None):
"""Update the entity state."""
# remark "now" is a dummy parameter to avoid problems with
# async_track_time_interval
if not self._verify_active:
self._attr_available = True
self.async_write_ha_state()
return
... | [
"async",
"def",
"async_update",
"(",
"self",
",",
"now",
"=",
"None",
")",
":",
"# remark \"now\" is a dummy parameter to avoid problems with",
"# async_track_time_interval",
"if",
"not",
"self",
".",
"_verify_active",
":",
"self",
".",
"_attr_available",
"=",
"True",
... | [
243,
4
] | [
286,
35
] | python | en | ['en', 'en', 'en'] | True |
_set_up_units | (hass) | Set up the tests. | Set up the tests. | def _set_up_units(hass):
"""Set up the tests."""
hass.config.units = UnitSystem(
"custom", TEMP_CELSIUS, LENGTH_METERS, VOLUME_LITERS, MASS_GRAMS, PRESSURE_PA
) | [
"def",
"_set_up_units",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"units",
"=",
"UnitSystem",
"(",
"\"custom\"",
",",
"TEMP_CELSIUS",
",",
"LENGTH_METERS",
",",
"VOLUME_LITERS",
",",
"MASS_GRAMS",
",",
"PRESSURE_PA",
")"
] | [
33,
0
] | [
37,
5
] | python | en | ['en', 'en', 'en'] | True |
render_to_info | (hass, template_str, variables=None) | Create render info from template. | Create render info from template. | def render_to_info(hass, template_str, variables=None):
"""Create render info from template."""
tmp = template.Template(template_str, hass)
return tmp.async_render_to_info(variables) | [
"def",
"render_to_info",
"(",
"hass",
",",
"template_str",
",",
"variables",
"=",
"None",
")",
":",
"tmp",
"=",
"template",
".",
"Template",
"(",
"template_str",
",",
"hass",
")",
"return",
"tmp",
".",
"async_render_to_info",
"(",
"variables",
")"
] | [
40,
0
] | [
43,
46
] | python | en | ['en', 'en', 'en'] | True |
extract_entities | (hass, template_str, variables=None) | Extract entities from a template. | Extract entities from a template. | def extract_entities(hass, template_str, variables=None):
"""Extract entities from a template."""
info = render_to_info(hass, template_str, variables)
return info.entities | [
"def",
"extract_entities",
"(",
"hass",
",",
"template_str",
",",
"variables",
"=",
"None",
")",
":",
"info",
"=",
"render_to_info",
"(",
"hass",
",",
"template_str",
",",
"variables",
")",
"return",
"info",
".",
"entities"
] | [
46,
0
] | [
49,
24
] | python | en | ['en', 'en', 'en'] | True |
assert_result_info | (info, result, entities=None, domains=None, all_states=False) | Check result info. | Check result info. | def assert_result_info(info, result, entities=None, domains=None, all_states=False):
"""Check result info."""
assert info.result() == result
assert info.all_states == all_states
assert info.filter("invalid_entity_name.somewhere") == all_states
if entities is not None:
assert info.entities ==... | [
"def",
"assert_result_info",
"(",
"info",
",",
"result",
",",
"entities",
"=",
"None",
",",
"domains",
"=",
"None",
",",
"all_states",
"=",
"False",
")",
":",
"assert",
"info",
".",
"result",
"(",
")",
"==",
"result",
"assert",
"info",
".",
"all_states",... | [
52,
0
] | [
68,
44
] | python | en | ['en', 'kk', 'en'] | True |
test_template_equality | () | Test template comparison and hashing. | Test template comparison and hashing. | def test_template_equality():
"""Test template comparison and hashing."""
template_one = template.Template("{{ template_one }}")
template_one_1 = template.Template("{{ template_one }}")
template_two = template.Template("{{ template_two }}")
assert template_one == template_one_1
assert template_... | [
"def",
"test_template_equality",
"(",
")",
":",
"template_one",
"=",
"template",
".",
"Template",
"(",
"\"{{ template_one }}\"",
")",
"template_one_1",
"=",
"template",
".",
"Template",
"(",
"\"{{ template_one }}\"",
")",
"template_two",
"=",
"template",
".",
"Templ... | [
71,
0
] | [
85,
49
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_template | (hass) | Invalid template raises error. | Invalid template raises error. | def test_invalid_template(hass):
"""Invalid template raises error."""
tmpl = template.Template("{{", hass)
with pytest.raises(TemplateError):
tmpl.ensure_valid()
with pytest.raises(TemplateError):
tmpl.async_render()
info = tmpl.async_render_to_info()
with pytest.raises(Templa... | [
"def",
"test_invalid_template",
"(",
"hass",
")",
":",
"tmpl",
"=",
"template",
".",
"Template",
"(",
"\"{{\"",
",",
"hass",
")",
"with",
"pytest",
".",
"raises",
"(",
"TemplateError",
")",
":",
"tmpl",
".",
"ensure_valid",
"(",
")",
"with",
"pytest",
".... | [
88,
0
] | [
107,
27
] | python | en | ['fi', 'et', 'en'] | False |
test_referring_states_by_entity_id | (hass) | Test referring states by entity id. | Test referring states by entity id. | def test_referring_states_by_entity_id(hass):
"""Test referring states by entity id."""
hass.states.async_set("test.object", "happy")
assert (
template.Template("{{ states.test.object.state }}", hass).async_render()
== "happy"
)
assert (
template.Template('{{ states["test.ob... | [
"def",
"test_referring_states_by_entity_id",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"test.object\"",
",",
"\"happy\"",
")",
"assert",
"(",
"template",
".",
"Template",
"(",
"\"{{ states.test.object.state }}\"",
",",
"hass",
")",
"."... | [
110,
0
] | [
125,
5
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_entity_id | (hass) | Test referring states by entity id. | Test referring states by entity id. | def test_invalid_entity_id(hass):
"""Test referring states by entity id."""
with pytest.raises(TemplateError):
template.Template('{{ states["big.fat..."] }}', hass).async_render()
with pytest.raises(TemplateError):
template.Template('{{ states.test["big.fat..."] }}', hass).async_render()
... | [
"def",
"test_invalid_entity_id",
"(",
"hass",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"TemplateError",
")",
":",
"template",
".",
"Template",
"(",
"'{{ states[\"big.fat...\"] }}'",
",",
"hass",
")",
".",
"async_render",
"(",
")",
"with",
"pytest",
".",... | [
128,
0
] | [
135,
80
] | python | en | ['en', 'en', 'en'] | True |
test_raise_exception_on_error | (hass) | Test raising an exception on error. | Test raising an exception on error. | def test_raise_exception_on_error(hass):
"""Test raising an exception on error."""
with pytest.raises(TemplateError):
template.Template("{{ invalid_syntax").ensure_valid() | [
"def",
"test_raise_exception_on_error",
"(",
"hass",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"TemplateError",
")",
":",
"template",
".",
"Template",
"(",
"\"{{ invalid_syntax\"",
")",
".",
"ensure_valid",
"(",
")"
] | [
138,
0
] | [
141,
61
] | python | en | ['en', 'de', 'en'] | True |
test_iterating_all_states | (hass) | Test iterating all states. | Test iterating all states. | def test_iterating_all_states(hass):
"""Test iterating all states."""
tmpl_str = "{% for state in states %}{{ state.state }}{% endfor %}"
info = render_to_info(hass, tmpl_str)
assert_result_info(info, "", all_states=True)
assert info.rate_limit == template.ALL_STATES_RATE_LIMIT
hass.states.asy... | [
"def",
"test_iterating_all_states",
"(",
"hass",
")",
":",
"tmpl_str",
"=",
"\"{% for state in states %}{{ state.state }}{% endfor %}\"",
"info",
"=",
"render_to_info",
"(",
"hass",
",",
"tmpl_str",
")",
"assert_result_info",
"(",
"info",
",",
"\"\"",
",",
"all_states",... | [
144,
0
] | [
156,
69
] | python | en | ['en', 'en', 'en'] | True |
test_iterating_all_states_unavailable | (hass) | Test iterating all states unavailable. | Test iterating all states unavailable. | def test_iterating_all_states_unavailable(hass):
"""Test iterating all states unavailable."""
hass.states.async_set("test.object", "on")
tmpl_str = "{{ states | selectattr('state', 'in', ['unavailable', 'unknown', 'none']) | list | count }}"
info = render_to_info(hass, tmpl_str)
assert info.all_s... | [
"def",
"test_iterating_all_states_unavailable",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"test.object\"",
",",
"\"on\"",
")",
"tmpl_str",
"=",
"\"{{ states | selectattr('state', 'in', ['unavailable', 'unknown', 'none']) | list | count }}\"",
"info"... | [
159,
0
] | [
174,
61
] | python | en | ['en', 'en', 'it'] | True |
test_iterating_domain_states | (hass) | Test iterating domain states. | Test iterating domain states. | def test_iterating_domain_states(hass):
"""Test iterating domain states."""
tmpl_str = "{% for state in states.sensor %}{{ state.state }}{% endfor %}"
info = render_to_info(hass, tmpl_str)
assert_result_info(info, "", domains=["sensor"])
assert info.rate_limit == template.DOMAIN_STATES_RATE_LIMIT
... | [
"def",
"test_iterating_domain_states",
"(",
"hass",
")",
":",
"tmpl_str",
"=",
"\"{% for state in states.sensor %}{{ state.state }}{% endfor %}\"",
"info",
"=",
"render_to_info",
"(",
"hass",
",",
"tmpl_str",
")",
"assert_result_info",
"(",
"info",
",",
"\"\"",
",",
"do... | [
177,
0
] | [
195,
5
] | python | en | ['de', 'en', 'en'] | True |
test_float | (hass) | Test float. | Test float. | def test_float(hass):
"""Test float."""
hass.states.async_set("sensor.temperature", "12")
assert (
template.Template(
"{{ float(states.sensor.temperature.state) }}", hass
).async_render()
== 12.0
)
assert (
template.Template(
"{{ float(states... | [
"def",
"test_float",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.temperature\"",
",",
"\"12\"",
")",
"assert",
"(",
"template",
".",
"Template",
"(",
"\"{{ float(states.sensor.temperature.state) }}\"",
",",
"hass",
")",
".",
"a... | [
198,
0
] | [
219,
5
] | python | en | ['en', 'da', 'en'] | False |
test_rounding_value | (hass) | Test rounding value. | Test rounding value. | def test_rounding_value(hass):
"""Test rounding value."""
hass.states.async_set("sensor.temperature", 12.78)
assert (
template.Template(
"{{ states.sensor.temperature.state | round(1) }}", hass
).async_render()
== 12.8
)
assert (
template.Template(
... | [
"def",
"test_rounding_value",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.temperature\"",
",",
"12.78",
")",
"assert",
"(",
"template",
".",
"Template",
"(",
"\"{{ states.sensor.temperature.state | round(1) }}\"",
",",
"hass",
")",... | [
222,
0
] | [
259,
5
] | python | en | ['nl', 'no', 'en'] | False |
test_rounding_value_get_original_value_on_error | (hass) | Test rounding value get original value on error. | Test rounding value get original value on error. | def test_rounding_value_get_original_value_on_error(hass):
"""Test rounding value get original value on error."""
assert template.Template("{{ None | round }}", hass).async_render() is None
assert (
template.Template('{{ "no_number" | round }}', hass).async_render()
== "no_number"
) | [
"def",
"test_rounding_value_get_original_value_on_error",
"(",
"hass",
")",
":",
"assert",
"template",
".",
"Template",
"(",
"\"{{ None | round }}\"",
",",
"hass",
")",
".",
"async_render",
"(",
")",
"is",
"None",
"assert",
"(",
"template",
".",
"Template",
"(",
... | [
262,
0
] | [
269,
5
] | python | en | ['nl', 'la', 'en'] | False |
test_multiply | (hass) | Test multiply. | Test multiply. | def test_multiply(hass):
"""Test multiply."""
tests = {None: None, 10: 100, '"abcd"': "abcd"}
for inp, out in tests.items():
assert (
template.Template(
"{{ %s | multiply(10) | round }}" % inp, hass
).async_render()
== out
) | [
"def",
"test_multiply",
"(",
"hass",
")",
":",
"tests",
"=",
"{",
"None",
":",
"None",
",",
"10",
":",
"100",
",",
"'\"abcd\"'",
":",
"\"abcd\"",
"}",
"for",
"inp",
",",
"out",
"in",
"tests",
".",
"items",
"(",
")",
":",
"assert",
"(",
"template",
... | [
272,
0
] | [
282,
9
] | python | en | ['en', 'no', 'en'] | False |
test_logarithm | (hass) | Test logarithm. | Test logarithm. | def test_logarithm(hass):
"""Test logarithm."""
tests = [
(4, 2, 2.0),
(1000, 10, 3.0),
(math.e, "", 1.0),
('"invalid"', "_", "invalid"),
(10, '"invalid"', 10.0),
]
for value, base, expected in tests:
assert (
template.Template(
... | [
"def",
"test_logarithm",
"(",
"hass",
")",
":",
"tests",
"=",
"[",
"(",
"4",
",",
"2",
",",
"2.0",
")",
",",
"(",
"1000",
",",
"10",
",",
"3.0",
")",
",",
"(",
"math",
".",
"e",
",",
"\"\"",
",",
"1.0",
")",
",",
"(",
"'\"invalid\"'",
",",
... | [
285,
0
] | [
308,
9
] | python | en | ['en', 'fr', 'it'] | False |
test_cos | (hass) | Test cosine. | Test cosine. | def test_cos(hass):
"""Test cosine."""
tests = [
(0, 1.0),
(math.pi / 2, 0.0),
(math.pi, -1.0),
(math.pi * 1.5, -0.0),
(math.pi / 10, 0.951),
("'error'", "error"),
]
for value, expected in tests:
assert (
template.Template("{{ %s | cos... | [
"def",
"test_cos",
"(",
"hass",
")",
":",
"tests",
"=",
"[",
"(",
"0",
",",
"1.0",
")",
",",
"(",
"math",
".",
"pi",
"/",
"2",
",",
"0.0",
")",
",",
"(",
"math",
".",
"pi",
",",
"-",
"1.0",
")",
",",
"(",
"math",
".",
"pi",
"*",
"1.5",
... | [
329,
0
] | [
344,
9
] | python | en | ['en', 'la', 'it'] | False |
test_tan | (hass) | Test tangent. | Test tangent. | def test_tan(hass):
"""Test tangent."""
tests = [
(0, 0.0),
(math.pi, -0.0),
(math.pi / 180 * 45, 1.0),
(math.pi / 180 * 90, "1.633123935319537e+16"),
(math.pi / 180 * 135, -1.0),
("'error'", "error"),
]
for value, expected in tests:
assert (
... | [
"def",
"test_tan",
"(",
"hass",
")",
":",
"tests",
"=",
"[",
"(",
"0",
",",
"0.0",
")",
",",
"(",
"math",
".",
"pi",
",",
"-",
"0.0",
")",
",",
"(",
"math",
".",
"pi",
"/",
"180",
"*",
"45",
",",
"1.0",
")",
",",
"(",
"math",
".",
"pi",
... | [
347,
0
] | [
362,
9
] | python | ja | ['sv', 'ja', 'ur'] | False |
test_sqrt | (hass) | Test square root. | Test square root. | def test_sqrt(hass):
"""Test square root."""
tests = [
(0, 0.0),
(1, 1.0),
(2, 1.414),
(10, 3.162),
(100, 10.0),
("'error'", "error"),
]
for value, expected in tests:
assert (
template.Template("{{ %s | sqrt | round(3) }}" % value, has... | [
"def",
"test_sqrt",
"(",
"hass",
")",
":",
"tests",
"=",
"[",
"(",
"0",
",",
"0.0",
")",
",",
"(",
"1",
",",
"1.0",
")",
",",
"(",
"2",
",",
"1.414",
")",
",",
"(",
"10",
",",
"3.162",
")",
",",
"(",
"100",
",",
"10.0",
")",
",",
"(",
"... | [
365,
0
] | [
380,
9
] | python | en | ['en', 'en', 'en'] | True |
test_arc_sine | (hass) | Test arcus sine. | Test arcus sine. | def test_arc_sine(hass):
"""Test arcus sine."""
tests = [
(-2.0, -2.0), # value error
(-1.0, -1.571),
(-0.5, -0.524),
(0.0, 0.0),
(0.5, 0.524),
(1.0, 1.571),
(2.0, 2.0), # value error
('"error"', "error"),
]
for value, expected in tests:... | [
"def",
"test_arc_sine",
"(",
"hass",
")",
":",
"tests",
"=",
"[",
"(",
"-",
"2.0",
",",
"-",
"2.0",
")",
",",
"# value error",
"(",
"-",
"1.0",
",",
"-",
"1.571",
")",
",",
"(",
"-",
"0.5",
",",
"-",
"0.524",
")",
",",
"(",
"0.0",
",",
"0.0",... | [
383,
0
] | [
400,
9
] | python | en | ['en', 'la', 'it'] | False |
test_arc_cos | (hass) | Test arcus cosine. | Test arcus cosine. | def test_arc_cos(hass):
"""Test arcus cosine."""
tests = [
(-2.0, -2.0), # value error
(-1.0, 3.142),
(-0.5, 2.094),
(0.0, 1.571),
(0.5, 1.047),
(1.0, 0.0),
(2.0, 2.0), # value error
('"error"', "error"),
]
for value, expected in tests:
... | [
"def",
"test_arc_cos",
"(",
"hass",
")",
":",
"tests",
"=",
"[",
"(",
"-",
"2.0",
",",
"-",
"2.0",
")",
",",
"# value error",
"(",
"-",
"1.0",
",",
"3.142",
")",
",",
"(",
"-",
"0.5",
",",
"2.094",
")",
",",
"(",
"0.0",
",",
"1.571",
")",
","... | [
403,
0
] | [
420,
9
] | python | en | ['en', 'la', 'it'] | False |
test_arc_tan | (hass) | Test arcus tangent. | Test arcus tangent. | def test_arc_tan(hass):
"""Test arcus tangent."""
tests = [
(-10.0, -1.471),
(-2.0, -1.107),
(-1.0, -0.785),
(-0.5, -0.464),
(0.0, 0.0),
(0.5, 0.464),
(1.0, 0.785),
(2.0, 1.107),
(10.0, 1.471),
('"error"', "error"),
]
for v... | [
"def",
"test_arc_tan",
"(",
"hass",
")",
":",
"tests",
"=",
"[",
"(",
"-",
"10.0",
",",
"-",
"1.471",
")",
",",
"(",
"-",
"2.0",
",",
"-",
"1.107",
")",
",",
"(",
"-",
"1.0",
",",
"-",
"0.785",
")",
",",
"(",
"-",
"0.5",
",",
"-",
"0.464",
... | [
423,
0
] | [
442,
9
] | python | it | ['sv', 'la', 'it'] | False |
test_arc_tan2 | (hass) | Test two parameter version of arcus tangent. | Test two parameter version of arcus tangent. | def test_arc_tan2(hass):
"""Test two parameter version of arcus tangent."""
tests = [
(-10.0, -10.0, -2.356),
(-10.0, 0.0, -1.571),
(-10.0, 10.0, -0.785),
(0.0, -10.0, 3.142),
(0.0, 0.0, 0.0),
(0.0, 10.0, 0.0),
(10.0, -10.0, 2.356),
(10.0, 0.0, 1.5... | [
"def",
"test_arc_tan2",
"(",
"hass",
")",
":",
"tests",
"=",
"[",
"(",
"-",
"10.0",
",",
"-",
"10.0",
",",
"-",
"2.356",
")",
",",
"(",
"-",
"10.0",
",",
"0.0",
",",
"-",
"1.571",
")",
",",
"(",
"-",
"10.0",
",",
"10.0",
",",
"-",
"0.785",
... | [
445,
0
] | [
475,
9
] | python | en | ['en', 'en', 'en'] | True |
test_strptime | (hass) | Test the parse timestamp method. | Test the parse timestamp method. | def test_strptime(hass):
"""Test the parse timestamp method."""
tests = [
("2016-10-19 15:22:05.588122 UTC", "%Y-%m-%d %H:%M:%S.%f %Z", None),
("2016-10-19 15:22:05.588122+0100", "%Y-%m-%d %H:%M:%S.%f%z", None),
("2016-10-19 15:22:05.588122", "%Y-%m-%d %H:%M:%S.%f", None),
("2016... | [
"def",
"test_strptime",
"(",
"hass",
")",
":",
"tests",
"=",
"[",
"(",
"\"2016-10-19 15:22:05.588122 UTC\"",
",",
"\"%Y-%m-%d %H:%M:%S.%f %Z\"",
",",
"None",
")",
",",
"(",
"\"2016-10-19 15:22:05.588122+0100\"",
",",
"\"%Y-%m-%d %H:%M:%S.%f%z\"",
",",
"None",
")",
","... | [
478,
0
] | [
497,
71
] | python | en | ['en', 'en', 'en'] | True |
test_timestamp_custom | (hass) | Test the timestamps to custom filter. | Test the timestamps to custom filter. | def test_timestamp_custom(hass):
"""Test the timestamps to custom filter."""
now = dt_util.utcnow()
tests = [
(None, None, None, None),
(1469119144, None, True, "2016-07-21 16:39:04"),
(1469119144, "%Y", True, 2016),
(1469119144, "invalid", True, "invalid"),
(dt_util.... | [
"def",
"test_timestamp_custom",
"(",
"hass",
")",
":",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"tests",
"=",
"[",
"(",
"None",
",",
"None",
",",
"None",
",",
"None",
")",
",",
"(",
"1469119144",
",",
"None",
",",
"True",
",",
"\"2016-07-21 16... | [
500,
0
] | [
519,
88
] | python | en | ['en', 'en', 'en'] | True |
test_timestamp_local | (hass) | Test the timestamps to local filter. | Test the timestamps to local filter. | def test_timestamp_local(hass):
"""Test the timestamps to local filter."""
tests = {None: None, 1469119144: "2016-07-21 16:39:04"}
for inp, out in tests.items():
assert (
template.Template("{{ %s | timestamp_local }}" % inp, hass).async_render()
== out
) | [
"def",
"test_timestamp_local",
"(",
"hass",
")",
":",
"tests",
"=",
"{",
"None",
":",
"None",
",",
"1469119144",
":",
"\"2016-07-21 16:39:04\"",
"}",
"for",
"inp",
",",
"out",
"in",
"tests",
".",
"items",
"(",
")",
":",
"assert",
"(",
"template",
".",
... | [
522,
0
] | [
530,
9
] | python | en | ['en', 'en', 'en'] | True |
test_as_datetime | (hass, input) | Test converting a timestamp string to a date object. | Test converting a timestamp string to a date object. | def test_as_datetime(hass, input):
"""Test converting a timestamp string to a date object."""
expected = dt_util.parse_datetime(input)
if expected is not None:
expected = str(expected)
assert (
template.Template(f"{{{{ as_datetime('{input}') }}}}", hass).async_render()
== expect... | [
"def",
"test_as_datetime",
"(",
"hass",
",",
"input",
")",
":",
"expected",
"=",
"dt_util",
".",
"parse_datetime",
"(",
"input",
")",
"if",
"expected",
"is",
"not",
"None",
":",
"expected",
"=",
"str",
"(",
"expected",
")",
"assert",
"(",
"template",
"."... | [
544,
0
] | [
557,
5
] | python | en | ['en', 'en', 'en'] | True |
test_as_local | (hass) | Test converting time to local. | Test converting time to local. | def test_as_local(hass):
"""Test converting time to local."""
hass.states.async_set("test.object", "available")
last_updated = hass.states.get("test.object").last_updated
assert template.Template(
"{{ as_local(states.test.object.last_updated) }}", hass
).async_render() == str(dt_util.as_loc... | [
"def",
"test_as_local",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"test.object\"",
",",
"\"available\"",
")",
"last_updated",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"test.object\"",
")",
".",
"last_updated",
"assert",
"te... | [
560,
0
] | [
570,
59
] | python | en | ['en', 'en', 'en'] | True |
test_to_json | (hass) | Test the object to JSON string filter. | Test the object to JSON string filter. | def test_to_json(hass):
"""Test the object to JSON string filter."""
# Note that we're not testing the actual json.loads and json.dumps methods,
# only the filters, so we don't need to be exhaustive with our sample JSON.
expected_result = {"Foo": "Bar"}
actual_result = template.Template(
"{... | [
"def",
"test_to_json",
"(",
"hass",
")",
":",
"# Note that we're not testing the actual json.loads and json.dumps methods,",
"# only the filters, so we don't need to be exhaustive with our sample JSON.",
"expected_result",
"=",
"{",
"\"Foo\"",
":",
"\"Bar\"",
"}",
"actual_result",
"=... | [
573,
0
] | [
582,
43
] | python | en | ['en', 'en', 'en'] | True |
test_from_json | (hass) | Test the JSON string to object filter. | Test the JSON string to object filter. | def test_from_json(hass):
"""Test the JSON string to object filter."""
# Note that we're not testing the actual json.loads and json.dumps methods,
# only the filters, so we don't need to be exhaustive with our sample JSON.
expected_result = "Bar"
actual_result = template.Template(
'{{ (\'{"... | [
"def",
"test_from_json",
"(",
"hass",
")",
":",
"# Note that we're not testing the actual json.loads and json.dumps methods,",
"# only the filters, so we don't need to be exhaustive with our sample JSON.",
"expected_result",
"=",
"\"Bar\"",
"actual_result",
"=",
"template",
".",
"Templ... | [
585,
0
] | [
594,
43
] | python | en | ['en', 'en', 'en'] | True |
test_min | (hass) | Test the min filter. | Test the min filter. | def test_min(hass):
"""Test the min filter."""
assert template.Template("{{ [1, 2, 3] | min }}", hass).async_render() == 1
assert template.Template("{{ min([1, 2, 3]) }}", hass).async_render() == 1
assert template.Template("{{ min(1, 2, 3) }}", hass).async_render() == 1 | [
"def",
"test_min",
"(",
"hass",
")",
":",
"assert",
"template",
".",
"Template",
"(",
"\"{{ [1, 2, 3] | min }}\"",
",",
"hass",
")",
".",
"async_render",
"(",
")",
"==",
"1",
"assert",
"template",
".",
"Template",
"(",
"\"{{ min([1, 2, 3]) }}\"",
",",
"hass",
... | [
597,
0
] | [
601,
76
] | python | en | ['en', 'en', 'en'] | True |
test_max | (hass) | Test the max filter. | Test the max filter. | def test_max(hass):
"""Test the max filter."""
assert template.Template("{{ [1, 2, 3] | max }}", hass).async_render() == 3
assert template.Template("{{ max([1, 2, 3]) }}", hass).async_render() == 3
assert template.Template("{{ max(1, 2, 3) }}", hass).async_render() == 3 | [
"def",
"test_max",
"(",
"hass",
")",
":",
"assert",
"template",
".",
"Template",
"(",
"\"{{ [1, 2, 3] | max }}\"",
",",
"hass",
")",
".",
"async_render",
"(",
")",
"==",
"3",
"assert",
"template",
".",
"Template",
"(",
"\"{{ max([1, 2, 3]) }}\"",
",",
"hass",
... | [
604,
0
] | [
608,
76
] | python | en | ['en', 'en', 'en'] | True |
test_ord | (hass) | Test the ord filter. | Test the ord filter. | def test_ord(hass):
"""Test the ord filter."""
assert template.Template('{{ "d" | ord }}', hass).async_render() == 100 | [
"def",
"test_ord",
"(",
"hass",
")",
":",
"assert",
"template",
".",
"Template",
"(",
"'{{ \"d\" | ord }}'",
",",
"hass",
")",
".",
"async_render",
"(",
")",
"==",
"100"
] | [
611,
0
] | [
613,
75
] | python | en | ['en', 'en', 'en'] | True |
test_base64_encode | (hass) | Test the base64_encode filter. | Test the base64_encode filter. | def test_base64_encode(hass):
"""Test the base64_encode filter."""
assert (
template.Template('{{ "homeassistant" | base64_encode }}', hass).async_render()
== "aG9tZWFzc2lzdGFudA=="
) | [
"def",
"test_base64_encode",
"(",
"hass",
")",
":",
"assert",
"(",
"template",
".",
"Template",
"(",
"'{{ \"homeassistant\" | base64_encode }}'",
",",
"hass",
")",
".",
"async_render",
"(",
")",
"==",
"\"aG9tZWFzc2lzdGFudA==\"",
")"
] | [
616,
0
] | [
621,
5
] | python | en | ['en', 'da', 'en'] | True |
test_base64_decode | (hass) | Test the base64_decode filter. | Test the base64_decode filter. | def test_base64_decode(hass):
"""Test the base64_decode filter."""
assert (
template.Template(
'{{ "aG9tZWFzc2lzdGFudA==" | base64_decode }}', hass
).async_render()
== "homeassistant"
) | [
"def",
"test_base64_decode",
"(",
"hass",
")",
":",
"assert",
"(",
"template",
".",
"Template",
"(",
"'{{ \"aG9tZWFzc2lzdGFudA==\" | base64_decode }}'",
",",
"hass",
")",
".",
"async_render",
"(",
")",
"==",
"\"homeassistant\"",
")"
] | [
624,
0
] | [
631,
5
] | python | en | ['en', 'en', 'en'] | True |
test_ordinal | (hass) | Test the ordinal filter. | Test the ordinal filter. | def test_ordinal(hass):
"""Test the ordinal filter."""
tests = [
(1, "1st"),
(2, "2nd"),
(3, "3rd"),
(4, "4th"),
(5, "5th"),
(12, "12th"),
(100, "100th"),
(101, "101st"),
]
for value, expected in tests:
assert (
templat... | [
"def",
"test_ordinal",
"(",
"hass",
")",
":",
"tests",
"=",
"[",
"(",
"1",
",",
"\"1st\"",
")",
",",
"(",
"2",
",",
"\"2nd\"",
")",
",",
"(",
"3",
",",
"\"3rd\"",
")",
",",
"(",
"4",
",",
"\"4th\"",
")",
",",
"(",
"5",
",",
"\"5th\"",
")",
... | [
634,
0
] | [
651,
9
] | python | en | ['en', 'su', 'en'] | True |
test_timestamp_utc | (hass) | Test the timestamps to local filter. | Test the timestamps to local filter. | def test_timestamp_utc(hass):
"""Test the timestamps to local filter."""
now = dt_util.utcnow()
tests = {
None: None,
1469119144: "2016-07-21 16:39:04",
dt_util.as_timestamp(now): now.strftime("%Y-%m-%d %H:%M:%S"),
}
for inp, out in tests.items():
assert (
... | [
"def",
"test_timestamp_utc",
"(",
"hass",
")",
":",
"now",
"=",
"dt_util",
".",
"utcnow",
"(",
")",
"tests",
"=",
"{",
"None",
":",
"None",
",",
"1469119144",
":",
"\"2016-07-21 16:39:04\"",
",",
"dt_util",
".",
"as_timestamp",
"(",
"now",
")",
":",
"now... | [
654,
0
] | [
667,
9
] | python | en | ['en', 'en', 'en'] | True |
test_as_timestamp | (hass) | Test the as_timestamp function. | Test the as_timestamp function. | def test_as_timestamp(hass):
"""Test the as_timestamp function."""
assert (
template.Template('{{ as_timestamp("invalid") }}', hass).async_render() is None
)
hass.mock = None
assert (
template.Template("{{ as_timestamp(states.mock) }}", hass).async_render()
is None
)
... | [
"def",
"test_as_timestamp",
"(",
"hass",
")",
":",
"assert",
"(",
"template",
".",
"Template",
"(",
"'{{ as_timestamp(\"invalid\") }}'",
",",
"hass",
")",
".",
"async_render",
"(",
")",
"is",
"None",
")",
"hass",
".",
"mock",
"=",
"None",
"assert",
"(",
"t... | [
670,
0
] | [
685,
70
] | python | en | ['en', 'en', 'en'] | True |
test_random_every_time | (test_choice, hass) | Ensure the random filter runs every time, not just once. | Ensure the random filter runs every time, not just once. | def test_random_every_time(test_choice, hass):
"""Ensure the random filter runs every time, not just once."""
tpl = template.Template("{{ [1,2] | random }}", hass)
test_choice.return_value = "foo"
assert tpl.async_render() == "foo"
test_choice.return_value = "bar"
assert tpl.async_render() == "b... | [
"def",
"test_random_every_time",
"(",
"test_choice",
",",
"hass",
")",
":",
"tpl",
"=",
"template",
".",
"Template",
"(",
"\"{{ [1,2] | random }}\"",
",",
"hass",
")",
"test_choice",
".",
"return_value",
"=",
"\"foo\"",
"assert",
"tpl",
".",
"async_render",
"(",... | [
689,
0
] | [
695,
38
] | python | en | ['en', 'en', 'en'] | True |
test_passing_vars_as_keywords | (hass) | Test passing variables as keywords. | Test passing variables as keywords. | def test_passing_vars_as_keywords(hass):
"""Test passing variables as keywords."""
assert template.Template("{{ hello }}", hass).async_render(hello=127) == 127 | [
"def",
"test_passing_vars_as_keywords",
"(",
"hass",
")",
":",
"assert",
"template",
".",
"Template",
"(",
"\"{{ hello }}\"",
",",
"hass",
")",
".",
"async_render",
"(",
"hello",
"=",
"127",
")",
"==",
"127"
] | [
698,
0
] | [
700,
80
] | python | en | ['en', 'en', 'en'] | True |
test_passing_vars_as_vars | (hass) | Test passing variables as variables. | Test passing variables as variables. | def test_passing_vars_as_vars(hass):
"""Test passing variables as variables."""
assert template.Template("{{ hello }}", hass).async_render({"hello": 127}) == 127 | [
"def",
"test_passing_vars_as_vars",
"(",
"hass",
")",
":",
"assert",
"template",
".",
"Template",
"(",
"\"{{ hello }}\"",
",",
"hass",
")",
".",
"async_render",
"(",
"{",
"\"hello\"",
":",
"127",
"}",
")",
"==",
"127"
] | [
703,
0
] | [
705,
85
] | python | en | ['en', 'en', 'en'] | True |
test_passing_vars_as_list | (hass) | Test passing variables as list. | Test passing variables as list. | def test_passing_vars_as_list(hass):
"""Test passing variables as list."""
assert template.render_complex(
template.Template("{{ hello }}", hass), {"hello": ["foo", "bar"]}
) == ["foo", "bar"] | [
"def",
"test_passing_vars_as_list",
"(",
"hass",
")",
":",
"assert",
"template",
".",
"render_complex",
"(",
"template",
".",
"Template",
"(",
"\"{{ hello }}\"",
",",
"hass",
")",
",",
"{",
"\"hello\"",
":",
"[",
"\"foo\"",
",",
"\"bar\"",
"]",
"}",
")",
"... | [
708,
0
] | [
712,
23
] | python | en | ['en', 'en', 'en'] | True |
test_passing_vars_as_list_element | (hass) | Test passing variables as list. | Test passing variables as list. | def test_passing_vars_as_list_element(hass):
"""Test passing variables as list."""
assert (
template.render_complex(
template.Template("{{ hello[1] }}", hass), {"hello": ["foo", "bar"]}
)
== "bar"
) | [
"def",
"test_passing_vars_as_list_element",
"(",
"hass",
")",
":",
"assert",
"(",
"template",
".",
"render_complex",
"(",
"template",
".",
"Template",
"(",
"\"{{ hello[1] }}\"",
",",
"hass",
")",
",",
"{",
"\"hello\"",
":",
"[",
"\"foo\"",
",",
"\"bar\"",
"]",... | [
715,
0
] | [
722,
5
] | python | en | ['en', 'en', 'en'] | True |
test_passing_vars_as_dict_element | (hass) | Test passing variables as list. | Test passing variables as list. | def test_passing_vars_as_dict_element(hass):
"""Test passing variables as list."""
assert (
template.render_complex(
template.Template("{{ hello.foo }}", hass), {"hello": {"foo": "bar"}}
)
== "bar"
) | [
"def",
"test_passing_vars_as_dict_element",
"(",
"hass",
")",
":",
"assert",
"(",
"template",
".",
"render_complex",
"(",
"template",
".",
"Template",
"(",
"\"{{ hello.foo }}\"",
",",
"hass",
")",
",",
"{",
"\"hello\"",
":",
"{",
"\"foo\"",
":",
"\"bar\"",
"}"... | [
725,
0
] | [
732,
5
] | python | en | ['en', 'en', 'en'] | True |
test_passing_vars_as_dict | (hass) | Test passing variables as list. | Test passing variables as list. | def test_passing_vars_as_dict(hass):
"""Test passing variables as list."""
assert template.render_complex(
template.Template("{{ hello }}", hass), {"hello": {"foo": "bar"}}
) == {"foo": "bar"} | [
"def",
"test_passing_vars_as_dict",
"(",
"hass",
")",
":",
"assert",
"template",
".",
"render_complex",
"(",
"template",
".",
"Template",
"(",
"\"{{ hello }}\"",
",",
"hass",
")",
",",
"{",
"\"hello\"",
":",
"{",
"\"foo\"",
":",
"\"bar\"",
"}",
"}",
")",
"... | [
735,
0
] | [
739,
23
] | 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.