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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_call_no_context_target_all | (hass, mock_handle_entity_call, mock_entities) | Check we target all if no user context given. | Check we target all if no user context given. | async def test_call_no_context_target_all(hass, mock_handle_entity_call, mock_entities):
"""Check we target all if no user context given."""
await service.entity_service_call(
hass,
[Mock(entities=mock_entities)],
Mock(),
ha.ServiceCall(
"test_domain", "test_service",... | [
"async",
"def",
"test_call_no_context_target_all",
"(",
"hass",
",",
"mock_handle_entity_call",
",",
"mock_entities",
")",
":",
"await",
"service",
".",
"entity_service_call",
"(",
"hass",
",",
"[",
"Mock",
"(",
"entities",
"=",
"mock_entities",
")",
"]",
",",
"... | [
559,
0
] | [
573,
5
] | python | en | ['en', 'en', 'en'] | True |
test_call_no_context_target_specific | (
hass, mock_handle_entity_call, mock_entities
) | Check we can target specified entities. | Check we can target specified entities. | async def test_call_no_context_target_specific(
hass, mock_handle_entity_call, mock_entities
):
"""Check we can target specified entities."""
await service.entity_service_call(
hass,
[Mock(entities=mock_entities)],
Mock(),
ha.ServiceCall(
"test_domain",
... | [
"async",
"def",
"test_call_no_context_target_specific",
"(",
"hass",
",",
"mock_handle_entity_call",
",",
"mock_entities",
")",
":",
"await",
"service",
".",
"entity_service_call",
"(",
"hass",
",",
"[",
"Mock",
"(",
"entities",
"=",
"mock_entities",
")",
"]",
","... | [
576,
0
] | [
592,
83
] | python | en | ['en', 'en', 'en'] | True |
test_call_with_match_all | (
hass, mock_handle_entity_call, mock_entities, caplog
) | Check we only target allowed entities if targeting all. | Check we only target allowed entities if targeting all. | async def test_call_with_match_all(
hass, mock_handle_entity_call, mock_entities, caplog
):
"""Check we only target allowed entities if targeting all."""
await service.entity_service_call(
hass,
[Mock(entities=mock_entities)],
Mock(),
ha.ServiceCall("test_domain", "test_servi... | [
"async",
"def",
"test_call_with_match_all",
"(",
"hass",
",",
"mock_handle_entity_call",
",",
"mock_entities",
",",
"caplog",
")",
":",
"await",
"service",
".",
"entity_service_call",
"(",
"hass",
",",
"[",
"Mock",
"(",
"entities",
"=",
"mock_entities",
")",
"]"... | [
595,
0
] | [
609,
5
] | python | en | ['en', 'en', 'en'] | True |
test_call_with_omit_entity_id | (hass, mock_handle_entity_call, mock_entities) | Check service call if we do not pass an entity ID. | Check service call if we do not pass an entity ID. | async def test_call_with_omit_entity_id(hass, mock_handle_entity_call, mock_entities):
"""Check service call if we do not pass an entity ID."""
await service.entity_service_call(
hass,
[Mock(entities=mock_entities)],
Mock(),
ha.ServiceCall("test_domain", "test_service"),
)
... | [
"async",
"def",
"test_call_with_omit_entity_id",
"(",
"hass",
",",
"mock_handle_entity_call",
",",
"mock_entities",
")",
":",
"await",
"service",
".",
"entity_service_call",
"(",
"hass",
",",
"[",
"Mock",
"(",
"entities",
"=",
"mock_entities",
")",
"]",
",",
"Mo... | [
612,
0
] | [
621,
55
] | python | en | ['en', 'en', 'en'] | True |
test_register_admin_service | (hass, hass_read_only_user, hass_admin_user) | Test the register admin service. | Test the register admin service. | async def test_register_admin_service(hass, hass_read_only_user, hass_admin_user):
"""Test the register admin service."""
calls = []
async def mock_service(call):
calls.append(call)
hass.helpers.service.async_register_admin_service("test", "test", mock_service)
hass.helpers.service.async_r... | [
"async",
"def",
"test_register_admin_service",
"(",
"hass",
",",
"hass_read_only_user",
",",
"hass_admin_user",
")",
":",
"calls",
"=",
"[",
"]",
"async",
"def",
"mock_service",
"(",
"call",
")",
":",
"calls",
".",
"append",
"(",
"call",
")",
"hass",
".",
... | [
624,
0
] | [
687,
57
] | python | en | ['en', 'en', 'en'] | True |
test_domain_control_not_async | (hass, mock_entities) | Test domain verification in a service call with an unknown user. | Test domain verification in a service call with an unknown user. | async def test_domain_control_not_async(hass, mock_entities):
"""Test domain verification in a service call with an unknown user."""
calls = []
def mock_service_log(call):
"""Define a protected service."""
calls.append(call)
with pytest.raises(exceptions.HomeAssistantError):
ha... | [
"async",
"def",
"test_domain_control_not_async",
"(",
"hass",
",",
"mock_entities",
")",
":",
"calls",
"=",
"[",
"]",
"def",
"mock_service_log",
"(",
"call",
")",
":",
"\"\"\"Define a protected service.\"\"\"",
"calls",
".",
"append",
"(",
"call",
")",
"with",
"... | [
690,
0
] | [
699,
83
] | python | en | ['en', 'en', 'en'] | True |
test_domain_control_unknown | (hass, mock_entities) | Test domain verification in a service call with an unknown user. | Test domain verification in a service call with an unknown user. | async def test_domain_control_unknown(hass, mock_entities):
"""Test domain verification in a service call with an unknown user."""
calls = []
async def mock_service_log(call):
"""Define a protected service."""
calls.append(call)
with patch(
"homeassistant.helpers.entity_registr... | [
"async",
"def",
"test_domain_control_unknown",
"(",
"hass",
",",
"mock_entities",
")",
":",
"calls",
"=",
"[",
"]",
"async",
"def",
"mock_service_log",
"(",
"call",
")",
":",
"\"\"\"Define a protected service.\"\"\"",
"calls",
".",
"append",
"(",
"call",
")",
"w... | [
702,
0
] | [
730,
30
] | python | en | ['en', 'en', 'en'] | True |
test_domain_control_unauthorized | (hass, hass_read_only_user) | Test domain verification in a service call with an unauthorized user. | Test domain verification in a service call with an unauthorized user. | async def test_domain_control_unauthorized(hass, hass_read_only_user):
"""Test domain verification in a service call with an unauthorized user."""
mock_registry(
hass,
{
"light.kitchen": ent_reg.RegistryEntry(
entity_id="light.kitchen",
unique_id="kitc... | [
"async",
"def",
"test_domain_control_unauthorized",
"(",
"hass",
",",
"hass_read_only_user",
")",
":",
"mock_registry",
"(",
"hass",
",",
"{",
"\"light.kitchen\"",
":",
"ent_reg",
".",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"light.kitchen\"",
",",
"unique_id",
"=... | [
733,
0
] | [
769,
26
] | python | en | ['en', 'en', 'en'] | True |
test_domain_control_admin | (hass, hass_admin_user) | Test domain verification in a service call with an admin user. | Test domain verification in a service call with an admin user. | async def test_domain_control_admin(hass, hass_admin_user):
"""Test domain verification in a service call with an admin user."""
mock_registry(
hass,
{
"light.kitchen": ent_reg.RegistryEntry(
entity_id="light.kitchen",
unique_id="kitchen",
... | [
"async",
"def",
"test_domain_control_admin",
"(",
"hass",
",",
"hass_admin_user",
")",
":",
"mock_registry",
"(",
"hass",
",",
"{",
"\"light.kitchen\"",
":",
"ent_reg",
".",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"light.kitchen\"",
",",
"unique_id",
"=",
"\"kit... | [
772,
0
] | [
807,
26
] | python | en | ['en', 'en', 'en'] | True |
test_domain_control_no_user | (hass) | Test domain verification in a service call with no user. | Test domain verification in a service call with no user. | async def test_domain_control_no_user(hass):
"""Test domain verification in a service call with no user."""
mock_registry(
hass,
{
"light.kitchen": ent_reg.RegistryEntry(
entity_id="light.kitchen",
unique_id="kitchen",
platform="test_do... | [
"async",
"def",
"test_domain_control_no_user",
"(",
"hass",
")",
":",
"mock_registry",
"(",
"hass",
",",
"{",
"\"light.kitchen\"",
":",
"ent_reg",
".",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"light.kitchen\"",
",",
"unique_id",
"=",
"\"kitchen\"",
",",
"platfor... | [
810,
0
] | [
845,
26
] | python | en | ['en', 'en', 'en'] | True |
test_extract_from_service_available_device | (hass) | Test the extraction of entity from service and device is available. | Test the extraction of entity from service and device is available. | async def test_extract_from_service_available_device(hass):
"""Test the extraction of entity from service and device is available."""
entities = [
MockEntity(name="test_1", entity_id="test_domain.test_1"),
MockEntity(name="test_2", entity_id="test_domain.test_2", available=False),
MockEn... | [
"async",
"def",
"test_extract_from_service_available_device",
"(",
"hass",
")",
":",
"entities",
"=",
"[",
"MockEntity",
"(",
"name",
"=",
"\"test_1\"",
",",
"entity_id",
"=",
"\"test_domain.test_1\"",
")",
",",
"MockEntity",
"(",
"name",
"=",
"\"test_2\"",
",",
... | [
848,
0
] | [
886,
5
] | python | en | ['en', 'en', 'en'] | True |
test_extract_from_service_empty_if_no_entity_id | (hass) | Test the extraction from service without specifying entity. | Test the extraction from service without specifying entity. | async def test_extract_from_service_empty_if_no_entity_id(hass):
"""Test the extraction from service without specifying entity."""
entities = [
MockEntity(name="test_1", entity_id="test_domain.test_1"),
MockEntity(name="test_2", entity_id="test_domain.test_2"),
]
call = ha.ServiceCall("t... | [
"async",
"def",
"test_extract_from_service_empty_if_no_entity_id",
"(",
"hass",
")",
":",
"entities",
"=",
"[",
"MockEntity",
"(",
"name",
"=",
"\"test_1\"",
",",
"entity_id",
"=",
"\"test_domain.test_1\"",
")",
",",
"MockEntity",
"(",
"name",
"=",
"\"test_2\"",
"... | [
889,
0
] | [
900,
5
] | python | en | ['en', 'en', 'en'] | True |
test_extract_from_service_filter_out_non_existing_entities | (hass) | Test the extraction of non existing entities from service. | Test the extraction of non existing entities from service. | async def test_extract_from_service_filter_out_non_existing_entities(hass):
"""Test the extraction of non existing entities from service."""
entities = [
MockEntity(name="test_1", entity_id="test_domain.test_1"),
MockEntity(name="test_2", entity_id="test_domain.test_2"),
]
call = ha.Ser... | [
"async",
"def",
"test_extract_from_service_filter_out_non_existing_entities",
"(",
"hass",
")",
":",
"entities",
"=",
"[",
"MockEntity",
"(",
"name",
"=",
"\"test_1\"",
",",
"entity_id",
"=",
"\"test_domain.test_1\"",
")",
",",
"MockEntity",
"(",
"name",
"=",
"\"tes... | [
903,
0
] | [
919,
5
] | python | en | ['en', 'en', 'en'] | True |
test_extract_from_service_area_id | (hass, area_mock) | Test the extraction using area ID as reference. | Test the extraction using area ID as reference. | async def test_extract_from_service_area_id(hass, area_mock):
"""Test the extraction using area ID as reference."""
entities = [
MockEntity(name="in_area", entity_id="light.in_area"),
MockEntity(name="no_area", entity_id="light.no_area"),
MockEntity(name="diff_area", entity_id="light.dif... | [
"async",
"def",
"test_extract_from_service_area_id",
"(",
"hass",
",",
"area_mock",
")",
":",
"entities",
"=",
"[",
"MockEntity",
"(",
"name",
"=",
"\"in_area\"",
",",
"entity_id",
"=",
"\"light.in_area\"",
")",
",",
"MockEntity",
"(",
"name",
"=",
"\"no_area\""... | [
922,
0
] | [
941,
5
] | python | en | ['en', 'en', 'en'] | True |
TestServiceHelpers.setUp | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setUp(self): # pylint: disable=invalid-name
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.calls = mock_service(self.hass, "test_domain", "test_service") | [
"def",
"setUp",
"(",
"self",
")",
":",
"# pylint: disable=invalid-name",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"self",
".",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"\"test_domain\"",
",",
"\"test_service\"",
")"
] | [
161,
4
] | [
164,
75
] | python | en | ['en', 'en', 'en'] | True |
TestServiceHelpers.tearDown | (self) | Stop down everything that was started. | Stop down everything that was started. | def tearDown(self): # pylint: disable=invalid-name
"""Stop down everything that was started."""
self.hass.stop() | [
"def",
"tearDown",
"(",
"self",
")",
":",
"# pylint: disable=invalid-name",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
166,
4
] | [
168,
24
] | python | en | ['en', 'en', 'en'] | True |
TestServiceHelpers.test_service_call | (self) | Test service call with templating. | Test service call with templating. | def test_service_call(self):
"""Test service call with templating."""
config = {
"service": "{{ 'test_domain.test_service' }}",
"entity_id": "hello.world",
"data": {
"hello": "{{ 'goodbye' }}",
"data": {"value": "{{ 'complex' }}", "simp... | [
"def",
"test_service_call",
"(",
"self",
")",
":",
"config",
"=",
"{",
"\"service\"",
":",
"\"{{ 'test_domain.test_service' }}\"",
",",
"\"entity_id\"",
":",
"\"hello.world\"",
",",
"\"data\"",
":",
"{",
"\"hello\"",
":",
"\"{{ 'goodbye' }}\"",
",",
"\"data\"",
":",... | [
170,
4
] | [
188,
54
] | python | en | ['en', 'en', 'en'] | True |
TestServiceHelpers.test_service_template_service_call | (self) | Test legacy service_template call with templating. | Test legacy service_template call with templating. | def test_service_template_service_call(self):
"""Test legacy service_template call with templating."""
config = {
"service_template": "{{ 'test_domain.test_service' }}",
"entity_id": "hello.world",
"data": {"hello": "goodbye"},
}
service.call_from_con... | [
"def",
"test_service_template_service_call",
"(",
"self",
")",
":",
"config",
"=",
"{",
"\"service_template\"",
":",
"\"{{ 'test_domain.test_service' }}\"",
",",
"\"entity_id\"",
":",
"\"hello.world\"",
",",
"\"data\"",
":",
"{",
"\"hello\"",
":",
"\"goodbye\"",
"}",
... | [
190,
4
] | [
201,
55
] | python | en | ['en', 'en', 'en'] | True |
TestServiceHelpers.test_passing_variables_to_templates | (self) | Test passing variables to templates. | Test passing variables to templates. | def test_passing_variables_to_templates(self):
"""Test passing variables to templates."""
config = {
"service_template": "{{ var_service }}",
"entity_id": "hello.world",
"data_template": {"hello": "{{ var_data }}"},
}
service.call_from_config(
... | [
"def",
"test_passing_variables_to_templates",
"(",
"self",
")",
":",
"config",
"=",
"{",
"\"service_template\"",
":",
"\"{{ var_service }}\"",
",",
"\"entity_id\"",
":",
"\"hello.world\"",
",",
"\"data_template\"",
":",
"{",
"\"hello\"",
":",
"\"{{ var_data }}\"",
"}",
... | [
203,
4
] | [
221,
55
] | python | en | ['en', 'en', 'en'] | True |
TestServiceHelpers.test_bad_template | (self) | Test passing bad template. | Test passing bad template. | def test_bad_template(self):
"""Test passing bad template."""
config = {
"service_template": "{{ var_service }}",
"entity_id": "hello.world",
"data_template": {"hello": "{{ states + unknown_var }}"},
}
service.call_from_config(
self.hass,
... | [
"def",
"test_bad_template",
"(",
"self",
")",
":",
"config",
"=",
"{",
"\"service_template\"",
":",
"\"{{ var_service }}\"",
",",
"\"entity_id\"",
":",
"\"hello.world\"",
",",
"\"data_template\"",
":",
"{",
"\"hello\"",
":",
"\"{{ states + unknown_var }}\"",
"}",
",",... | [
223,
4
] | [
241,
35
] | python | en | ['en', 'en', 'en'] | True |
TestServiceHelpers.test_split_entity_string | (self) | Test splitting of entity string. | Test splitting of entity string. | def test_split_entity_string(self):
"""Test splitting of entity string."""
service.call_from_config(
self.hass,
{
"service": "test_domain.test_service",
"entity_id": "hello.world, sensor.beer",
},
)
self.hass.block_till_... | [
"def",
"test_split_entity_string",
"(",
"self",
")",
":",
"service",
".",
"call_from_config",
"(",
"self",
".",
"hass",
",",
"{",
"\"service\"",
":",
"\"test_domain.test_service\"",
",",
"\"entity_id\"",
":",
"\"hello.world, sensor.beer\"",
",",
"}",
",",
")",
"se... | [
243,
4
] | [
253,
85
] | python | en | ['en', 'ru-Latn', 'en'] | True |
TestServiceHelpers.test_not_mutate_input | (self) | Test for immutable input. | Test for immutable input. | def test_not_mutate_input(self):
"""Test for immutable input."""
config = cv.SERVICE_SCHEMA(
{
"service": "test_domain.test_service",
"entity_id": "hello.world, sensor.beer",
"data": {"hello": 1},
"data_template": {"nested": {"v... | [
"def",
"test_not_mutate_input",
"(",
"self",
")",
":",
"config",
"=",
"cv",
".",
"SERVICE_SCHEMA",
"(",
"{",
"\"service\"",
":",
"\"test_domain.test_service\"",
",",
"\"entity_id\"",
":",
"\"hello.world, sensor.beer\"",
",",
"\"data\"",
":",
"{",
"\"hello\"",
":",
... | [
255,
4
] | [
271,
29
] | python | en | ['en', 'en', 'en'] | True |
TestServiceHelpers.test_fail_silently_if_no_service | (self, mock_log) | Test failing if service is missing. | Test failing if service is missing. | def test_fail_silently_if_no_service(self, mock_log):
"""Test failing if service is missing."""
service.call_from_config(self.hass, None)
assert mock_log.call_count == 1
service.call_from_config(self.hass, {})
assert mock_log.call_count == 2
service.call_from_config(sel... | [
"def",
"test_fail_silently_if_no_service",
"(",
"self",
",",
"mock_log",
")",
":",
"service",
".",
"call_from_config",
"(",
"self",
".",
"hass",
",",
"None",
")",
"assert",
"mock_log",
".",
"call_count",
"==",
"1",
"service",
".",
"call_from_config",
"(",
"sel... | [
274,
4
] | [
283,
39
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the Foursquare component. | Set up the Foursquare component. | def setup(hass, config):
"""Set up the Foursquare component."""
config = config[DOMAIN]
def checkin_user(call):
"""Check a user in on Swarm."""
url = f"https://api.foursquare.com/v2/checkins/add?oauth_token={config[CONF_ACCESS_TOKEN]}&v=20160802&m=swarm"
response = requests.post(url... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"config",
"=",
"config",
"[",
"DOMAIN",
"]",
"def",
"checkin_user",
"(",
"call",
")",
":",
"\"\"\"Check a user in on Swarm.\"\"\"",
"url",
"=",
"f\"https://api.foursquare.com/v2/checkins/add?oauth_token={config[CONF_... | [
53,
0
] | [
78,
15
] | python | en | ['en', 'fr', 'en'] | True |
FoursquarePushReceiver.__init__ | (self, push_secret) | Initialize the OAuth callback view. | Initialize the OAuth callback view. | def __init__(self, push_secret):
"""Initialize the OAuth callback view."""
self.push_secret = push_secret | [
"def",
"__init__",
"(",
"self",
",",
"push_secret",
")",
":",
"self",
".",
"push_secret",
"=",
"push_secret"
] | [
88,
4
] | [
90,
38
] | python | en | ['en', 'en', 'en'] | True |
FoursquarePushReceiver.post | (self, request) | Accept the POST from Foursquare. | Accept the POST from Foursquare. | async def post(self, request):
"""Accept the POST from Foursquare."""
try:
data = await request.json()
except ValueError:
return self.json_message("Invalid JSON", HTTP_BAD_REQUEST)
secret = data.pop("secret", None)
_LOGGER.debug("Received Foursquare push... | [
"async",
"def",
"post",
"(",
"self",
",",
"request",
")",
":",
"try",
":",
"data",
"=",
"await",
"request",
".",
"json",
"(",
")",
"except",
"ValueError",
":",
"return",
"self",
".",
"json_message",
"(",
"\"Invalid JSON\"",
",",
"HTTP_BAD_REQUEST",
")",
... | [
92,
4
] | [
109,
60
] | python | en | ['en', 'en', 'en'] | True |
QueueTestCase.test_create_queue_entry | (self) | Can we enqueue and save a song on a queue? | Can we enqueue and save a song on a queue? | def test_create_queue_entry(self):
""" Can we enqueue and save a song on a queue? """
self.party.enqueue_song(self.user, 't112233')
self.party.save(self.redis)
p = Party.get(self.redis, self.party.id)
self.assertEquals(p.queue[0].track_key, 't112233') | [
"def",
"test_create_queue_entry",
"(",
"self",
")",
":",
"self",
".",
"party",
".",
"enqueue_song",
"(",
"self",
".",
"user",
",",
"'t112233'",
")",
"self",
".",
"party",
".",
"save",
"(",
"self",
".",
"redis",
")",
"p",
"=",
"Party",
".",
"get",
"("... | [
14,
2
] | [
19,
54
] | python | en | ['en', 'en', 'en'] | True |
QueueTestCase.test_queue_ordering | (self) | Does the comparator on our QueueEntry work as expected? | Does the comparator on our QueueEntry work as expected? | def test_queue_ordering(self):
""" Does the comparator on our QueueEntry work as expected? """
q1 = QueueEntry()
q1.timestamp = datetime.datetime(1950, 1, 1)
q2 = QueueEntry()
q2.timestamp = datetime.datetime(1960, 1, 1)
queue = [q2, q1]
q1.upvote(self.user)
# More votes > fewer vote... | [
"def",
"test_queue_ordering",
"(",
"self",
")",
":",
"q1",
"=",
"QueueEntry",
"(",
")",
"q1",
".",
"timestamp",
"=",
"datetime",
".",
"datetime",
"(",
"1950",
",",
"1",
",",
"1",
")",
"q2",
"=",
"QueueEntry",
"(",
")",
"q2",
".",
"timestamp",
"=",
... | [
21,
2
] | [
50,
38
] | python | en | ['en', 'en', 'en'] | True |
QueueTestCase.test_queue_remove | (self) | Do we dequeue the right song from the party? Does that song get properly removed? | Do we dequeue the right song from the party? Does that song get properly removed? | def test_queue_remove(self):
""" Do we dequeue the right song from the party? Does that song get properly removed? """
q1 = self.party.enqueue_song(self.user, 't123')
q2 = self.party.enqueue_song(self.user, 't456')
q2.upvote(self.user2)
next_entry = self.party.dequeue_next_song()
self.assertEqua... | [
"def",
"test_queue_remove",
"(",
"self",
")",
":",
"q1",
"=",
"self",
".",
"party",
".",
"enqueue_song",
"(",
"self",
".",
"user",
",",
"'t123'",
")",
"q2",
"=",
"self",
".",
"party",
".",
"enqueue_song",
"(",
"self",
".",
"user",
",",
"'t456'",
")",... | [
52,
2
] | [
61,
43
] | python | en | ['en', 'en', 'en'] | True |
QueueTestCase.test_empty_votes_serialized_correctly | (self) | Do we dequeue the right song from the party? Does that song get properly removed? | Do we dequeue the right song from the party? Does that song get properly removed? | def test_empty_votes_serialized_correctly(self):
""" Do we dequeue the right song from the party? Does that song get properly removed? """
self.party.enqueue_song(self.user, 't123')
self.party.save(self.redis)
p = Party.get(self.redis, self.party.id)
self.assertEquals(p.queue[0].downvotes, set([])) | [
"def",
"test_empty_votes_serialized_correctly",
"(",
"self",
")",
":",
"self",
".",
"party",
".",
"enqueue_song",
"(",
"self",
".",
"user",
",",
"'t123'",
")",
"self",
".",
"party",
".",
"save",
"(",
"self",
".",
"redis",
")",
"p",
"=",
"Party",
".",
"... | [
63,
2
] | [
68,
52
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the mochad component. | Set up the mochad component. | def setup(hass, config):
"""Set up the mochad component."""
conf = config[DOMAIN]
host = conf.get(CONF_HOST)
port = conf.get(CONF_PORT)
try:
mochad_controller = MochadCtrl(host, port)
except exceptions.ConfigurationError:
_LOGGER.exception()
return False
def stop_mo... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"host",
"=",
"conf",
".",
"get",
"(",
"CONF_HOST",
")",
"port",
"=",
"conf",
".",
"get",
"(",
"CONF_PORT",
")",
"try",
":",
"mochad_controller",
"=",
"... | [
36,
0
] | [
59,
15
] | python | en | ['en', 'en', 'en'] | True |
MochadCtrl.__init__ | (self, host, port) | Initialize a PyMochad controller. | Initialize a PyMochad controller. | def __init__(self, host, port):
"""Initialize a PyMochad controller."""
super().__init__()
self._host = host
self._port = port
self.ctrl = controller.PyMochad(server=self._host, port=self._port) | [
"def",
"__init__",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_host",
"=",
"host",
"self",
".",
"_port",
"=",
"port",
"self",
".",
"ctrl",
"=",
"controller",
".",
"PyMochad",
"(",
... | [
65,
4
] | [
71,
75
] | python | en | ['en', 'en', 'en'] | True |
MochadCtrl.host | (self) | Return the server where mochad is running. | Return the server where mochad is running. | def host(self):
"""Return the server where mochad is running."""
return self._host | [
"def",
"host",
"(",
"self",
")",
":",
"return",
"self",
".",
"_host"
] | [
74,
4
] | [
76,
25
] | python | en | ['en', 'no', 'en'] | True |
MochadCtrl.port | (self) | Return the port mochad is running on. | Return the port mochad is running on. | def port(self):
"""Return the port mochad is running on."""
return self._port | [
"def",
"port",
"(",
"self",
")",
":",
"return",
"self",
".",
"_port"
] | [
79,
4
] | [
81,
25
] | python | en | ['en', 'ja', 'en'] | True |
MochadCtrl.disconnect | (self) | Close the connection to the mochad socket. | Close the connection to the mochad socket. | def disconnect(self):
"""Close the connection to the mochad socket."""
self.ctrl.socket.close() | [
"def",
"disconnect",
"(",
"self",
")",
":",
"self",
".",
"ctrl",
".",
"socket",
".",
"close",
"(",
")"
] | [
83,
4
] | [
85,
32
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the sensors. | Set up the sensors. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the sensors."""
if discovery_info is None:
return
name = hass.data[DOMAIN]["name"]
state_proxy = hass.data[DOMAIN]["state_proxy"]
sensors = [
ValloxProfileSensor(
name=f"{na... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"name",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"\"... | [
21,
0
] | [
95,
56
] | python | en | ['en', 'bg', 'en'] | True |
ValloxSensor.__init__ | (
self, name, state_proxy, metric_key, device_class, unit_of_measurement, icon
) | Initialize the Vallox sensor. | Initialize the Vallox sensor. | def __init__(
self, name, state_proxy, metric_key, device_class, unit_of_measurement, icon
) -> None:
"""Initialize the Vallox sensor."""
self._name = name
self._state_proxy = state_proxy
self._metric_key = metric_key
self._device_class = device_class
self._un... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"state_proxy",
",",
"metric_key",
",",
"device_class",
",",
"unit_of_measurement",
",",
"icon",
")",
"->",
"None",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state_proxy",
"=",
"state_proxy",
"s... | [
101,
4
] | [
112,
26
] | python | en | ['en', 'sq', 'en'] | True |
ValloxSensor.should_poll | (self) | Do not poll the device. | Do not poll the device. | def should_poll(self):
"""Do not poll the device."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
115,
4
] | [
117,
20
] | python | en | ['en', 'en', 'en'] | True |
ValloxSensor.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
120,
4
] | [
122,
25
] | python | en | ['en', 'ig', 'en'] | True |
ValloxSensor.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"
] | [
125,
4
] | [
127,
40
] | python | en | ['en', 'la', 'en'] | True |
ValloxSensor.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
130,
4
] | [
132,
33
] | python | en | ['en', 'en', 'en'] | True |
ValloxSensor.icon | (self) | Return the icon. | Return the icon. | def icon(self):
"""Return the icon."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
135,
4
] | [
137,
25
] | python | en | ['en', 'sr', 'en'] | True |
ValloxSensor.available | (self) | Return true when state is known. | Return true when state is known. | def available(self):
"""Return true when state is known."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
140,
4
] | [
142,
30
] | python | en | ['en', 'de', 'en'] | True |
ValloxSensor.state | (self) | Return the state. | Return the state. | def state(self):
"""Return the state."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
145,
4
] | [
147,
26
] | python | en | ['en', 'en', 'en'] | True |
ValloxSensor.async_added_to_hass | (self) | Call to update. | Call to update. | async def async_added_to_hass(self):
"""Call to update."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_VALLOX_STATE_UPDATE, self._update_callback
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_VALLOX_STATE_UPDATE",
",",
"self",
".",
"_update_callback",
")",
")"
] | [
149,
4
] | [
155,
9
] | python | en | ['en', 'en', 'en'] | True |
ValloxSensor._update_callback | (self) | Call update method. | Call update method. | def _update_callback(self):
"""Call update method."""
self.async_schedule_update_ha_state(True) | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"async_schedule_update_ha_state",
"(",
"True",
")"
] | [
158,
4
] | [
160,
49
] | python | en | ['en', 'sn', 'en'] | True |
ValloxSensor.async_update | (self) | Fetch state from the ventilation unit. | Fetch state from the ventilation unit. | async def async_update(self):
"""Fetch state from the ventilation unit."""
try:
self._state = self._state_proxy.fetch_metric(self._metric_key)
self._available = True
except (OSError, KeyError) as err:
self._available = False
_LOGGER.error("Error u... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_state_proxy",
".",
"fetch_metric",
"(",
"self",
".",
"_metric_key",
")",
"self",
".",
"_available",
"=",
"True",
"except",
"(",
"OSError",
",",
... | [
162,
4
] | [
170,
59
] | python | en | ['en', 'en', 'en'] | True |
ValloxFanSpeedSensor.async_update | (self) | Fetch state from the ventilation unit. | Fetch state from the ventilation unit. | async def async_update(self):
"""Fetch state from the ventilation unit."""
try:
# If device is in regular operation, continue.
if self._state_proxy.fetch_metric(METRIC_KEY_MODE) == 0:
await super().async_update()
else:
# Report zero per... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"# If device is in regular operation, continue.",
"if",
"self",
".",
"_state_proxy",
".",
"fetch_metric",
"(",
"METRIC_KEY_MODE",
")",
"==",
"0",
":",
"await",
"super",
"(",
")",
".",
"async_upda... | [
183,
4
] | [
196,
59
] | python | en | ['en', 'en', 'en'] | True |
ValloxProfileSensor.__init__ | (
self, name, state_proxy, device_class, unit_of_measurement, icon
) | Initialize the Vallox sensor. | Initialize the Vallox sensor. | def __init__(
self, name, state_proxy, device_class, unit_of_measurement, icon
) -> None:
"""Initialize the Vallox sensor."""
super().__init__(
name, state_proxy, None, device_class, unit_of_measurement, icon
) | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"state_proxy",
",",
"device_class",
",",
"unit_of_measurement",
",",
"icon",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"name",
",",
"state_proxy",
",",
"None",
",",
"device_class",
... | [
202,
4
] | [
208,
9
] | python | en | ['en', 'sq', 'en'] | True |
ValloxProfileSensor.async_update | (self) | Fetch state from the ventilation unit. | Fetch state from the ventilation unit. | async def async_update(self):
"""Fetch state from the ventilation unit."""
try:
self._state = self._state_proxy.get_profile()
self._available = True
except OSError as err:
self._available = False
_LOGGER.error("Error updating sensor: %s", err) | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_state_proxy",
".",
"get_profile",
"(",
")",
"self",
".",
"_available",
"=",
"True",
"except",
"OSError",
"as",
"err",
":",
"self",
".",
"_avai... | [
210,
4
] | [
218,
59
] | python | en | ['en', 'en', 'en'] | True |
ValloxFilterRemainingSensor.async_update | (self) | Fetch state from the ventilation unit. | Fetch state from the ventilation unit. | async def async_update(self):
"""Fetch state from the ventilation unit."""
try:
days_remaining = int(self._state_proxy.fetch_metric(self._metric_key))
days_remaining_delta = timedelta(days=days_remaining)
# Since only a delta of days is received from the device, fix ... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"try",
":",
"days_remaining",
"=",
"int",
"(",
"self",
".",
"_state_proxy",
".",
"fetch_metric",
"(",
"self",
".",
"_metric_key",
")",
")",
"days_remaining_delta",
"=",
"timedelta",
"(",
"days",
"=",
"... | [
224,
4
] | [
239,
59
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_import | (self, import_config) | Import a config entry from configuration.yaml. | Import a config entry from configuration.yaml. | async def async_step_import(self, import_config):
"""Import a config entry from configuration.yaml."""
return await self.async_step_user(import_config) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_config",
")",
":",
"return",
"await",
"self",
".",
"async_step_user",
"(",
"import_config",
")"
] | [
25,
4
] | [
27,
56
] | python | en | ['en', 'en', 'en'] | True |
ConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
errors = {}
if user_input is not None:
try:
await validate_projector(
self.hass, user_input[CONF_HOST], user_input[CONF_PORT]
)
except Cann... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"try",
":",
"await",
"validate_projector",
"(",
"self",
".",
"hass",
",",
"user_input",
"[",
... | [
29,
4
] | [
45,
9
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up an Arlo IP Camera. | Set up an Arlo IP Camera. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up an Arlo IP Camera."""
arlo = hass.data[DATA_ARLO]
cameras = []
for camera in arlo.cameras:
cameras.append(ArloCam(hass, camera, config))
add_entities(cameras) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"arlo",
"=",
"hass",
".",
"data",
"[",
"DATA_ARLO",
"]",
"cameras",
"=",
"[",
"]",
"for",
"camera",
"in",
"arlo",
".",
"cameras",
":... | [
39,
0
] | [
47,
25
] | python | en | ['en', 'su', 'en'] | True |
ArloCam.__init__ | (self, hass, camera, device_info) | Initialize an Arlo camera. | Initialize an Arlo camera. | def __init__(self, hass, camera, device_info):
"""Initialize an Arlo camera."""
super().__init__()
self._camera = camera
self._name = self._camera.name
self._motion_status = False
self._ffmpeg = hass.data[DATA_FFMPEG]
self._ffmpeg_arguments = device_info.get(CONF_... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"camera",
",",
"device_info",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_camera",
"=",
"camera",
"self",
".",
"_name",
"=",
"self",
".",
"_camera",
".",
"name",
"self",
"... | [
53,
4
] | [
62,
23
] | python | en | ['en', 'zh-Latn', 'it'] | False |
ArloCam.camera_image | (self) | Return a still image response from the camera. | Return a still image response from the camera. | def camera_image(self):
"""Return a still image response from the camera."""
return self._camera.last_image_from_cache | [
"def",
"camera_image",
"(",
"self",
")",
":",
"return",
"self",
".",
"_camera",
".",
"last_image_from_cache"
] | [
64,
4
] | [
66,
49
] | python | en | ['en', 'en', 'en'] | True |
ArloCam.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_ARLO, self.async_write_ha_state
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_UPDATE_ARLO",
",",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
68,
4
] | [
74,
9
] | python | en | ['en', 'no', 'en'] | False |
ArloCam.handle_async_mjpeg_stream | (self, request) | Generate an HTTP MJPEG stream from the camera. | Generate an HTTP MJPEG stream from the camera. | async def handle_async_mjpeg_stream(self, request):
"""Generate an HTTP MJPEG stream from the camera."""
video = await self.hass.async_add_executor_job(
getattr, self._camera, "last_video"
)
if not video:
error_msg = (
f"Video not found for {self.... | [
"async",
"def",
"handle_async_mjpeg_stream",
"(",
"self",
",",
"request",
")",
":",
"video",
"=",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"getattr",
",",
"self",
".",
"_camera",
",",
"\"last_video\"",
")",
"if",
"not",
"video",
":",... | [
76,
4
] | [
102,
32
] | python | en | ['en', 'en', 'en'] | True |
ArloCam.name | (self) | Return the name of this camera. | Return the name of this camera. | def name(self):
"""Return the name of this camera."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
105,
4
] | [
107,
25
] | python | en | ['en', 'en', 'en'] | True |
ArloCam.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {
name: value
for name, value in (
(ATTR_BATTERY_LEVEL, self._camera.battery_level),
(ATTR_BRIGHTNESS, self._camera.brightness),
(ATTR_FLIPPED, self._camer... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"name",
":",
"value",
"for",
"name",
",",
"value",
"in",
"(",
"(",
"ATTR_BATTERY_LEVEL",
",",
"self",
".",
"_camera",
".",
"battery_level",
")",
",",
"(",
"ATTR_BRIGHTNESS",
",",
"self... | [
110,
4
] | [
128,
9
] | python | en | ['en', 'en', 'en'] | True |
ArloCam.model | (self) | Return the camera model. | Return the camera model. | def model(self):
"""Return the camera model."""
return self._camera.model_id | [
"def",
"model",
"(",
"self",
")",
":",
"return",
"self",
".",
"_camera",
".",
"model_id"
] | [
131,
4
] | [
133,
36
] | python | en | ['en', 'co', 'en'] | True |
ArloCam.brand | (self) | Return the camera brand. | Return the camera brand. | def brand(self):
"""Return the camera brand."""
return DEFAULT_BRAND | [
"def",
"brand",
"(",
"self",
")",
":",
"return",
"DEFAULT_BRAND"
] | [
136,
4
] | [
138,
28
] | python | en | ['en', 'bs', 'en'] | True |
ArloCam.motion_detection_enabled | (self) | Return the camera motion detection status. | Return the camera motion detection status. | def motion_detection_enabled(self):
"""Return the camera motion detection status."""
return self._motion_status | [
"def",
"motion_detection_enabled",
"(",
"self",
")",
":",
"return",
"self",
".",
"_motion_status"
] | [
141,
4
] | [
143,
34
] | python | en | ['en', 'en', 'en'] | True |
ArloCam.set_base_station_mode | (self, mode) | Set the mode in the base station. | Set the mode in the base station. | def set_base_station_mode(self, mode):
"""Set the mode in the base station."""
# Get the list of base stations identified by library
base_stations = self.hass.data[DATA_ARLO].base_stations
# Some Arlo cameras does not have base station
# So check if there is base station detecte... | [
"def",
"set_base_station_mode",
"(",
"self",
",",
"mode",
")",
":",
"# Get the list of base stations identified by library",
"base_stations",
"=",
"self",
".",
"hass",
".",
"data",
"[",
"DATA_ARLO",
"]",
".",
"base_stations",
"# Some Arlo cameras does not have base station"... | [
145,
4
] | [
156,
44
] | python | en | ['en', 'en', 'en'] | True |
ArloCam.enable_motion_detection | (self) | Enable the Motion detection in base station (Arm). | Enable the Motion detection in base station (Arm). | def enable_motion_detection(self):
"""Enable the Motion detection in base station (Arm)."""
self._motion_status = True
self.set_base_station_mode(ARLO_MODE_ARMED) | [
"def",
"enable_motion_detection",
"(",
"self",
")",
":",
"self",
".",
"_motion_status",
"=",
"True",
"self",
".",
"set_base_station_mode",
"(",
"ARLO_MODE_ARMED",
")"
] | [
158,
4
] | [
161,
51
] | python | en | ['en', 'en', 'en'] | True |
ArloCam.disable_motion_detection | (self) | Disable the motion detection in base station (Disarm). | Disable the motion detection in base station (Disarm). | def disable_motion_detection(self):
"""Disable the motion detection in base station (Disarm)."""
self._motion_status = False
self.set_base_station_mode(ARLO_MODE_DISARMED) | [
"def",
"disable_motion_detection",
"(",
"self",
")",
":",
"self",
".",
"_motion_status",
"=",
"False",
"self",
".",
"set_base_station_mode",
"(",
"ARLO_MODE_DISARMED",
")"
] | [
163,
4
] | [
166,
54
] | python | en | ['en', 'en', 'en'] | True |
storage_setup | (hass, hass_storage) | Storage setup. | Storage setup. | def storage_setup(hass, hass_storage):
"""Storage setup."""
async def _storage(items=None, config=None):
if items is None:
hass_storage[DOMAIN] = {
"key": DOMAIN,
"version": 1,
"data": {
"items": [
{... | [
"def",
"storage_setup",
"(",
"hass",
",",
"hass_storage",
")",
":",
"async",
"def",
"_storage",
"(",
"items",
"=",
"None",
",",
"config",
"=",
"None",
")",
":",
"if",
"items",
"is",
"None",
":",
"hass_storage",
"[",
"DOMAIN",
"]",
"=",
"{",
"\"key\"",
... | [
33,
0
] | [
61,
19
] | python | en | ['en', 'bs', 'en'] | False |
select_option | (hass, entity_id, option) | Set value of input_select.
This is a legacy helper method. Do not use it for new tests.
| Set value of input_select. | def select_option(hass, entity_id, option):
"""Set value of input_select.
This is a legacy helper method. Do not use it for new tests.
"""
hass.async_create_task(
hass.services.async_call(
DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION... | [
"def",
"select_option",
"(",
"hass",
",",
"entity_id",
",",
"option",
")",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SELECT_OPTION",
",",
"{",
"ATTR_ENTITY_ID",
":",
"entity_id",
",",
... | [
65,
0
] | [
76,
5
] | python | en | ['en', 'en', 'en'] | True |
select_next | (hass, entity_id) | Set next value of input_select.
This is a legacy helper method. Do not use it for new tests.
| Set next value of input_select. | def select_next(hass, entity_id):
"""Set next value of input_select.
This is a legacy helper method. Do not use it for new tests.
"""
hass.async_create_task(
hass.services.async_call(
DOMAIN, SERVICE_SELECT_NEXT, {ATTR_ENTITY_ID: entity_id}
)
) | [
"def",
"select_next",
"(",
"hass",
",",
"entity_id",
")",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SELECT_NEXT",
",",
"{",
"ATTR_ENTITY_ID",
":",
"entity_id",
"}",
")",
")"
] | [
80,
0
] | [
89,
5
] | python | en | ['en', 'su', 'en'] | True |
select_previous | (hass, entity_id) | Set previous value of input_select.
This is a legacy helper method. Do not use it for new tests.
| Set previous value of input_select. | def select_previous(hass, entity_id):
"""Set previous value of input_select.
This is a legacy helper method. Do not use it for new tests.
"""
hass.async_create_task(
hass.services.async_call(
DOMAIN, SERVICE_SELECT_PREVIOUS, {ATTR_ENTITY_ID: entity_id}
)
) | [
"def",
"select_previous",
"(",
"hass",
",",
"entity_id",
")",
":",
"hass",
".",
"async_create_task",
"(",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SELECT_PREVIOUS",
",",
"{",
"ATTR_ENTITY_ID",
":",
"entity_id",
"}",
")",
")"
] | [
93,
0
] | [
102,
5
] | python | en | ['en', 'en', 'en'] | True |
test_config | (hass) | Test config. | Test config. | async def test_config(hass):
"""Test config."""
invalid_configs = [
None,
{},
{"name with space": None},
# {'bad_options': {'options': None}},
{"bad_initial": {"options": [1, 2], "initial": 3}},
]
for cfg in invalid_configs:
assert not await async_setup_c... | [
"async",
"def",
"test_config",
"(",
"hass",
")",
":",
"invalid_configs",
"=",
"[",
"None",
",",
"{",
"}",
",",
"{",
"\"name with space\"",
":",
"None",
"}",
",",
"# {'bad_options': {'options': None}},",
"{",
"\"bad_initial\"",
":",
"{",
"\"options\"",
":",
"["... | [
105,
0
] | [
116,
75
] | python | en | ['en', 'en', 'en'] | False |
test_select_option | (hass) | Test select_option methods. | Test select_option methods. | async def test_select_option(hass):
"""Test select_option methods."""
assert await async_setup_component(
hass,
DOMAIN,
{DOMAIN: {"test_1": {"options": ["some option", "another option"]}}},
)
entity_id = "input_select.test_1"
state = hass.states.get(entity_id)
assert "so... | [
"async",
"def",
"test_select_option",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"\"test_1\"",
":",
"{",
"\"options\"",
":",
"[",
"\"some option\"",
",",
"\"another option\"",
"]... | [
119,
0
] | [
141,
42
] | python | en | ['en', 'en', 'en'] | True |
test_select_next | (hass) | Test select_next methods. | Test select_next methods. | async def test_select_next(hass):
"""Test select_next methods."""
assert await async_setup_component(
hass,
DOMAIN,
{
DOMAIN: {
"test_1": {
"options": ["first option", "middle option", "last option"],
"initial": "middle ... | [
"async",
"def",
"test_select_next",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"\"test_1\"",
":",
"{",
"\"options\"",
":",
"[",
"\"first option\"",
",",
"\"middle option\"",
",",... | [
144,
0
] | [
173,
40
] | python | en | ['en', 'en', 'en'] | True |
test_select_previous | (hass) | Test select_previous methods. | Test select_previous methods. | async def test_select_previous(hass):
"""Test select_previous methods."""
assert await async_setup_component(
hass,
DOMAIN,
{
DOMAIN: {
"test_1": {
"options": ["first option", "middle option", "last option"],
"initial": ... | [
"async",
"def",
"test_select_previous",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"\"test_1\"",
":",
"{",
"\"options\"",
":",
"[",
"\"first option\"",
",",
"\"middle option\"",
... | [
176,
0
] | [
205,
39
] | python | en | ['en', 'en', 'en'] | True |
test_config_options | (hass) | Test configuration options. | Test configuration options. | async def test_config_options(hass):
"""Test configuration options."""
count_start = len(hass.states.async_entity_ids())
test_2_options = ["Good Option", "Better Option", "Best Option"]
assert await async_setup_component(
hass,
DOMAIN,
{
DOMAIN: {
"t... | [
"async",
"def",
"test_config_options",
"(",
"hass",
")",
":",
"count_start",
"=",
"len",
"(",
"hass",
".",
"states",
".",
"async_entity_ids",
"(",
")",
")",
"test_2_options",
"=",
"[",
"\"Good Option\"",
",",
"\"Better Option\"",
",",
"\"Best Option\"",
"]",
"... | [
208,
0
] | [
245,
58
] | python | en | ['en', 'fr', 'en'] | True |
test_set_options_service | (hass) | Test set_options service. | Test set_options service. | async def test_set_options_service(hass):
"""Test set_options service."""
assert await async_setup_component(
hass,
DOMAIN,
{
DOMAIN: {
"test_1": {
"options": ["first option", "middle option", "last option"],
"initial": ... | [
"async",
"def",
"test_set_options_service",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":",
"{",
"\"test_1\"",
":",
"{",
"\"options\"",
":",
"[",
"\"first option\"",
",",
"\"middle option\""... | [
248,
0
] | [
282,
33
] | python | en | ['en', 'fr', 'en'] | True |
test_restore_state | (hass) | Ensure states are restored on startup. | Ensure states are restored on startup. | async def test_restore_state(hass):
"""Ensure states are restored on startup."""
mock_restore_cache(
hass,
(
State("input_select.s1", "last option"),
State("input_select.s2", "bad option"),
),
)
options = {"options": ["first option", "middle option", "las... | [
"async",
"def",
"test_restore_state",
"(",
"hass",
")",
":",
"mock_restore_cache",
"(",
"hass",
",",
"(",
"State",
"(",
"\"input_select.s1\"",
",",
"\"last option\"",
")",
",",
"State",
"(",
"\"input_select.s2\"",
",",
"\"bad option\"",
")",
",",
")",
",",
")"... | [
285,
0
] | [
305,
40
] | python | en | ['en', 'en', 'en'] | True |
test_initial_state_overrules_restore_state | (hass) | Ensure states are restored on startup. | Ensure states are restored on startup. | async def test_initial_state_overrules_restore_state(hass):
"""Ensure states are restored on startup."""
mock_restore_cache(
hass,
(
State("input_select.s1", "last option"),
State("input_select.s2", "bad option"),
),
)
options = {
"options": ["fir... | [
"async",
"def",
"test_initial_state_overrules_restore_state",
"(",
"hass",
")",
":",
"mock_restore_cache",
"(",
"hass",
",",
"(",
"State",
"(",
"\"input_select.s1\"",
",",
"\"last option\"",
")",
",",
"State",
"(",
"\"input_select.s2\"",
",",
"\"bad option\"",
")",
... | [
308,
0
] | [
331,
41
] | python | en | ['en', 'en', 'en'] | True |
test_input_select_context | (hass, hass_admin_user) | Test that input_select context works. | Test that input_select context works. | async def test_input_select_context(hass, hass_admin_user):
"""Test that input_select context works."""
assert await async_setup_component(
hass,
"input_select",
{
"input_select": {
"s1": {"options": ["first option", "middle option", "last option"]}
... | [
"async",
"def",
"test_input_select_context",
"(",
"hass",
",",
"hass_admin_user",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"input_select\"",
",",
"{",
"\"input_select\"",
":",
"{",
"\"s1\"",
":",
"{",
"\"options\"",
":",
"[",
"\"... | [
334,
0
] | [
360,
55
] | python | en | ['en', 'en', 'en'] | True |
test_reload | (hass, hass_admin_user, hass_read_only_user) | Test reload service. | Test reload service. | async def test_reload(hass, hass_admin_user, hass_read_only_user):
"""Test reload service."""
count_start = len(hass.states.async_entity_ids())
ent_reg = await entity_registry.async_get_registry(hass)
assert await async_setup_component(
hass,
DOMAIN,
{
DOMAIN: {
... | [
"async",
"def",
"test_reload",
"(",
"hass",
",",
"hass_admin_user",
",",
"hass_read_only_user",
")",
":",
"count_start",
"=",
"len",
"(",
"hass",
".",
"states",
".",
"async_entity_ids",
"(",
")",
")",
"ent_reg",
"=",
"await",
"entity_registry",
".",
"async_get... | [
363,
0
] | [
444,
76
] | python | en | ['en', 'da', 'en'] | True |
test_load_from_storage | (hass, storage_setup) | Test set up from storage. | Test set up from storage. | async def test_load_from_storage(hass, storage_setup):
"""Test set up from storage."""
assert await storage_setup()
state = hass.states.get(f"{DOMAIN}.from_storage")
assert state.state == "storage option 1"
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "from storage"
assert state.attributes... | [
"async",
"def",
"test_load_from_storage",
"(",
"hass",
",",
"storage_setup",
")",
":",
"assert",
"await",
"storage_setup",
"(",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"f\"{DOMAIN}.from_storage\"",
")",
"assert",
"state",
".",
"state",
"==",... | [
447,
0
] | [
453,
46
] | python | en | ['en', 'en', 'en'] | True |
test_editable_state_attribute | (hass, storage_setup) | Test editable attribute. | Test editable attribute. | async def test_editable_state_attribute(hass, storage_setup):
"""Test editable attribute."""
assert await storage_setup(
config={DOMAIN: {"from_yaml": {"options": ["yaml option", "other option"]}}}
)
state = hass.states.get(f"{DOMAIN}.from_storage")
assert state.state == "storage option 1"
... | [
"async",
"def",
"test_editable_state_attribute",
"(",
"hass",
",",
"storage_setup",
")",
":",
"assert",
"await",
"storage_setup",
"(",
"config",
"=",
"{",
"DOMAIN",
":",
"{",
"\"from_yaml\"",
":",
"{",
"\"options\"",
":",
"[",
"\"yaml option\"",
",",
"\"other op... | [
456,
0
] | [
469,
50
] | python | de | ['de', 'et', 'en'] | False |
test_ws_list | (hass, hass_ws_client, storage_setup) | Test listing via WS. | Test listing via WS. | async def test_ws_list(hass, hass_ws_client, storage_setup):
"""Test listing via WS."""
assert await storage_setup(
config={DOMAIN: {"from_yaml": {"options": ["yaml option"]}}}
)
client = await hass_ws_client(hass)
await client.send_json({"id": 6, "type": f"{DOMAIN}/list"})
resp = awai... | [
"async",
"def",
"test_ws_list",
"(",
"hass",
",",
"hass_ws_client",
",",
"storage_setup",
")",
":",
"assert",
"await",
"storage_setup",
"(",
"config",
"=",
"{",
"DOMAIN",
":",
"{",
"\"from_yaml\"",
":",
"{",
"\"options\"",
":",
"[",
"\"yaml option\"",
"]",
"... | [
472,
0
] | [
491,
59
] | python | hmn | ['nl', 'hmn', 'it'] | False |
test_ws_delete | (hass, hass_ws_client, storage_setup) | Test WS delete cleans up entity registry. | Test WS delete cleans up entity registry. | async def test_ws_delete(hass, hass_ws_client, storage_setup):
"""Test WS delete cleans up entity registry."""
assert await storage_setup()
input_id = "from_storage"
input_entity_id = f"{DOMAIN}.{input_id}"
ent_reg = await entity_registry.async_get_registry(hass)
state = hass.states.get(input_... | [
"async",
"def",
"test_ws_delete",
"(",
"hass",
",",
"hass_ws_client",
",",
"storage_setup",
")",
":",
"assert",
"await",
"storage_setup",
"(",
")",
"input_id",
"=",
"\"from_storage\"",
"input_entity_id",
"=",
"f\"{DOMAIN}.{input_id}\"",
"ent_reg",
"=",
"await",
"ent... | [
494,
0
] | [
516,
72
] | python | en | ['en', 'en', 'en'] | True |
test_update | (hass, hass_ws_client, storage_setup) | Test updating min/max updates the state. | Test updating min/max updates the state. | async def test_update(hass, hass_ws_client, storage_setup):
"""Test updating min/max updates the state."""
items = [
{
"id": "from_storage",
"name": "from storage",
"options": ["yaml update 1", "yaml update 2"],
}
]
assert await storage_setup(items)
... | [
"async",
"def",
"test_update",
"(",
"hass",
",",
"hass_ws_client",
",",
"storage_setup",
")",
":",
"items",
"=",
"[",
"{",
"\"id\"",
":",
"\"from_storage\"",
",",
"\"name\"",
":",
"\"from storage\"",
",",
"\"options\"",
":",
"[",
"\"yaml update 1\"",
",",
"\"y... | [
519,
0
] | [
565,
30
] | python | en | ['en', 'en', 'en'] | True |
test_ws_create | (hass, hass_ws_client, storage_setup) | Test create WS. | Test create WS. | async def test_ws_create(hass, hass_ws_client, storage_setup):
"""Test create WS."""
assert await storage_setup(items=[])
input_id = "new_input"
input_entity_id = f"{DOMAIN}.{input_id}"
ent_reg = await entity_registry.async_get_registry(hass)
state = hass.states.get(input_entity_id)
assert... | [
"async",
"def",
"test_ws_create",
"(",
"hass",
",",
"hass_ws_client",
",",
"storage_setup",
")",
":",
"assert",
"await",
"storage_setup",
"(",
"items",
"=",
"[",
"]",
")",
"input_id",
"=",
"\"new_input\"",
"input_entity_id",
"=",
"f\"{DOMAIN}.{input_id}\"",
"ent_r... | [
568,
0
] | [
595,
45
] | python | en | ['en', 'gd', 'en'] | True |
test_setup_no_config | (hass, hass_admin_user) | Test component setup with no config. | Test component setup with no config. | async def test_setup_no_config(hass, hass_admin_user):
"""Test component setup with no config."""
count_start = len(hass.states.async_entity_ids())
assert await async_setup_component(hass, DOMAIN, {})
with patch(
"homeassistant.config.load_yaml_config_file", autospec=True, return_value={}
)... | [
"async",
"def",
"test_setup_no_config",
"(",
"hass",
",",
"hass_admin_user",
")",
":",
"count_start",
"=",
"len",
"(",
"hass",
".",
"states",
".",
"async_entity_ids",
"(",
")",
")",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
... | [
598,
0
] | [
614,
61
] | python | en | ['en', 'pt', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Return push service. | Return push service. | def get_service(hass, config, discovery_info=None):
"""Return push service."""
name = config[CONF_NAME]
cert_file = config[CONF_CERTFILE]
topic = config[CONF_TOPIC]
sandbox = config[CONF_SANDBOX]
service = ApnsNotificationService(hass, name, topic, sandbox, cert_file)
hass.services.register... | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
"[",
"CONF_NAME",
"]",
"cert_file",
"=",
"config",
"[",
"CONF_CERTFILE",
"]",
"topic",
"=",
"config",
"[",
"CONF_TOPIC",
"]",
"sandbox",
... | [
45,
0
] | [
56,
18
] | python | en | ['en', 'hi-Latn', 'en'] | True |
_write_device | (out, device) | Write a single device to file. | Write a single device to file. | def _write_device(out, device):
"""Write a single device to file."""
attributes = []
if device.name is not None:
attributes.append(f"name: {device.name}")
if device.tracking_device_id is not None:
attributes.append(f"tracking_device_id: {device.tracking_device_id}")
if device.disable... | [
"def",
"_write_device",
"(",
"out",
",",
"device",
")",
":",
"attributes",
"=",
"[",
"]",
"if",
"device",
".",
"name",
"is",
"not",
"None",
":",
"attributes",
".",
"append",
"(",
"f\"name: {device.name}\"",
")",
"if",
"device",
".",
"tracking_device_id",
"... | [
124,
0
] | [
140,
20
] | python | en | ['it', 'mk', 'en'] | False |
ApnsDevice.__init__ | (self, push_id, name, tracking_device_id=None, disabled=False) | Initialize APNS Device. | Initialize APNS Device. | def __init__(self, push_id, name, tracking_device_id=None, disabled=False):
"""Initialize APNS Device."""
self.device_push_id = push_id
self.device_name = name
self.tracking_id = tracking_device_id
self.device_disabled = disabled | [
"def",
"__init__",
"(",
"self",
",",
"push_id",
",",
"name",
",",
"tracking_device_id",
"=",
"None",
",",
"disabled",
"=",
"False",
")",
":",
"self",
".",
"device_push_id",
"=",
"push_id",
"self",
".",
"device_name",
"=",
"name",
"self",
".",
"tracking_id"... | [
67,
4
] | [
72,
39
] | python | en | ['en', 'pl', 'it'] | False |
ApnsDevice.push_id | (self) | Return the APNS id for the device. | Return the APNS id for the device. | def push_id(self):
"""Return the APNS id for the device."""
return self.device_push_id | [
"def",
"push_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"device_push_id"
] | [
75,
4
] | [
77,
34
] | python | en | ['en', 'en', 'en'] | True |
ApnsDevice.name | (self) | Return the friendly name for the device. | Return the friendly name for the device. | def name(self):
"""Return the friendly name for the device."""
return self.device_name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"device_name"
] | [
80,
4
] | [
82,
31
] | python | en | ['en', 'en', 'en'] | True |
ApnsDevice.tracking_device_id | (self) |
Return the device Id.
The id of a device that is tracked by the device
tracking component.
|
Return the device Id. | def tracking_device_id(self):
"""
Return the device Id.
The id of a device that is tracked by the device
tracking component.
"""
return self.tracking_id | [
"def",
"tracking_device_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"tracking_id"
] | [
85,
4
] | [
92,
31
] | python | en | ['en', 'error', 'th'] | False |
ApnsDevice.full_tracking_device_id | (self) |
Return the fully qualified device id.
The full id of a device that is tracked by the device
tracking component.
|
Return the fully qualified device id. | def full_tracking_device_id(self):
"""
Return the fully qualified device id.
The full id of a device that is tracked by the device
tracking component.
"""
return f"{DEVICE_TRACKER_DOMAIN}.{self.tracking_id}" | [
"def",
"full_tracking_device_id",
"(",
"self",
")",
":",
"return",
"f\"{DEVICE_TRACKER_DOMAIN}.{self.tracking_id}\""
] | [
95,
4
] | [
102,
60
] | python | en | ['en', 'error', 'th'] | False |
ApnsDevice.disabled | (self) | Return the state of the service. | Return the state of the service. | def disabled(self):
"""Return the state of the service."""
return self.device_disabled | [
"def",
"disabled",
"(",
"self",
")",
":",
"return",
"self",
".",
"device_disabled"
] | [
105,
4
] | [
107,
35
] | python | en | ['en', 'en', 'en'] | True |
ApnsDevice.disable | (self) | Disable the device from receiving notifications. | Disable the device from receiving notifications. | def disable(self):
"""Disable the device from receiving notifications."""
self.device_disabled = True | [
"def",
"disable",
"(",
"self",
")",
":",
"self",
".",
"device_disabled",
"=",
"True"
] | [
109,
4
] | [
111,
35
] | python | en | ['en', 'en', 'en'] | True |
ApnsDevice.__eq__ | (self, other) | Return the comparison. | Return the comparison. | def __eq__(self, other):
"""Return the comparison."""
if isinstance(other, self.__class__):
return self.push_id == other.push_id and self.name == other.name
return NotImplemented | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"self",
".",
"__class__",
")",
":",
"return",
"self",
".",
"push_id",
"==",
"other",
".",
"push_id",
"and",
"self",
".",
"name",
"==",
"other",
".",
"name",
... | [
113,
4
] | [
117,
29
] | python | en | ['en', 'it', 'en'] | True |
ApnsDevice.__ne__ | (self, other) | Return the comparison. | Return the comparison. | def __ne__(self, other):
"""Return the comparison."""
return not self.__eq__(other) | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"return",
"not",
"self",
".",
"__eq__",
"(",
"other",
")"
] | [
119,
4
] | [
121,
37
] | python | en | ['en', 'it', 'en'] | True |
ApnsNotificationService.__init__ | (self, hass, app_name, topic, sandbox, cert_file) | Initialize APNS application. | Initialize APNS application. | def __init__(self, hass, app_name, topic, sandbox, cert_file):
"""Initialize APNS application."""
self.hass = hass
self.app_name = app_name
self.sandbox = sandbox
self.certificate = cert_file
self.yaml_path = hass.config.path(f"{app_name}_{APNS_DEVICES}")
self.dev... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"app_name",
",",
"topic",
",",
"sandbox",
",",
"cert_file",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"app_name",
"=",
"app_name",
"self",
".",
"sandbox",
"=",
"sandbox",
"self",
".",
"... | [
146,
4
] | [
175,
82
] | python | en | ['en', 'fr', 'en'] | True |
ApnsNotificationService.device_state_changed_listener | (self, entity_id, from_s, to_s) |
Listen for state change.
Track device state change if a device has a tracking id specified.
|
Listen for state change. | def device_state_changed_listener(self, entity_id, from_s, to_s):
"""
Listen for state change.
Track device state change if a device has a tracking id specified.
"""
self.device_states[entity_id] = str(to_s.state) | [
"def",
"device_state_changed_listener",
"(",
"self",
",",
"entity_id",
",",
"from_s",
",",
"to_s",
")",
":",
"self",
".",
"device_states",
"[",
"entity_id",
"]",
"=",
"str",
"(",
"to_s",
".",
"state",
")"
] | [
177,
4
] | [
183,
55
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.