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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
DeconzCover.async_close_cover | (self, **kwargs) | Close cover. | Close cover. | async def async_close_cover(self, **kwargs):
"""Close cover."""
data = {ATTR_POSITION: 0}
await self.async_set_cover_position(**data) | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"ATTR_POSITION",
":",
"0",
"}",
"await",
"self",
".",
"async_set_cover_position",
"(",
"*",
"*",
"data",
")"
] | [
104,
4
] | [
107,
51
] | python | en | ['en', 'la', 'en'] | False |
DeconzCover.async_stop_cover | (self, **kwargs) | Stop cover. | Stop cover. | async def async_stop_cover(self, **kwargs):
"""Stop cover."""
data = {"bri_inc": 0}
await self._device.async_set_state(data) | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"bri_inc\"",
":",
"0",
"}",
"await",
"self",
".",
"_device",
".",
"async_set_state",
"(",
"data",
")"
] | [
109,
4
] | [
112,
48
] | python | en | ['en', 'en', 'en'] | False |
mock_send_magic_packet | () | Mock magic packet. | Mock magic packet. | def mock_send_magic_packet():
"""Mock magic packet."""
with patch("wakeonlan.send_magic_packet") as mock_send:
yield mock_send | [
"def",
"mock_send_magic_packet",
"(",
")",
":",
"with",
"patch",
"(",
"\"wakeonlan.send_magic_packet\"",
")",
"as",
"mock_send",
":",
"yield",
"mock_send"
] | [
21,
0
] | [
24,
23
] | python | en | ['en', 'bg', 'en'] | True |
test_valid_hostname | (hass) | Test with valid hostname. | Test with valid hostname. | async def test_valid_hostname(hass):
"""Test with valid hostname."""
assert await async_setup_component(
hass,
switch.DOMAIN,
{
"switch": {
"platform": "wake_on_lan",
"mac": "00-01-02-03-04-05",
"host": "validhostname",
... | [
"async",
"def",
"test_valid_hostname",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"switch",
".",
"DOMAIN",
",",
"{",
"\"switch\"",
":",
"{",
"\"platform\"",
":",
"\"wake_on_lan\"",
",",
"\"mac\"",
":",
"\"00-01-02-03-04-... | [
27,
0
] | [
65,
38
] | python | en | ['en', 'da', 'en'] | True |
test_valid_hostname_windows | (hass) | Test with valid hostname on windows. | Test with valid hostname on windows. | async def test_valid_hostname_windows(hass):
"""Test with valid hostname on windows."""
assert await async_setup_component(
hass,
switch.DOMAIN,
{
"switch": {
"platform": "wake_on_lan",
"mac": "00-01-02-03-04-05",
"host": "valid... | [
"async",
"def",
"test_valid_hostname_windows",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"switch",
".",
"DOMAIN",
",",
"{",
"\"switch\"",
":",
"{",
"\"platform\"",
":",
"\"wake_on_lan\"",
",",
"\"mac\"",
":",
"\"00-01-0... | [
68,
0
] | [
97,
34
] | python | en | ['en', 'et', 'en'] | True |
test_broadcast_config_ip_and_port | (hass, mock_send_magic_packet) | Test with broadcast address and broadcast port config. | Test with broadcast address and broadcast port config. | async def test_broadcast_config_ip_and_port(hass, mock_send_magic_packet):
"""Test with broadcast address and broadcast port config."""
mac = "00-01-02-03-04-05"
broadcast_address = "255.255.255.255"
port = 999
assert await async_setup_component(
hass,
switch.DOMAIN,
{
... | [
"async",
"def",
"test_broadcast_config_ip_and_port",
"(",
"hass",
",",
"mock_send_magic_packet",
")",
":",
"mac",
"=",
"\"00-01-02-03-04-05\"",
"broadcast_address",
"=",
"\"255.255.255.255\"",
"port",
"=",
"999",
"assert",
"await",
"async_setup_component",
"(",
"hass",
... | [
100,
0
] | [
134,
9
] | python | en | ['en', 'en', 'en'] | True |
test_broadcast_config_ip | (hass, mock_send_magic_packet) | Test with only broadcast address. | Test with only broadcast address. | async def test_broadcast_config_ip(hass, mock_send_magic_packet):
"""Test with only broadcast address."""
mac = "00-01-02-03-04-05"
broadcast_address = "255.255.255.255"
assert await async_setup_component(
hass,
switch.DOMAIN,
{
"switch": {
"platform... | [
"async",
"def",
"test_broadcast_config_ip",
"(",
"hass",
",",
"mock_send_magic_packet",
")",
":",
"mac",
"=",
"\"00-01-02-03-04-05\"",
"broadcast_address",
"=",
"\"255.255.255.255\"",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"switch",
".",
"DOMAIN",... | [
137,
0
] | [
168,
84
] | python | en | ['en', 'en', 'en'] | True |
test_broadcast_config_port | (hass, mock_send_magic_packet) | Test with only broadcast port config. | Test with only broadcast port config. | async def test_broadcast_config_port(hass, mock_send_magic_packet):
"""Test with only broadcast port config."""
mac = "00-01-02-03-04-05"
port = 999
assert await async_setup_component(
hass,
switch.DOMAIN,
{"switch": {"platform": "wake_on_lan", "mac": mac, "broadcast_port": por... | [
"async",
"def",
"test_broadcast_config_port",
"(",
"hass",
",",
"mock_send_magic_packet",
")",
":",
"mac",
"=",
"\"00-01-02-03-04-05\"",
"port",
"=",
"999",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"switch",
".",
"DOMAIN",
",",
"{",
"\"switch\... | [
171,
0
] | [
196,
65
] | python | en | ['en', 'en', 'en'] | True |
test_off_script | (hass) | Test with turn off script. | Test with turn off script. | async def test_off_script(hass):
"""Test with turn off script."""
assert await async_setup_component(
hass,
switch.DOMAIN,
{
"switch": {
"platform": "wake_on_lan",
"mac": "00-01-02-03-04-05",
"host": "validhostname",
... | [
"async",
"def",
"test_off_script",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"switch",
".",
"DOMAIN",
",",
"{",
"\"switch\"",
":",
"{",
"\"platform\"",
":",
"\"wake_on_lan\"",
",",
"\"mac\"",
":",
"\"00-01-02-03-04-05\"... | [
199,
0
] | [
244,
30
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_hostname_windows | (hass) | Test with invalid hostname on windows. | Test with invalid hostname on windows. | async def test_invalid_hostname_windows(hass):
"""Test with invalid hostname on windows."""
assert await async_setup_component(
hass,
switch.DOMAIN,
{
"switch": {
"platform": "wake_on_lan",
"mac": "00-01-02-03-04-05",
"host": "... | [
"async",
"def",
"test_invalid_hostname_windows",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"switch",
".",
"DOMAIN",
",",
"{",
"\"switch\"",
":",
"{",
"\"platform\"",
":",
"\"wake_on_lan\"",
",",
"\"mac\"",
":",
"\"00-01... | [
247,
0
] | [
276,
39
] | python | en | ['en', 'en', 'en'] | True |
lookup_movie | (library_section, **kwargs) | Find a specific movie and return a Plex media object. | Find a specific movie and return a Plex media object. | def lookup_movie(library_section, **kwargs):
"""Find a specific movie and return a Plex media object."""
try:
title = kwargs["title"]
except KeyError:
_LOGGER.error("Must specify 'title' for this search")
return None
try:
movies = library_section.search(**kwargs, libtype... | [
"def",
"lookup_movie",
"(",
"library_section",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"title",
"=",
"kwargs",
"[",
"\"title\"",
"]",
"except",
"KeyError",
":",
"_LOGGER",
".",
"error",
"(",
"\"Must specify 'title' for this search\"",
")",
"return",
"No... | [
10,
0
] | [
35,
20
] | python | en | ['en', 'en', 'en'] | True |
lookup_tv | (library_section, **kwargs) | Find TV media and return a Plex media object. | Find TV media and return a Plex media object. | def lookup_tv(library_section, **kwargs):
"""Find TV media and return a Plex media object."""
season_number = kwargs.get("season_number")
episode_number = kwargs.get("episode_number")
try:
show_name = kwargs["show_name"]
show = library_section.get(show_name)
except KeyError:
... | [
"def",
"lookup_tv",
"(",
"library_section",
",",
"*",
"*",
"kwargs",
")",
":",
"season_number",
"=",
"kwargs",
".",
"get",
"(",
"\"season_number\"",
")",
"episode_number",
"=",
"kwargs",
".",
"get",
"(",
"\"episode_number\"",
")",
"try",
":",
"show_name",
"=... | [
38,
0
] | [
67,
73
] | python | en | ['en', 'mt', 'en'] | True |
lookup_music | (library_section, **kwargs) | Search for music and return a Plex media object. | Search for music and return a Plex media object. | def lookup_music(library_section, **kwargs):
"""Search for music and return a Plex media object."""
album_name = kwargs.get("album_name")
track_name = kwargs.get("track_name")
track_number = kwargs.get("track_number")
try:
artist_name = kwargs["artist_name"]
artist = library_section... | [
"def",
"lookup_music",
"(",
"library_section",
",",
"*",
"*",
"kwargs",
")",
":",
"album_name",
"=",
"kwargs",
".",
"get",
"(",
"\"album_name\"",
")",
"track_name",
"=",
"kwargs",
".",
"get",
"(",
"\"track_name\"",
")",
"track_number",
"=",
"kwargs",
".",
... | [
70,
0
] | [
115,
17
] | python | en | ['en', 'en', 'en'] | True |
get_device | (hass, host, port, username, password) | Get ONVIFCamera instance. | Get ONVIFCamera instance. | def get_device(hass, host, port, username, password) -> ONVIFCamera:
"""Get ONVIFCamera instance."""
return ONVIFCamera(
host,
port,
username,
password,
f"{os.path.dirname(onvif.__file__)}/wsdl/",
no_cache=True,
) | [
"def",
"get_device",
"(",
"hass",
",",
"host",
",",
"port",
",",
"username",
",",
"password",
")",
"->",
"ONVIFCamera",
":",
"return",
"ONVIFCamera",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"f\"{os.path.dirname(onvif.__file__)}/wsdl/\"",... | [
442,
0
] | [
451,
5
] | python | de | ['es', 'de', 'en'] | False |
ONVIFDevice.__init__ | (self, hass: HomeAssistant, config_entry: ConfigEntry = None) | Initialize the device. | Initialize the device. | def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry = None):
"""Initialize the device."""
self.hass: HomeAssistant = hass
self.config_entry: ConfigEntry = config_entry
self.available: bool = True
self.device: ONVIFCamera = None
self.events: EventManager = N... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"config_entry",
":",
"ConfigEntry",
"=",
"None",
")",
":",
"self",
".",
"hass",
":",
"HomeAssistant",
"=",
"hass",
"self",
".",
"config_entry",
":",
"ConfigEntry",
"=",
"config_entry",
... | [
40,
4
] | [
54,
38
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.name | (self) | Return the name of this device. | Return the name of this device. | def name(self) -> str:
"""Return the name of this device."""
return self.config_entry.data[CONF_NAME] | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_NAME",
"]"
] | [
57,
4
] | [
59,
48
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.host | (self) | Return the host of this device. | Return the host of this device. | def host(self) -> str:
"""Return the host of this device."""
return self.config_entry.data[CONF_HOST] | [
"def",
"host",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_HOST",
"]"
] | [
62,
4
] | [
64,
48
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.port | (self) | Return the port of this device. | Return the port of this device. | def port(self) -> int:
"""Return the port of this device."""
return self.config_entry.data[CONF_PORT] | [
"def",
"port",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_PORT",
"]"
] | [
67,
4
] | [
69,
48
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.username | (self) | Return the username of this device. | Return the username of this device. | def username(self) -> int:
"""Return the username of this device."""
return self.config_entry.data[CONF_USERNAME] | [
"def",
"username",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_USERNAME",
"]"
] | [
72,
4
] | [
74,
52
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.password | (self) | Return the password of this device. | Return the password of this device. | def password(self) -> int:
"""Return the password of this device."""
return self.config_entry.data[CONF_PASSWORD] | [
"def",
"password",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_PASSWORD",
"]"
] | [
77,
4
] | [
79,
52
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.async_setup | (self) | Set up the device. | Set up the device. | async def async_setup(self) -> bool:
"""Set up the device."""
self.device = get_device(
self.hass,
host=self.config_entry.data[CONF_HOST],
port=self.config_entry.data[CONF_PORT],
username=self.config_entry.data[CONF_USERNAME],
password=self.con... | [
"async",
"def",
"async_setup",
"(",
"self",
")",
"->",
"bool",
":",
"self",
".",
"device",
"=",
"get_device",
"(",
"self",
".",
"hass",
",",
"host",
"=",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_HOST",
"]",
",",
"port",
"=",
"self",
".",
... | [
81,
4
] | [
135,
19
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.async_stop | (self, event=None) | Shut it all down. | Shut it all down. | async def async_stop(self, event=None):
"""Shut it all down."""
if self.events:
await self.events.async_stop()
await self.device.close() | [
"async",
"def",
"async_stop",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"if",
"self",
".",
"events",
":",
"await",
"self",
".",
"events",
".",
"async_stop",
"(",
")",
"await",
"self",
".",
"device",
".",
"close",
"(",
")"
] | [
137,
4
] | [
141,
33
] | python | en | ['en', 'mt', 'en'] | True |
ONVIFDevice.async_check_date_and_time | (self) | Warns if device and system date not synced. | Warns if device and system date not synced. | async def async_check_date_and_time(self) -> None:
"""Warns if device and system date not synced."""
LOGGER.debug("Setting up the ONVIF device management service")
device_mgmt = self.device.create_devicemgmt_service()
LOGGER.debug("Retrieving current device date/time")
try:
... | [
"async",
"def",
"async_check_date_and_time",
"(",
"self",
")",
"->",
"None",
":",
"LOGGER",
".",
"debug",
"(",
"\"Setting up the ONVIF device management service\"",
")",
"device_mgmt",
"=",
"self",
".",
"device",
".",
"create_devicemgmt_service",
"(",
")",
"LOGGER",
... | [
143,
4
] | [
206,
13
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.async_get_device_info | (self) | Obtain information about this device. | Obtain information about this device. | async def async_get_device_info(self) -> DeviceInfo:
"""Obtain information about this device."""
device_mgmt = self.device.create_devicemgmt_service()
device_info = await device_mgmt.GetDeviceInformation()
# Grab the last MAC address for backwards compatibility
mac = None
... | [
"async",
"def",
"async_get_device_info",
"(",
"self",
")",
"->",
"DeviceInfo",
":",
"device_mgmt",
"=",
"self",
".",
"device",
".",
"create_devicemgmt_service",
"(",
")",
"device_info",
"=",
"await",
"device_mgmt",
".",
"GetDeviceInformation",
"(",
")",
"# Grab th... | [
208,
4
] | [
236,
9
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.async_get_capabilities | (self) | Obtain information about the available services on the device. | Obtain information about the available services on the device. | async def async_get_capabilities(self):
"""Obtain information about the available services on the device."""
snapshot = False
try:
media_service = self.device.create_media_service()
media_capabilities = await media_service.GetServiceCapabilities()
snapshot = m... | [
"async",
"def",
"async_get_capabilities",
"(",
"self",
")",
":",
"snapshot",
"=",
"False",
"try",
":",
"media_service",
"=",
"self",
".",
"device",
".",
"create_media_service",
"(",
")",
"media_capabilities",
"=",
"await",
"media_service",
".",
"GetServiceCapabili... | [
238,
4
] | [
261,
53
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.async_get_profiles | (self) | Obtain media profiles for this device. | Obtain media profiles for this device. | async def async_get_profiles(self) -> List[Profile]:
"""Obtain media profiles for this device."""
media_service = self.device.create_media_service()
result = await media_service.GetProfiles()
profiles = []
if not isinstance(result, list):
return profiles
for... | [
"async",
"def",
"async_get_profiles",
"(",
"self",
")",
"->",
"List",
"[",
"Profile",
"]",
":",
"media_service",
"=",
"self",
".",
"device",
".",
"create_media_service",
"(",
")",
"result",
"=",
"await",
"media_service",
".",
"GetProfiles",
"(",
")",
"profil... | [
263,
4
] | [
314,
23
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.async_get_stream_uri | (self, profile: Profile) | Get the stream URI for a specified profile. | Get the stream URI for a specified profile. | async def async_get_stream_uri(self, profile: Profile) -> str:
"""Get the stream URI for a specified profile."""
media_service = self.device.create_media_service()
req = media_service.create_type("GetStreamUri")
req.ProfileToken = profile.token
req.StreamSetup = {
"St... | [
"async",
"def",
"async_get_stream_uri",
"(",
"self",
",",
"profile",
":",
"Profile",
")",
"->",
"str",
":",
"media_service",
"=",
"self",
".",
"device",
".",
"create_media_service",
"(",
")",
"req",
"=",
"media_service",
".",
"create_type",
"(",
"\"GetStreamUr... | [
316,
4
] | [
326,
25
] | python | en | ['en', 'en', 'en'] | True |
ONVIFDevice.async_perform_ptz | (
self,
profile: Profile,
distance,
speed,
move_mode,
continuous_duration,
preset,
pan=None,
tilt=None,
zoom=None,
) | Perform a PTZ action on the camera. | Perform a PTZ action on the camera. | async def async_perform_ptz(
self,
profile: Profile,
distance,
speed,
move_mode,
continuous_duration,
preset,
pan=None,
tilt=None,
zoom=None,
):
"""Perform a PTZ action on the camera."""
if not self.capabilities.ptz:
... | [
"async",
"def",
"async_perform_ptz",
"(",
"self",
",",
"profile",
":",
"Profile",
",",
"distance",
",",
"speed",
",",
"move_mode",
",",
"continuous_duration",
",",
"preset",
",",
"pan",
"=",
"None",
",",
"tilt",
"=",
"None",
",",
"zoom",
"=",
"None",
","... | [
328,
4
] | [
439,
75
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the platform. | Set up the platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the platform."""
hass.async_create_task(
hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_IMPORT},
data={
CONF_USERNAME: config[CONF... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",... | [
55,
0
] | [
67,
5
] | python | en | ['en', 'da', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up mysq covers. | Set up mysq covers. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up mysq covers."""
data = hass.data[DOMAIN][config_entry.entry_id]
myq = data[MYQ_GATEWAY]
coordinator = data[MYQ_COORDINATOR]
async_add_entities(
[MyQDevice(coordinator, device) for device in myq.covers.values()], ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"myq",
"=",
"data",
"[",
"MYQ_GATEWAY",
"]",
"coord... | [
70,
0
] | [
78,
5
] | python | en | ['en', 'bg', 'en'] | True |
MyQDevice.__init__ | (self, coordinator, device) | Initialize with API object, device id. | Initialize with API object, device id. | def __init__(self, coordinator, device):
"""Initialize with API object, device id."""
super().__init__(coordinator)
self._device = device
self._last_action_timestamp = 0
self._scheduled_transition_update = None | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_device",
"=",
"device",
"self",
".",
"_last_action_timestamp",
"=",
"0",
"self",
".",
"_scheduled_trans... | [
84,
4
] | [
89,
48
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.device_class | (self) | Define this cover as a garage door. | Define this cover as a garage door. | def device_class(self):
"""Define this cover as a garage door."""
device_type = self._device.device_json.get(MYQ_DEVICE_TYPE)
if device_type is not None and device_type == MYQ_DEVICE_TYPE_GATE:
return DEVICE_CLASS_GATE
return DEVICE_CLASS_GARAGE | [
"def",
"device_class",
"(",
"self",
")",
":",
"device_type",
"=",
"self",
".",
"_device",
".",
"device_json",
".",
"get",
"(",
"MYQ_DEVICE_TYPE",
")",
"if",
"device_type",
"is",
"not",
"None",
"and",
"device_type",
"==",
"MYQ_DEVICE_TYPE_GATE",
":",
"return",
... | [
92,
4
] | [
97,
34
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.name | (self) | Return the name of the garage door if any. | Return the name of the garage door if any. | def name(self):
"""Return the name of the garage door if any."""
return self._device.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"name"
] | [
100,
4
] | [
102,
32
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.available | (self) | Return if the device is online. | Return if the device is online. | def available(self):
"""Return if the device is online."""
if not self.coordinator.last_update_success:
return False
# Not all devices report online so assume True if its missing
return self._device.device_json[MYQ_DEVICE_STATE].get(
MYQ_DEVICE_STATE_ONLINE, True... | [
"def",
"available",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"coordinator",
".",
"last_update_success",
":",
"return",
"False",
"# Not all devices report online so assume True if its missing",
"return",
"self",
".",
"_device",
".",
"device_json",
"[",
"MYQ_DEV... | [
105,
4
] | [
113,
9
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.is_closed | (self) | Return true if cover is closed, else False. | Return true if cover is closed, else False. | def is_closed(self):
"""Return true if cover is closed, else False."""
return MYQ_TO_HASS.get(self._device.state) == STATE_CLOSED | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"MYQ_TO_HASS",
".",
"get",
"(",
"self",
".",
"_device",
".",
"state",
")",
"==",
"STATE_CLOSED"
] | [
116,
4
] | [
118,
66
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.is_closing | (self) | Return if the cover is closing or not. | Return if the cover is closing or not. | def is_closing(self):
"""Return if the cover is closing or not."""
return MYQ_TO_HASS.get(self._device.state) == STATE_CLOSING | [
"def",
"is_closing",
"(",
"self",
")",
":",
"return",
"MYQ_TO_HASS",
".",
"get",
"(",
"self",
".",
"_device",
".",
"state",
")",
"==",
"STATE_CLOSING"
] | [
121,
4
] | [
123,
67
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.is_opening | (self) | Return if the cover is opening or not. | Return if the cover is opening or not. | def is_opening(self):
"""Return if the cover is opening or not."""
return MYQ_TO_HASS.get(self._device.state) == STATE_OPENING | [
"def",
"is_opening",
"(",
"self",
")",
":",
"return",
"MYQ_TO_HASS",
".",
"get",
"(",
"self",
".",
"_device",
".",
"state",
")",
"==",
"STATE_OPENING"
] | [
126,
4
] | [
128,
67
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return SUPPORT_OPEN | SUPPORT_CLOSE | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_OPEN",
"|",
"SUPPORT_CLOSE"
] | [
131,
4
] | [
133,
43
] | python | en | ['da', 'en', 'en'] | True |
MyQDevice.unique_id | (self) | Return a unique, Home Assistant friendly identifier for this entity. | Return a unique, Home Assistant friendly identifier for this entity. | def unique_id(self):
"""Return a unique, Home Assistant friendly identifier for this entity."""
return self._device.device_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"device_id"
] | [
136,
4
] | [
138,
37
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.async_close_cover | (self, **kwargs) | Issue close command to cover. | Issue close command to cover. | async def async_close_cover(self, **kwargs):
"""Issue close command to cover."""
self._last_action_timestamp = time.time()
await self._device.close()
self._async_schedule_update_for_transition() | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_last_action_timestamp",
"=",
"time",
".",
"time",
"(",
")",
"await",
"self",
".",
"_device",
".",
"close",
"(",
")",
"self",
".",
"_async_schedule_update_fo... | [
140,
4
] | [
144,
52
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.async_open_cover | (self, **kwargs) | Issue open command to cover. | Issue open command to cover. | async def async_open_cover(self, **kwargs):
"""Issue open command to cover."""
self._last_action_timestamp = time.time()
await self._device.open()
self._async_schedule_update_for_transition() | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_last_action_timestamp",
"=",
"time",
".",
"time",
"(",
")",
"await",
"self",
".",
"_device",
".",
"open",
"(",
")",
"self",
".",
"_async_schedule_update_for_... | [
146,
4
] | [
150,
52
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice._async_complete_schedule_update | (self, _) | Update status of the cover via coordinator. | Update status of the cover via coordinator. | async def _async_complete_schedule_update(self, _):
"""Update status of the cover via coordinator."""
self._scheduled_transition_update = None
await self.coordinator.async_request_refresh() | [
"async",
"def",
"_async_complete_schedule_update",
"(",
"self",
",",
"_",
")",
":",
"self",
".",
"_scheduled_transition_update",
"=",
"None",
"await",
"self",
".",
"coordinator",
".",
"async_request_refresh",
"(",
")"
] | [
169,
4
] | [
172,
54
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.device_info | (self) | Return the device_info of the device. | Return the device_info of the device. | def device_info(self):
"""Return the device_info of the device."""
device_info = {
"identifiers": {(DOMAIN, self._device.device_id)},
"name": self._device.name,
"manufacturer": MANUFACTURER,
"sw_version": self._device.firmware_version,
}
mo... | [
"def",
"device_info",
"(",
"self",
")",
":",
"device_info",
"=",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device",
".",
"device_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_device",
".",
"name",
",",
"\"manufacturer\"",... | [
175,
4
] | [
188,
26
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.async_added_to_hass | (self) | Subscribe to updates. | Subscribe to updates. | async def async_added_to_hass(self):
"""Subscribe to updates."""
self.async_on_remove(
self.coordinator.async_add_listener(self._async_consume_update)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"coordinator",
".",
"async_add_listener",
"(",
"self",
".",
"_async_consume_update",
")",
")"
] | [
199,
4
] | [
203,
9
] | python | en | ['en', 'en', 'en'] | True |
MyQDevice.async_will_remove_from_hass | (self) | Undo subscription. | Undo subscription. | async def async_will_remove_from_hass(self):
"""Undo subscription."""
if self._scheduled_transition_update:
self._scheduled_transition_update() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"if",
"self",
".",
"_scheduled_transition_update",
":",
"self",
".",
"_scheduled_transition_update",
"(",
")"
] | [
205,
4
] | [
208,
47
] | python | de | ['pt', 'it', 'de'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Create the SolarEdge Monitoring API sensor. | Create the SolarEdge Monitoring API sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Create the SolarEdge Monitoring API sensor."""
ip_address = config[CONF_IP_ADDRESS]
platform_name = config[CONF_NAME]
# Create new SolarEdge object to retrieve data.
api = SolarEdge(f"http://{ip_address}/")
# Check if api ... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"ip_address",
"=",
"config",
"[",
"CONF_IP_ADDRESS",
"]",
"platform_name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"# Create new SolarEdge object ... | [
143,
0
] | [
230,
32
] | python | en | ['en', 'sm', 'en'] | True |
SolarEdgeSensor.__init__ | (self, platform_name, data, json_key, name, unit, icon, attr) | Initialize the sensor. | Initialize the sensor. | def __init__(self, platform_name, data, json_key, name, unit, icon, attr):
"""Initialize the sensor."""
self._platform_name = platform_name
self._data = data
self._state = None
self._json_key = json_key
self._name = name
self._unit_of_measurement = unit
s... | [
"def",
"__init__",
"(",
"self",
",",
"platform_name",
",",
"data",
",",
"json_key",
",",
"name",
",",
"unit",
",",
"icon",
",",
"attr",
")",
":",
"self",
".",
"_platform_name",
"=",
"platform_name",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_sta... | [
236,
4
] | [
246,
25
] | python | en | ['en', 'en', 'en'] | True |
SolarEdgeSensor.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
return f"{self._platform_name} ({self._name})" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self._platform_name} ({self._name})\""
] | [
249,
4
] | [
251,
54
] | python | en | ['en', 'ig', 'en'] | True |
SolarEdgeSensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
254,
4
] | [
256,
40
] | python | en | ['en', 'la', 'en'] | True |
SolarEdgeSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
if self._attr:
try:
return {self._attr: self._data.info[self._json_key]}
except KeyError:
return None
return None | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_attr",
":",
"try",
":",
"return",
"{",
"self",
".",
"_attr",
":",
"self",
".",
"_data",
".",
"info",
"[",
"self",
".",
"_json_key",
"]",
"}",
"except",
"KeyError",
":",
"re... | [
259,
4
] | [
266,
19
] | python | en | ['en', 'en', 'en'] | True |
SolarEdgeSensor.icon | (self) | Return the sensor icon. | Return the sensor icon. | def icon(self):
"""Return the sensor icon."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
269,
4
] | [
271,
25
] | python | en | ['en', 'fa', 'en'] | True |
SolarEdgeSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
274,
4
] | [
276,
26
] | python | en | ['en', 'en', 'en'] | True |
SolarEdgeSensor.update | (self) | Get the latest data from the sensor and update the state. | Get the latest data from the sensor and update the state. | def update(self):
"""Get the latest data from the sensor and update the state."""
self._data.update()
self._state = self._data.data[self._json_key] | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_data",
".",
"update",
"(",
")",
"self",
".",
"_state",
"=",
"self",
".",
"_data",
".",
"data",
"[",
"self",
".",
"_json_key",
"]"
] | [
278,
4
] | [
281,
53
] | python | en | ['en', 'en', 'en'] | True |
SolarEdgeData.__init__ | (self, hass, api) | Initialize the data object. | Initialize the data object. | def __init__(self, hass, api):
"""Initialize the data object."""
self.hass = hass
self.api = api
self.data = {}
self.info = {} | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"api",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"api",
"=",
"api",
"self",
".",
"data",
"=",
"{",
"}",
"self",
".",
"info",
"=",
"{",
"}"
] | [
287,
4
] | [
292,
22
] | python | en | ['en', 'en', 'en'] | True |
SolarEdgeData.update | (self) | Update the data from the SolarEdge Monitoring API. | Update the data from the SolarEdge Monitoring API. | def update(self):
"""Update the data from the SolarEdge Monitoring API."""
try:
status = self.api.get_status()
_LOGGER.debug("Status from SolarEdge: %s", status)
except ConnectTimeout:
_LOGGER.error("Connection timeout, skipping update")
return
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"status",
"=",
"self",
".",
"api",
".",
"get_status",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Status from SolarEdge: %s\"",
",",
"status",
")",
"except",
"ConnectTimeout",
":",
"_LOGGER",
".",
"error",... | [
295,
4
] | [
371,
57
] | python | en | ['en', 'en', 'en'] | True |
setup_comp | (hass, config_count) | Set up group cover component. | Set up group cover component. | async def setup_comp(hass, config_count):
"""Set up group cover component."""
config, count = config_count
with assert_setup_component(count, DOMAIN):
await async_setup_component(hass, DOMAIN, config)
await hass.async_block_till_done()
await hass.async_start()
await hass.async_block_till... | [
"async",
"def",
"setup_comp",
"(",
"hass",
",",
"config_count",
")",
":",
"config",
",",
"count",
"=",
"config_count",
"with",
"assert_setup_component",
"(",
"count",
",",
"DOMAIN",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
... | [
84,
0
] | [
91,
38
] | python | en | ['en', 'en', 'en'] | True |
test_attributes | (hass, setup_comp) | Test handling of state attributes. | Test handling of state attributes. | async def test_attributes(hass, setup_comp):
"""Test handling of state attributes."""
state = hass.states.get(COVER_GROUP)
assert state.state == STATE_CLOSED
assert state.attributes[ATTR_FRIENDLY_NAME] == DEFAULT_NAME
assert state.attributes[ATTR_ENTITY_ID] == [
DEMO_COVER,
DEMO_COVE... | [
"async",
"def",
"test_attributes",
"(",
"hass",
",",
"setup_comp",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"COVER_GROUP",
")",
"assert",
"state",
".",
"state",
"==",
"STATE_CLOSED",
"assert",
"state",
".",
"attributes",
"[",
"ATTR_F... | [
95,
0
] | [
220,
55
] | python | en | ['en', 'en', 'en'] | True |
test_cover_that_only_supports_tilt_removed | (hass, setup_comp) | Test removing a cover that support tilt. | Test removing a cover that support tilt. | async def test_cover_that_only_supports_tilt_removed(hass, setup_comp):
"""Test removing a cover that support tilt."""
hass.states.async_set(
DEMO_COVER_TILT,
STATE_OPEN,
{ATTR_SUPPORTED_FEATURES: 128, ATTR_CURRENT_TILT_POSITION: 60},
)
hass.states.async_set(
DEMO_TILT,
... | [
"async",
"def",
"test_cover_that_only_supports_tilt_removed",
"(",
"hass",
",",
"setup_comp",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"DEMO_COVER_TILT",
",",
"STATE_OPEN",
",",
"{",
"ATTR_SUPPORTED_FEATURES",
":",
"128",
",",
"ATTR_CURRENT_TILT_POSITIO... | [
224,
0
] | [
248,
38
] | python | en | ['en', 'en', 'en'] | True |
test_open_covers | (hass, setup_comp) | Test open cover function. | Test open cover function. | async def test_open_covers(hass, setup_comp):
"""Test open cover function."""
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
)
for _ in range(10):
future = dt_util.utcnow() + timedelta(seconds=1)
async_fire_time_changed(h... | [
"async",
"def",
"test_open_covers",
"(",
"hass",
",",
"setup_comp",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_OPEN_COVER",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
"}",
",",
"blocking",
"=",
"True",
")... | [
252,
0
] | [
269,
84
] | python | en | ['en', 'en', 'en'] | True |
test_close_covers | (hass, setup_comp) | Test close cover function. | Test close cover function. | async def test_close_covers(hass, setup_comp):
"""Test close cover function."""
await hass.services.async_call(
DOMAIN, SERVICE_CLOSE_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
)
for _ in range(10):
future = dt_util.utcnow() + timedelta(seconds=1)
async_fire_time_change... | [
"async",
"def",
"test_close_covers",
"(",
"hass",
",",
"setup_comp",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_CLOSE_COVER",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
"}",
",",
"blocking",
"=",
"True",
... | [
273,
0
] | [
290,
82
] | python | en | ['en', 'en', 'en'] | True |
test_toggle_covers | (hass, setup_comp) | Test toggle cover function. | Test toggle cover function. | async def test_toggle_covers(hass, setup_comp):
"""Test toggle cover function."""
# Start covers in open state
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
)
for _ in range(10):
future = dt_util.utcnow() + timedelta(seconds=... | [
"async",
"def",
"test_toggle_covers",
"(",
"hass",
",",
"setup_comp",
")",
":",
"# Start covers in open state",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_OPEN_COVER",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
"}",
",",... | [
294,
0
] | [
340,
84
] | python | en | ['en', 'en', 'en'] | True |
test_stop_covers | (hass, setup_comp) | Test stop cover function. | Test stop cover function. | async def test_stop_covers(hass, setup_comp):
"""Test stop cover function."""
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
)
future = dt_util.utcnow() + timedelta(seconds=1)
async_fire_time_changed(hass, future)
await hass.async... | [
"async",
"def",
"test_stop_covers",
"(",
"hass",
",",
"setup_comp",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_OPEN_COVER",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
"}",
",",
"blocking",
"=",
"True",
")... | [
344,
0
] | [
366,
83
] | python | en | ['en', 'en', 'en'] | True |
test_set_cover_position | (hass, setup_comp) | Test set cover position function. | Test set cover position function. | async def test_set_cover_position(hass, setup_comp):
"""Test set cover position function."""
await hass.services.async_call(
DOMAIN,
SERVICE_SET_COVER_POSITION,
{ATTR_ENTITY_ID: COVER_GROUP, ATTR_POSITION: 50},
blocking=True,
)
for _ in range(4):
future = dt_util.... | [
"async",
"def",
"test_set_cover_position",
"(",
"hass",
",",
"setup_comp",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SET_COVER_POSITION",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
",",
"ATTR_POSITION",
":",
... | [
370,
0
] | [
389,
83
] | python | en | ['en', 'en', 'en'] | True |
test_open_tilts | (hass, setup_comp) | Test open tilt function. | Test open tilt function. | async def test_open_tilts(hass, setup_comp):
"""Test open tilt function."""
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER_TILT, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
)
for _ in range(5):
future = dt_util.utcnow() + timedelta(seconds=1)
async_fire_time_changed(... | [
"async",
"def",
"test_open_tilts",
"(",
"hass",
",",
"setup_comp",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_OPEN_COVER_TILT",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
"}",
",",
"blocking",
"=",
"True",
... | [
393,
0
] | [
409,
5
] | python | da | ['da', 'no', 'en'] | False |
test_close_tilts | (hass, setup_comp) | Test close tilt function. | Test close tilt function. | async def test_close_tilts(hass, setup_comp):
"""Test close tilt function."""
await hass.services.async_call(
DOMAIN, SERVICE_CLOSE_COVER_TILT, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
)
for _ in range(5):
future = dt_util.utcnow() + timedelta(seconds=1)
async_fire_time_chang... | [
"async",
"def",
"test_close_tilts",
"(",
"hass",
",",
"setup_comp",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_CLOSE_COVER_TILT",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
"}",
",",
"blocking",
"=",
"True"... | [
413,
0
] | [
427,
87
] | python | da | ['da', 'fr', 'en'] | False |
test_toggle_tilts | (hass, setup_comp) | Test toggle tilt function. | Test toggle tilt function. | async def test_toggle_tilts(hass, setup_comp):
"""Test toggle tilt function."""
# Start tilted open
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER_TILT, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
)
for _ in range(10):
future = dt_util.utcnow() + timedelta(seconds=1)
... | [
"async",
"def",
"test_toggle_tilts",
"(",
"hass",
",",
"setup_comp",
")",
":",
"# Start tilted open",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_OPEN_COVER_TILT",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
"}",
",",
"b... | [
431,
0
] | [
480,
5
] | python | da | ['da', 'da', 'en'] | True |
test_stop_tilts | (hass, setup_comp) | Test stop tilts function. | Test stop tilts function. | async def test_stop_tilts(hass, setup_comp):
"""Test stop tilts function."""
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER_TILT, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
)
future = dt_util.utcnow() + timedelta(seconds=1)
async_fire_time_changed(hass, future)
await hass.a... | [
"async",
"def",
"test_stop_tilts",
"(",
"hass",
",",
"setup_comp",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_OPEN_COVER_TILT",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
"}",
",",
"blocking",
"=",
"True",
... | [
484,
0
] | [
504,
88
] | python | da | ['da', 'da', 'en'] | True |
test_set_tilt_positions | (hass, setup_comp) | Test set tilt position function. | Test set tilt position function. | async def test_set_tilt_positions(hass, setup_comp):
"""Test set tilt position function."""
await hass.services.async_call(
DOMAIN,
SERVICE_SET_COVER_TILT_POSITION,
{ATTR_ENTITY_ID: COVER_GROUP, ATTR_TILT_POSITION: 80},
blocking=True,
)
for _ in range(3):
future =... | [
"async",
"def",
"test_set_tilt_positions",
"(",
"hass",
",",
"setup_comp",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SET_COVER_TILT_POSITION",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
",",
"ATTR_TILT_POSITION"... | [
508,
0
] | [
525,
88
] | python | da | ['da', 'da', 'en'] | True |
test_is_opening_closing | (hass, setup_comp) | Test is_opening property. | Test is_opening property. | async def test_is_opening_closing(hass, setup_comp):
"""Test is_opening property."""
await hass.services.async_call(
DOMAIN, SERVICE_OPEN_COVER, {ATTR_ENTITY_ID: COVER_GROUP}, blocking=True
)
await hass.async_block_till_done()
assert hass.states.get(DEMO_COVER_POS).state == STATE_OPENING
... | [
"async",
"def",
"test_is_opening_closing",
"(",
"hass",
",",
"setup_comp",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_OPEN_COVER",
",",
"{",
"ATTR_ENTITY_ID",
":",
"COVER_GROUP",
"}",
",",
"blocking",
"=",
"True... | [
529,
0
] | [
563,
62
] | python | en | ['en', 'en', 'en'] | True |
test_form | (hass) | Test we get the form. | Test we get the form. | async def test_form(hass):
"""Test we get the form."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors... | [
"async",
"def",
"test_form",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(... | [
24,
0
] | [
53,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_invalid_auth | (hass) | Test we handle invalid auth. | Test we handle invalid auth. | async def test_form_invalid_auth(hass):
"""Test we handle invalid auth."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.tesla.config_flow.TeslaAPI.connect",
side_effect=TeslaExc... | [
"async",
"def",
"test_form_invalid_auth",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")"... | [
56,
0
] | [
72,
56
] | python | en | ['en', 'en', 'en'] | True |
test_form_cannot_connect | (hass) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_form_cannot_connect(hass):
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.tesla.config_flow.TeslaAPI.connect",
side_effec... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
"... | [
75,
0
] | [
91,
58
] | python | en | ['en', 'en', 'en'] | True |
test_form_repeat_identifier | (hass) | Test we handle repeat identifiers. | Test we handle repeat identifiers. | async def test_form_repeat_identifier(hass):
"""Test we handle repeat identifiers."""
entry = MockConfigEntry(domain=DOMAIN, title="test-username", data={}, options=None)
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE... | [
"async",
"def",
"test_form_repeat_identifier",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"title",
"=",
"\"test-username\"",
",",
"data",
"=",
"{",
"}",
",",
"options",
"=",
"None",
")",
"entry",
".",
"add_to... | [
94,
0
] | [
112,
69
] | python | en | ['en', 'af', 'en'] | True |
test_import | (hass) | Test import step. | Test import step. | async def test_import(hass):
"""Test import step."""
with patch(
"homeassistant.components.tesla.config_flow.TeslaAPI.connect",
return_value=("test-refresh-token", "test-access-token"),
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"... | [
"async",
"def",
"test_import",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.tesla.config_flow.TeslaAPI.connect\"",
",",
"return_value",
"=",
"(",
"\"test-refresh-token\"",
",",
"\"test-access-token\"",
")",
",",
")",
":",
"result",
"=",
"aw... | [
115,
0
] | [
131,
53
] | python | de | ['de', 'sd', 'en'] | False |
test_option_flow | (hass) | Test config flow options. | Test config flow options. | async def test_option_flow(hass):
"""Test config flow options."""
entry = MockConfigEntry(domain=DOMAIN, data={}, options=None)
entry.add_to_hass(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "form"
assert result["step_id"] == "init"
... | [
"async",
"def",
"test_option_flow",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"}",
",",
"options",
"=",
"None",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"result",
"=",
"await... | [
134,
0
] | [
149,
80
] | python | en | ['en', 'fr', 'en'] | True |
test_option_flow_defaults | (hass) | Test config flow options. | Test config flow options. | async def test_option_flow_defaults(hass):
"""Test config flow options."""
entry = MockConfigEntry(domain=DOMAIN, data={}, options=None)
entry.add_to_hass(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "form"
assert result["step_id"] == "in... | [
"async",
"def",
"test_option_flow_defaults",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"}",
",",
"options",
"=",
"None",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"result",
"=",... | [
152,
0
] | [
169,
5
] | python | en | ['en', 'fr', 'en'] | True |
test_option_flow_input_floor | (hass) | Test config flow options. | Test config flow options. | async def test_option_flow_input_floor(hass):
"""Test config flow options."""
entry = MockConfigEntry(domain=DOMAIN, data={}, options=None)
entry.add_to_hass(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] == "form"
assert result["step_id"] == ... | [
"async",
"def",
"test_option_flow_input_floor",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"}",
",",
"options",
"=",
"None",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"result",
"... | [
172,
0
] | [
189,
5
] | python | en | ['en', 'fr', 'en'] | True |
load_dataset | () | Download and reformat MNIST dataset | Download and reformat MNIST dataset | def load_dataset():
"""Download and reformat MNIST dataset"""
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
x_train = x_train[..., tf.newaxis]
x_test = x_test[..., tf.newaxis]
return (x_train, y_trai... | [
"def",
"load_dataset",
"(",
")",
":",
"mnist",
"=",
"tf",
".",
"keras",
".",
"datasets",
".",
"mnist",
"(",
"x_train",
",",
"y_train",
")",
",",
"(",
"x_test",
",",
"y_test",
")",
"=",
"mnist",
".",
"load_data",
"(",
")",
"x_train",
",",
"x_test",
... | [
84,
0
] | [
91,
47
] | python | en | ['en', 'en', 'en'] | True |
main | (params) |
Main program:
- Build network
- Prepare dataset
- Train the model
- Report accuracy to tuner
|
Main program:
- Build network
- Prepare dataset
- Train the model
- Report accuracy to tuner
| def main(params):
"""
Main program:
- Build network
- Prepare dataset
- Train the model
- Report accuracy to tuner
"""
model = MnistModel(
conv_size=params['conv_size'],
hidden_size=params['hidden_size'],
dropout_rate=params['dropout_rate']
)
optim... | [
"def",
"main",
"(",
"params",
")",
":",
"model",
"=",
"MnistModel",
"(",
"conv_size",
"=",
"params",
"[",
"'conv_size'",
"]",
",",
"hidden_size",
"=",
"params",
"[",
"'hidden_size'",
"]",
",",
"dropout_rate",
"=",
"params",
"[",
"'dropout_rate'",
"]",
")",... | [
94,
0
] | [
127,
57
] | python | en | ['en', 'error', 'th'] | False |
MnistModel.__init__ | (self, conv_size, hidden_size, dropout_rate) |
Initialize hyper-parameters.
Parameters
----------
conv_size : int
Kernel size of convolutional layers.
hidden_size : int
Dimensionality of last hidden layer.
dropout_rate : float
Dropout rate between two fully connected (dense) layer... |
Initialize hyper-parameters. | def __init__(self, conv_size, hidden_size, dropout_rate):
"""
Initialize hyper-parameters.
Parameters
----------
conv_size : int
Kernel size of convolutional layers.
hidden_size : int
Dimensionality of last hidden layer.
dropout_rate : flo... | [
"def",
"__init__",
"(",
"self",
",",
"conv_size",
",",
"hidden_size",
",",
"dropout_rate",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"conv1",
"=",
"Conv2D",
"(",
"filters",
"=",
"32",
",",
"kernel_size",
"=",
"conv_size",
","... | [
30,
4
] | [
51,
56
] | python | en | ['en', 'error', 'th'] | False |
MnistModel.call | (self, x) | Override ``Model.call`` to build LeNet-5 model. | Override ``Model.call`` to build LeNet-5 model. | def call(self, x):
"""Override ``Model.call`` to build LeNet-5 model."""
x = self.conv1(x)
x = self.pool1(x)
x = self.conv2(x)
x = self.pool2(x)
x = self.flatten(x)
x = self.fc1(x)
x = self.dropout(x)
return self.fc2(x) | [
"def",
"call",
"(",
"self",
",",
"x",
")",
":",
"x",
"=",
"self",
".",
"conv1",
"(",
"x",
")",
"x",
"=",
"self",
".",
"pool1",
"(",
"x",
")",
"x",
"=",
"self",
".",
"conv2",
"(",
"x",
")",
"x",
"=",
"self",
".",
"pool2",
"(",
"x",
")",
... | [
53,
4
] | [
62,
26
] | python | en | ['en', 'no', 'en'] | True |
ReportIntermediates.on_epoch_end | (self, epoch, logs=None) | Reports intermediate accuracy to NNI framework | Reports intermediate accuracy to NNI framework | def on_epoch_end(self, epoch, logs=None):
"""Reports intermediate accuracy to NNI framework"""
# TensorFlow 2.0 API reference claims the key is `val_acc`, but in fact it's `val_accuracy`
if 'val_acc' in logs:
nni.report_intermediate_result(logs['val_acc'])
else:
n... | [
"def",
"on_epoch_end",
"(",
"self",
",",
"epoch",
",",
"logs",
"=",
"None",
")",
":",
"# TensorFlow 2.0 API reference claims the key is `val_acc`, but in fact it's `val_accuracy`",
"if",
"'val_acc'",
"in",
"logs",
":",
"nni",
".",
"report_intermediate_result",
"(",
"logs"... | [
75,
4
] | [
81,
64
] | python | en | ['en', 'ig', 'en'] | True |
test_show_form | (hass) | Test that the form is served with no input. | Test that the form is served with no input. | async def test_show_form(hass):
"""Test that the form is served with no input."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user" | [
"async",
"def",
"test_show_form",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")",
"ass... | [
18,
0
] | [
25,
38
] | python | en | ['en', 'en', 'en'] | True |
test_adding_second_device | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test that only one Atag configuration is allowed. | Test that only one Atag configuration is allowed. | async def test_adding_second_device(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test that only one Atag configuration is allowed."""
await init_integration(hass, aioclient_mock)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entr... | [
"async",
"def",
"test_adding_second_device",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"result",
"=",
"await",
"hass",
".",
... | [
28,
0
] | [
46,
69
] | python | en | ['en', 'en', 'en'] | True |
test_connection_error | (hass) | Test we show user form on Atag connection error. | Test we show user form on Atag connection error. | async def test_connection_error(hass):
"""Test we show user form on Atag connection error."""
with patch("pyatag.AtagOne.authorize", side_effect=errors.AtagException()):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_USER},
... | [
"async",
"def",
"test_connection_error",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pyatag.AtagOne.authorize\"",
",",
"side_effect",
"=",
"errors",
".",
"AtagException",
"(",
")",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow... | [
49,
0
] | [
60,
57
] | python | en | ['en', 'en', 'en'] | True |
test_unauthorized | (hass) | Test we show correct form when Unauthorized error is raised. | Test we show correct form when Unauthorized error is raised. | async def test_unauthorized(hass):
"""Test we show correct form when Unauthorized error is raised."""
with patch("pyatag.AtagOne.authorize", side_effect=errors.Unauthorized()):
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_US... | [
"async",
"def",
"test_unauthorized",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"pyatag.AtagOne.authorize\"",
",",
"side_effect",
"=",
"errors",
".",
"Unauthorized",
"(",
")",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
... | [
63,
0
] | [
73,
55
] | python | en | ['en', 'en', 'en'] | True |
test_full_flow_implementation | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test registering an integration and finishing flow works. | Test registering an integration and finishing flow works. | async def test_full_flow_implementation(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test registering an integration and finishing flow works."""
aioclient_mock.post(
"http://127.0.0.1:10000/pair",
json=PAIR_REPLY,
)
aioclient_mock.post(
"http://127... | [
"async",
"def",
"test_full_flow_implementation",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"aioclient_mock",
".",
"post",
"(",
"\"http://127.0.0.1:10000/pair\"",
",",
"json",
"=",
"PAIR_REPLY",
",",
... | [
76,
0
] | [
95,
44
] | python | en | ['en', 'en', 'en'] | True |
mock_handlers | () | Mock config flows. | Mock config flows. | def mock_handlers():
"""Mock config flows."""
class MockFlowHandler(config_entries.ConfigFlow):
"""Define a mock flow handler."""
VERSION = 1
with patch.dict(
config_entries.HANDLERS, {"comp": MockFlowHandler, "test": MockFlowHandler}
):
yield | [
"def",
"mock_handlers",
"(",
")",
":",
"class",
"MockFlowHandler",
"(",
"config_entries",
".",
"ConfigFlow",
")",
":",
"\"\"\"Define a mock flow handler.\"\"\"",
"VERSION",
"=",
"1",
"with",
"patch",
".",
"dict",
"(",
"config_entries",
".",
"HANDLERS",
",",
"{",
... | [
27,
0
] | [
38,
13
] | python | da | ['de', 'da', 'en'] | False |
manager | (hass) | Fixture of a loaded config manager. | Fixture of a loaded config manager. | def manager(hass):
"""Fixture of a loaded config manager."""
manager = config_entries.ConfigEntries(hass, {})
manager._entries = []
manager._store._async_ensure_stop_listener = lambda: None
hass.config_entries = manager
return manager | [
"def",
"manager",
"(",
"hass",
")",
":",
"manager",
"=",
"config_entries",
".",
"ConfigEntries",
"(",
"hass",
",",
"{",
"}",
")",
"manager",
".",
"_entries",
"=",
"[",
"]",
"manager",
".",
"_store",
".",
"_async_ensure_stop_listener",
"=",
"lambda",
":",
... | [
42,
0
] | [
48,
18
] | python | en | ['en', 'en', 'en'] | True |
test_call_setup_entry | (hass) | Test we call <component>.setup_entry. | Test we call <component>.setup_entry. | async def test_call_setup_entry(hass):
"""Test we call <component>.setup_entry."""
entry = MockConfigEntry(domain="comp")
entry.add_to_hass(hass)
assert not entry.supports_unload
mock_setup_entry = AsyncMock(return_value=True)
mock_migrate_entry = AsyncMock(return_value=True)
mock_integrat... | [
"async",
"def",
"test_call_setup_entry",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"comp\"",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"not",
"entry",
".",
"supports_unload",
"mock_setup_entry",
"=",
"Asy... | [
51,
0
] | [
77,
32
] | python | en | ['en', 'en', 'en'] | True |
test_call_setup_entry_without_reload_support | (hass) | Test we call <component>.setup_entry and the <component> does not support unloading. | Test we call <component>.setup_entry and the <component> does not support unloading. | async def test_call_setup_entry_without_reload_support(hass):
"""Test we call <component>.setup_entry and the <component> does not support unloading."""
entry = MockConfigEntry(domain="comp")
entry.add_to_hass(hass)
assert not entry.supports_unload
mock_setup_entry = AsyncMock(return_value=True)
... | [
"async",
"def",
"test_call_setup_entry_without_reload_support",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"comp\"",
")",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"not",
"entry",
".",
"supports_unload",
"mock_setu... | [
80,
0
] | [
106,
36
] | python | en | ['en', 'en', 'en'] | True |
test_call_async_migrate_entry | (hass) | Test we call <component>.async_migrate_entry when version mismatch. | Test we call <component>.async_migrate_entry when version mismatch. | async def test_call_async_migrate_entry(hass):
"""Test we call <component>.async_migrate_entry when version mismatch."""
entry = MockConfigEntry(domain="comp")
assert not entry.supports_unload
entry.version = 2
entry.add_to_hass(hass)
mock_migrate_entry = AsyncMock(return_value=True)
mock_s... | [
"async",
"def",
"test_call_async_migrate_entry",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"comp\"",
")",
"assert",
"not",
"entry",
".",
"supports_unload",
"entry",
".",
"version",
"=",
"2",
"entry",
".",
"add_to_hass",
"(",... | [
109,
0
] | [
136,
32
] | python | en | ['en', 'en', 'en'] | True |
test_call_async_migrate_entry_failure_false | (hass) | Test migration fails if returns false. | Test migration fails if returns false. | async def test_call_async_migrate_entry_failure_false(hass):
"""Test migration fails if returns false."""
entry = MockConfigEntry(domain="comp")
entry.version = 2
entry.add_to_hass(hass)
assert not entry.supports_unload
mock_migrate_entry = AsyncMock(return_value=False)
mock_setup_entry = A... | [
"async",
"def",
"test_call_async_migrate_entry_failure_false",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"comp\"",
")",
"entry",
".",
"version",
"=",
"2",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"not",
"entr... | [
139,
0
] | [
164,
36
] | python | fr | ['fr', 'fr', 'en'] | True |
test_call_async_migrate_entry_failure_exception | (hass) | Test migration fails if exception raised. | Test migration fails if exception raised. | async def test_call_async_migrate_entry_failure_exception(hass):
"""Test migration fails if exception raised."""
entry = MockConfigEntry(domain="comp")
entry.version = 2
entry.add_to_hass(hass)
assert not entry.supports_unload
mock_migrate_entry = AsyncMock(side_effect=Exception)
mock_setup... | [
"async",
"def",
"test_call_async_migrate_entry_failure_exception",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"comp\"",
")",
"entry",
".",
"version",
"=",
"2",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"not",
"... | [
167,
0
] | [
192,
36
] | python | en | ['en', 'fr', 'en'] | True |
test_call_async_migrate_entry_failure_not_bool | (hass) | Test migration fails if boolean not returned. | Test migration fails if boolean not returned. | async def test_call_async_migrate_entry_failure_not_bool(hass):
"""Test migration fails if boolean not returned."""
entry = MockConfigEntry(domain="comp")
entry.version = 2
entry.add_to_hass(hass)
assert not entry.supports_unload
mock_migrate_entry = AsyncMock(return_value=None)
mock_setup_... | [
"async",
"def",
"test_call_async_migrate_entry_failure_not_bool",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"comp\"",
")",
"entry",
".",
"version",
"=",
"2",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"not",
"e... | [
195,
0
] | [
220,
36
] | python | en | ['en', 'en', 'en'] | True |
test_call_async_migrate_entry_failure_not_supported | (hass) | Test migration fails if async_migrate_entry not implemented. | Test migration fails if async_migrate_entry not implemented. | async def test_call_async_migrate_entry_failure_not_supported(hass):
"""Test migration fails if async_migrate_entry not implemented."""
entry = MockConfigEntry(domain="comp")
entry.version = 2
entry.add_to_hass(hass)
assert not entry.supports_unload
mock_setup_entry = AsyncMock(return_value=Tru... | [
"async",
"def",
"test_call_async_migrate_entry_failure_not_supported",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"comp\"",
")",
"entry",
".",
"version",
"=",
"2",
"entry",
".",
"add_to_hass",
"(",
"hass",
")",
"assert",
"not",... | [
223,
0
] | [
239,
36
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry | (hass, manager) | Test that we can remove an entry. | Test that we can remove an entry. | async def test_remove_entry(hass, manager):
"""Test that we can remove an entry."""
async def mock_setup_entry(hass, entry):
"""Mock setting up entry."""
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "light")
)
return True
async de... | [
"async",
"def",
"test_remove_entry",
"(",
"hass",
",",
"manager",
")",
":",
"async",
"def",
"mock_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"\"\"\"Mock setting up entry.\"\"\"",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"config_entries",
".",
... | [
242,
0
] | [
325,
32
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_handles_callback_error | (hass, manager) | Test that exceptions in the remove callback are handled. | Test that exceptions in the remove callback are handled. | async def test_remove_entry_handles_callback_error(hass, manager):
"""Test that exceptions in the remove callback are handled."""
mock_setup_entry = AsyncMock(return_value=True)
mock_unload_entry = AsyncMock(return_value=True)
mock_remove_entry = AsyncMock(return_value=None)
mock_integration(
... | [
"async",
"def",
"test_remove_entry_handles_callback_error",
"(",
"hass",
",",
"manager",
")",
":",
"mock_setup_entry",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"mock_unload_entry",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"mock_remove... | [
328,
0
] | [
358,
68
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_raises | (hass, manager) | Test if a component raises while removing entry. | Test if a component raises while removing entry. | async def test_remove_entry_raises(hass, manager):
"""Test if a component raises while removing entry."""
async def mock_unload_entry(hass, entry):
"""Mock unload entry function."""
raise Exception("BROKEN")
mock_integration(hass, MockModule("comp", async_unload_entry=mock_unload_entry))
... | [
"async",
"def",
"test_remove_entry_raises",
"(",
"hass",
",",
"manager",
")",
":",
"async",
"def",
"mock_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"\"\"\"Mock unload entry function.\"\"\"",
"raise",
"Exception",
"(",
"\"BROKEN\"",
")",
"mock_integration",
... | [
361,
0
] | [
385,
84
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entry_if_not_loaded | (hass, manager) | Test that we can remove an entry that is not loaded. | Test that we can remove an entry that is not loaded. | async def test_remove_entry_if_not_loaded(hass, manager):
"""Test that we can remove an entry that is not loaded."""
mock_unload_entry = AsyncMock(return_value=True)
mock_integration(hass, MockModule("comp", async_unload_entry=mock_unload_entry))
MockConfigEntry(domain="test", entry_id="test1").add_to... | [
"async",
"def",
"test_remove_entry_if_not_loaded",
"(",
"hass",
",",
"manager",
")",
":",
"mock_unload_entry",
"=",
"AsyncMock",
"(",
"return_value",
"=",
"True",
")",
"mock_integration",
"(",
"hass",
",",
"MockModule",
"(",
"\"comp\"",
",",
"async_unload_entry",
... | [
388,
0
] | [
409,
49
] | 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.