Code styling tweaks to the tests - Part 1 ()

pull/86296/head
Franck Nijhof 2023-01-20 13:52:46 +01:00 committed by GitHub
parent 79b52a2b41
commit 24fdd588fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
50 changed files with 552 additions and 251 deletions

View File

@ -301,7 +301,10 @@ async def async_test_home_assistant(event_loop, load_registries=True):
hass.config_entries = config_entries.ConfigEntries(
hass,
{
"_": "Not empty or else some bad checks for hass config in discovery.py breaks"
"_": (
"Not empty or else some bad checks for hass config in discovery.py"
" breaks"
)
},
)

View File

@ -44,9 +44,11 @@ async def test_connection_error(
) -> None:
"""Test we show user form on AdGuard Home connection error."""
aioclient_mock.get(
f"{'https' if FIXTURE_USER_INPUT[CONF_SSL] else 'http'}"
f"://{FIXTURE_USER_INPUT[CONF_HOST]}"
f":{FIXTURE_USER_INPUT[CONF_PORT]}/control/status",
(
f"{'https' if FIXTURE_USER_INPUT[CONF_SSL] else 'http'}"
f"://{FIXTURE_USER_INPUT[CONF_HOST]}"
f":{FIXTURE_USER_INPUT[CONF_PORT]}/control/status"
),
exc=aiohttp.ClientError,
)
@ -65,9 +67,11 @@ async def test_full_flow_implementation(
) -> None:
"""Test registering an integration and finishing flow works."""
aioclient_mock.get(
f"{'https' if FIXTURE_USER_INPUT[CONF_SSL] else 'http'}"
f"://{FIXTURE_USER_INPUT[CONF_HOST]}"
f":{FIXTURE_USER_INPUT[CONF_PORT]}/control/status",
(
f"{'https' if FIXTURE_USER_INPUT[CONF_SSL] else 'http'}"
f"://{FIXTURE_USER_INPUT[CONF_HOST]}"
f":{FIXTURE_USER_INPUT[CONF_PORT]}/control/status"
),
json={"version": "v0.99.0"},
headers={"Content-Type": CONTENT_TYPE_JSON},
)

View File

@ -212,7 +212,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_triggered - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_triggered "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -230,7 +234,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_disarmed - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_disarmed "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -248,7 +256,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_armed_home - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_armed_home "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -266,7 +278,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_armed_away - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_armed_away "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -284,7 +300,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_armed_night - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_armed_night "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -302,7 +322,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_armed_vacation - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_armed_vacation "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -320,7 +344,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_armed_custom_bypass - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_armed_custom_bypass "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},

View File

@ -232,9 +232,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"triggered - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"triggered "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -251,9 +254,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"disarmed - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"disarmed "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -270,9 +276,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"armed_home - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"armed_home "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -289,9 +298,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"armed_away - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"armed_away "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -308,9 +320,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"armed_night - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"armed_night "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -327,9 +342,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"armed_vacation - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"armed_vacation "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -344,7 +362,8 @@ async def test_if_fires_on_state_change(hass, calls):
assert len(calls) == 1
assert (
calls[0].data["some"]
== "triggered - device - alarm_control_panel.entity - pending - triggered - None"
== "triggered - device - alarm_control_panel.entity - pending - triggered -"
" None"
)
# Fake that the entity is disarmed.
@ -353,7 +372,8 @@ async def test_if_fires_on_state_change(hass, calls):
assert len(calls) == 2
assert (
calls[1].data["some"]
== "disarmed - device - alarm_control_panel.entity - triggered - disarmed - None"
== "disarmed - device - alarm_control_panel.entity - triggered - disarmed -"
" None"
)
# Fake that the entity is armed home.
@ -362,7 +382,8 @@ async def test_if_fires_on_state_change(hass, calls):
assert len(calls) == 3
assert (
calls[2].data["some"]
== "armed_home - device - alarm_control_panel.entity - disarmed - armed_home - None"
== "armed_home - device - alarm_control_panel.entity - disarmed - armed_home -"
" None"
)
# Fake that the entity is armed away.
@ -371,7 +392,8 @@ async def test_if_fires_on_state_change(hass, calls):
assert len(calls) == 4
assert (
calls[3].data["some"]
== "armed_away - device - alarm_control_panel.entity - armed_home - armed_away - None"
== "armed_away - device - alarm_control_panel.entity - armed_home - armed_away"
" - None"
)
# Fake that the entity is armed night.
@ -380,7 +402,8 @@ async def test_if_fires_on_state_change(hass, calls):
assert len(calls) == 5
assert (
calls[4].data["some"]
== "armed_night - device - alarm_control_panel.entity - armed_away - armed_night - None"
== "armed_night - device - alarm_control_panel.entity - armed_away -"
" armed_night - None"
)
# Fake that the entity is armed vacation.
@ -389,7 +412,8 @@ async def test_if_fires_on_state_change(hass, calls):
assert len(calls) == 6
assert (
calls[5].data["some"]
== "armed_vacation - device - alarm_control_panel.entity - armed_night - armed_vacation - None"
== "armed_vacation - device - alarm_control_panel.entity - armed_night -"
" armed_vacation - None"
)

View File

@ -114,6 +114,6 @@ async def test_serialize_discovery_recovers(hass, caplog):
assert "Alexa.PowerController" not in interfaces
assert (
f"Error serializing Alexa.PowerController discovery"
"Error serializing Alexa.PowerController discovery"
f" for {hass.states.get('switch.bla')}"
) in caplog.text

View File

@ -233,9 +233,9 @@ async def test_send_usage_with_supervisor(hass, caplog, aioclient_mock):
):
await analytics.send_analytics()
assert (
"'addons': [{'slug': 'test_addon', 'protected': True, 'version': '1', 'auto_update': False}]"
in caplog.text
)
"'addons': [{'slug': 'test_addon', 'protected': True, 'version': '1',"
" 'auto_update': False}]"
) in caplog.text
assert "'addon_count':" not in caplog.text
@ -251,9 +251,9 @@ async def test_send_statistics(hass, caplog, aioclient_mock):
with patch("homeassistant.components.analytics.analytics.HA_VERSION", MOCK_VERSION):
await analytics.send_analytics()
assert (
"'state_count': 0, 'automation_count': 0, 'integration_count': 1, 'user_count': 0"
in caplog.text
)
"'state_count': 0, 'automation_count': 0, 'integration_count': 1,"
" 'user_count': 0"
) in caplog.text
assert "'integrations':" not in caplog.text
@ -406,9 +406,9 @@ async def test_dev_url_error(hass, aioclient_mock, caplog):
payload = aioclient_mock.mock_calls[0]
assert str(payload[1]) == ANALYTICS_ENDPOINT_URL_DEV
assert (
f"Sending analytics failed with statuscode 400 from {ANALYTICS_ENDPOINT_URL_DEV}"
in caplog.text
)
"Sending analytics failed with statuscode 400 from"
f" {ANALYTICS_ENDPOINT_URL_DEV}"
) in caplog.text
async def test_nightly_endpoint(hass, aioclient_mock):

View File

@ -78,8 +78,14 @@ ADB_PATCH_KEY = "patch_key"
TEST_ENTITY_NAME = "entity_name"
MSG_RECONNECT = {
patchers.KEY_PYTHON: f"ADB connection to {HOST}:{DEFAULT_PORT} successfully established",
patchers.KEY_SERVER: f"ADB connection to {HOST}:{DEFAULT_PORT} via ADB server {patchers.ADB_SERVER_HOST}:{DEFAULT_ADB_SERVER_PORT} successfully established",
patchers.KEY_PYTHON: (
f"ADB connection to {HOST}:{DEFAULT_PORT} successfully established"
),
patchers.KEY_SERVER: (
f"ADB connection to {HOST}:{DEFAULT_PORT} via ADB server"
f" {patchers.ADB_SERVER_HOST}:{DEFAULT_ADB_SERVER_PORT} successfully"
" established"
),
}
SHELL_RESPONSE_OFF = ""

View File

@ -140,8 +140,8 @@ async def test_source_list(player, state):
@pytest.mark.parametrize(
"mode",
[
("STEREO"),
("DOLBY_PL"),
"STEREO",
"DOLBY_PL",
],
)
async def test_select_sound_mode(player, state, mode):

View File

@ -191,7 +191,9 @@ async def test_doorbell_update_via_pubnub(hass):
"data": {
"result": {
"created_at": "2021-03-16T01:07:08.817Z",
"secure_url": "https://dyu7azbnaoi74.cloudfront.net/zip/images/zip.jpeg",
"secure_url": (
"https://dyu7azbnaoi74.cloudfront.net/zip/images/zip.jpeg"
),
},
},
},
@ -220,7 +222,9 @@ async def test_doorbell_update_via_pubnub(hass):
"format": "jpg",
"created_at": "2021-03-16T02:36:26.886Z",
"bytes": 14061,
"secure_url": "https://dyu7azbnaoi74.cloudfront.net/images/1f8.jpeg",
"secure_url": (
"https://dyu7azbnaoi74.cloudfront.net/images/1f8.jpeg"
),
"url": "https://dyu7azbnaoi74.cloudfront.net/images/1f8.jpeg",
"etag": "09e839331c4ea59eef28081f2caa0e90",
},

View File

@ -75,7 +75,7 @@ async def test_diagnostics(hass, hass_client):
"doorbell_low_battery": False,
"ip_addr": "10.0.1.11",
"link_quality": 54,
"load_average": "0.50 0.47 0.35 " "1/154 9345",
"load_average": "0.50 0.47 0.35 1/154 9345",
"signal_level": -56,
"steady_ac_in": 22.196405,
"temperature": 28.25,

View File

@ -95,9 +95,9 @@ async def test_unlock_throws_august_api_http_error(hass):
await hass.services.async_call(LOCK_DOMAIN, SERVICE_UNLOCK, data, blocking=True)
except HomeAssistantError as err:
last_err = err
assert (
str(last_err)
== "A6697750D607098BAE8D6BAA11EF8063 Name: This should bubble up as its user consumable"
assert str(last_err) == (
"A6697750D607098BAE8D6BAA11EF8063 Name: This should bubble up as its user"
" consumable"
)
@ -121,9 +121,9 @@ async def test_lock_throws_august_api_http_error(hass):
await hass.services.async_call(LOCK_DOMAIN, SERVICE_LOCK, data, blocking=True)
except HomeAssistantError as err:
last_err = err
assert (
str(last_err)
== "A6697750D607098BAE8D6BAA11EF8063 Name: This should bubble up as its user consumable"
assert str(last_err) == (
"A6697750D607098BAE8D6BAA11EF8063 Name: This should bubble up as its user"
" consumable"
)

View File

@ -121,8 +121,9 @@ async def test_service_specify_data(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "{{ trigger.platform }} - "
"{{ trigger.event.event_type }}"
"some": (
"{{ trigger.platform }} - {{ trigger.event.event_type }}"
)
},
},
}
@ -1401,9 +1402,9 @@ async def test_automation_bad_config_validation(
# Check we get the expected error message
assert (
f"Automation with alias 'bad_automation' {problem} and has been disabled: {details}"
in caplog.text
)
f"Automation with alias 'bad_automation' {problem} and has been disabled:"
f" {details}"
) in caplog.text
# Make sure one bad automation does not prevent other automations from setting up
assert hass.states.async_entity_ids("automation") == ["automation.good_automation"]
@ -1969,7 +1970,10 @@ async def test_blueprint_automation(hass, calls):
"a_number": 5,
},
"Blueprint 'Call service based on event' generated invalid automation",
"value should be a string for dictionary value @ data['action'][0]['service']",
(
"value should be a string for dictionary value @"
" data['action'][0]['service']"
),
),
),
)
@ -2016,10 +2020,10 @@ async def test_blueprint_automation_fails_substitution(hass, caplog):
},
)
assert (
"Blueprint 'Call service based on event' failed to generate automation with inputs "
"{'trigger_event': 'test_event', 'service_to_call': 'test.automation', 'a_number': 5}:"
" No substitution found for input blah" in caplog.text
)
"Blueprint 'Call service based on event' failed to generate automation with"
" inputs {'trigger_event': 'test_event', 'service_to_call': 'test.automation',"
" 'a_number': 5}: No substitution found for input blah"
) in caplog.text
async def test_trigger_service(hass, calls):
@ -2204,7 +2208,10 @@ async def test_recursive_automation_starting_script(
"sequence": [
{"event": "trigger_automation"},
{
"wait_template": f"{{{{ float(states('sensor.test'), 0) >= {automation_runs} }}}}"
"wait_template": (
"{{ float(states('sensor.test'), 0) >="
f" {automation_runs} }}}}"
)
},
{"service": "script.script1"},
{"service": "test.script_done"},

View File

@ -259,7 +259,10 @@ async def test_reauth_flow_update_configuration(hass, config_entry):
"st": "urn:axis-com:service:BasicService:1",
"usn": f"uuid:Upnp-BasicDevice-1_0-{MAC}::urn:axis-com:service:BasicService:1",
"ext": "",
"server": "Linux/4.14.173-axis8, UPnP/1.0, Portable SDK for UPnP devices/1.8.7",
"server": (
"Linux/4.14.173-axis8, UPnP/1.0, Portable SDK for UPnP"
" devices/1.8.7"
),
"deviceType": "urn:schemas-upnp-org:device:Basic:1",
"friendlyName": f"AXIS M1065-LW - {MAC}",
"manufacturer": "AXIS",

View File

@ -323,7 +323,10 @@ async def test_device_support_mqtt(hass, mqtt_mock, config_entry):
mqtt_mock.async_subscribe.assert_called_with(f"{MAC}/#", mock.ANY, 0, "utf-8")
topic = f"{MAC}/event/tns:onvif/Device/tns:axis/Sensor/PIR/$source/sensor/0"
message = b'{"timestamp": 1590258472044, "topic": "onvif:Device/axis:Sensor/PIR", "message": {"source": {"sensor": "0"}, "key": {}, "data": {"state": "1"}}}'
message = (
b'{"timestamp": 1590258472044, "topic": "onvif:Device/axis:Sensor/PIR",'
b' "message": {"source": {"sensor": "0"}, "key": {}, "data": {"state": "1"}}}'
)
assert len(hass.states.async_entity_ids(BINARY_SENSOR_DOMAIN)) == 0
async_fire_mqtt_message(hass, topic, message)

View File

@ -16,9 +16,9 @@ async def test_setup_with_hassio(
"""Test the setup of the integration with hassio enabled."""
assert not await setup_backup_integration(hass=hass, with_hassio=True)
assert (
"The backup integration is not supported on this installation method, please remove it from your configuration"
in caplog.text
)
"The backup integration is not supported on this installation method, please"
" remove it from your configuration"
) in caplog.text
async def test_create_service(

View File

@ -154,8 +154,8 @@ async def test_getting_backup_that_does_not_exist(
assert (
f"Removing tracked backup ({TEST_BACKUP.slug}) that "
f"does not exists on the expected path {TEST_BACKUP.path}" in caplog.text
)
f"does not exists on the expected path {TEST_BACKUP.path}"
) in caplog.text
async def test_generate_backup_when_backing_up(hass: HomeAssistant) -> None:

View File

@ -678,7 +678,10 @@ async def test_observed_entities(hass):
},
{
"platform": "template",
"value_template": "{{is_state('sensor.test_monitored1','on') and is_state('sensor.test_monitored','off')}}",
"value_template": (
"{{is_state('sensor.test_monitored1','on') and"
" is_state('sensor.test_monitored','off')}}"
),
"prob_given_true": 0.9,
"prob_given_false": 0.1,
},
@ -734,7 +737,10 @@ async def test_state_attributes_are_serializable(hass):
},
{
"platform": "template",
"value_template": "{{is_state('sensor.test_monitored1','on') and is_state('sensor.test_monitored','off')}}",
"value_template": (
"{{is_state('sensor.test_monitored1','on') and"
" is_state('sensor.test_monitored','off')}}"
),
"prob_given_true": 0.9,
"prob_given_false": 0.1,
},

View File

@ -557,9 +557,9 @@ async def test_wlightbox_on_effect(wlightbox, hass):
)
assert (
f"Turning on with effect '{feature_mock.full_name}' failed: NOT IN LIST not in effect list."
in str(info.value)
)
f"Turning on with effect '{feature_mock.full_name}' failed: "
"NOT IN LIST not in effect list."
) in str(info.value)
await hass.services.async_call(
"light",

View File

@ -36,7 +36,10 @@ COMMUNITY_POST_INPUTS = {
},
"force_brightness": {
"name": "Force turn on brightness",
"description": 'Force the brightness to the set level below, when the "on" button on the remote is pushed and lights turn on.\n',
"description": (
'Force the brightness to the set level below, when the "on" button on the'
" remote is pushed and lights turn on.\n"
),
"default": False,
"selector": {"boolean": {}},
},

View File

@ -256,10 +256,10 @@ async def test_domain_blueprints_add_blueprint(domain_bps, blueprint_1):
with patch.object(domain_bps, "_create_file") as create_file_mock:
# Should add extension when not present.
await domain_bps.async_add_blueprint(blueprint_1, "something")
assert create_file_mock.call_args[0][1] == ("something.yaml")
assert create_file_mock.call_args[0][1] == "something.yaml"
await domain_bps.async_add_blueprint(blueprint_1, "something2.yaml")
assert create_file_mock.call_args[0][1] == ("something2.yaml")
assert create_file_mock.call_args[0][1] == "something2.yaml"
# Should be in cache.
with patch.object(domain_bps, "_load_blueprint") as mock_load:

View File

@ -150,9 +150,21 @@ async def test_save_blueprint(hass, aioclient_mock, hass_ws_client):
output_yaml = write_mock.call_args[0][0]
assert output_yaml in (
# pure python dumper will quote the value after !input
"blueprint:\n name: Call service based on event\n domain: automation\n input:\n trigger_event:\n selector:\n text: {}\n service_to_call:\n a_number:\n selector:\n number:\n mode: box\n step: 1.0\n source_url: https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\ntrigger:\n platform: event\n event_type: !input 'trigger_event'\naction:\n service: !input 'service_to_call'\n entity_id: light.kitchen\n"
"blueprint:\n name: Call service based on event\n domain: automation\n "
" input:\n trigger_event:\n selector:\n text: {}\n "
" service_to_call:\n a_number:\n selector:\n number:\n "
" mode: box\n step: 1.0\n source_url:"
" https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\ntrigger:\n"
" platform: event\n event_type: !input 'trigger_event'\naction:\n "
" service: !input 'service_to_call'\n entity_id: light.kitchen\n"
# c dumper will not quote the value after !input
"blueprint:\n name: Call service based on event\n domain: automation\n input:\n trigger_event:\n selector:\n text: {}\n service_to_call:\n a_number:\n selector:\n number:\n mode: box\n step: 1.0\n source_url: https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\ntrigger:\n platform: event\n event_type: !input trigger_event\naction:\n service: !input service_to_call\n entity_id: light.kitchen\n"
"blueprint:\n name: Call service based on event\n domain: automation\n "
" input:\n trigger_event:\n selector:\n text: {}\n "
" service_to_call:\n a_number:\n selector:\n number:\n "
" mode: box\n step: 1.0\n source_url:"
" https://github.com/balloob/home-assistant-config/blob/main/blueprints/automation/motion_light.yaml\ntrigger:\n"
" platform: event\n event_type: !input trigger_event\naction:\n service:"
" !input service_to_call\n entity_id: light.kitchen\n"
)
# Make sure ita parsable and does not raise
assert len(parse_yaml(output_yaml)) > 1

View File

@ -104,10 +104,10 @@ async def test_diagnostics(
"org.bluez": {
"/org/bluez/hci0": {
"org.bluez.Adapter1": {
"Alias": "BlueZ " "5.63",
"Alias": "BlueZ 5.63",
"Discovering": False,
"Modalias": "usb:v1D6Bp0246d0540",
"Name": "BlueZ " "5.63",
"Name": "BlueZ 5.63",
},
"org.bluez.AdvertisementMonitorManager1": {
"SupportedFeatures": [],
@ -323,7 +323,7 @@ async def test_diagnostics_macos(
"address": "44:44:33:11:23:45",
"advertisement": [
"wohand",
{"1": {"__type": "<class " "'bytes'>", "repr": "b'\\x01'"}},
{"1": {"__type": "<class 'bytes'>", "repr": "b'\\x01'"}},
{},
[],
-127,
@ -331,12 +331,12 @@ async def test_diagnostics_macos(
[[]],
],
"device": {
"__type": "<class " "'bleak.backends.device.BLEDevice'>",
"repr": "BLEDevice(44:44:33:11:23:45, " "wohand)",
"__type": "<class 'bleak.backends.device.BLEDevice'>",
"repr": "BLEDevice(44:44:33:11:23:45, wohand)",
},
"connectable": True,
"manufacturer_data": {
"1": {"__type": "<class " "'bytes'>", "repr": "b'\\x01'"}
"1": {"__type": "<class 'bytes'>", "repr": "b'\\x01'"}
},
"name": "wohand",
"rssi": -127,
@ -351,7 +351,7 @@ async def test_diagnostics_macos(
"address": "44:44:33:11:23:45",
"advertisement": [
"wohand",
{"1": {"__type": "<class " "'bytes'>", "repr": "b'\\x01'"}},
{"1": {"__type": "<class 'bytes'>", "repr": "b'\\x01'"}},
{},
[],
-127,
@ -359,12 +359,12 @@ async def test_diagnostics_macos(
[[]],
],
"device": {
"__type": "<class " "'bleak.backends.device.BLEDevice'>",
"repr": "BLEDevice(44:44:33:11:23:45, " "wohand)",
"__type": "<class 'bleak.backends.device.BLEDevice'>",
"repr": "BLEDevice(44:44:33:11:23:45, wohand)",
},
"connectable": True,
"manufacturer_data": {
"1": {"__type": "<class " "'bytes'>", "repr": "b'\\x01'"}
"1": {"__type": "<class 'bytes'>", "repr": "b'\\x01'"}
},
"name": "wohand",
"rssi": -127,
@ -384,7 +384,7 @@ async def test_diagnostics_macos(
"wohand",
{
"1": {
"__type": "<class " "'bytes'>",
"__type": "<class 'bytes'>",
"repr": "b'\\x01'",
}
},
@ -515,7 +515,7 @@ async def test_diagnostics_remote_adapter(
"address": "44:44:33:11:23:45",
"advertisement": [
"wohand",
{"1": {"__type": "<class " "'bytes'>", "repr": "b'\\x01'"}},
{"1": {"__type": "<class 'bytes'>", "repr": "b'\\x01'"}},
{},
[],
-127,
@ -524,11 +524,11 @@ async def test_diagnostics_remote_adapter(
],
"connectable": False,
"device": {
"__type": "<class " "'bleak.backends.device.BLEDevice'>",
"repr": "BLEDevice(44:44:33:11:23:45, " "wohand)",
"__type": "<class 'bleak.backends.device.BLEDevice'>",
"repr": "BLEDevice(44:44:33:11:23:45, wohand)",
},
"manufacturer_data": {
"1": {"__type": "<class " "'bytes'>", "repr": "b'\\x01'"}
"1": {"__type": "<class 'bytes'>", "repr": "b'\\x01'"}
},
"name": "wohand",
"rssi": -127,
@ -543,7 +543,7 @@ async def test_diagnostics_remote_adapter(
"address": "44:44:33:11:23:45",
"advertisement": [
"wohand",
{"1": {"__type": "<class " "'bytes'>", "repr": "b'\\x01'"}},
{"1": {"__type": "<class 'bytes'>", "repr": "b'\\x01'"}},
{},
[],
-127,
@ -552,11 +552,11 @@ async def test_diagnostics_remote_adapter(
],
"connectable": True,
"device": {
"__type": "<class " "'bleak.backends.device.BLEDevice'>",
"repr": "BLEDevice(44:44:33:11:23:45, " "wohand)",
"__type": "<class 'bleak.backends.device.BLEDevice'>",
"repr": "BLEDevice(44:44:33:11:23:45, wohand)",
},
"manufacturer_data": {
"1": {"__type": "<class " "'bytes'>", "repr": "b'\\x01'"}
"1": {"__type": "<class 'bytes'>", "repr": "b'\\x01'"}
},
"name": "wohand",
"rssi": -127,
@ -600,7 +600,7 @@ async def test_diagnostics_remote_adapter(
"wohand",
{
"1": {
"__type": "<class " "'bytes'>",
"__type": "<class 'bytes'>",
"repr": "b'\\x01'",
}
},

View File

@ -492,7 +492,9 @@ async def test_discovery_match_by_name_connectable_false(
qingping_adv = generate_advertisement_data(
local_name="Qingping Motion & Light",
service_data={
"0000fdcd-0000-1000-8000-00805f9b34fb": b"H\x12\xcd\xd5`4-X\x08\x04\x01\xe8\x00\x00\x0f\x01{"
"0000fdcd-0000-1000-8000-00805f9b34fb": (
b"H\x12\xcd\xd5`4-X\x08\x04\x01\xe8\x00\x00\x0f\x01{"
)
},
)
@ -508,7 +510,9 @@ async def test_discovery_match_by_name_connectable_false(
qingping_adv_with_better_rssi = generate_advertisement_data(
local_name="Qingping Motion & Light",
service_data={
"0000fdcd-0000-1000-8000-00805f9b34fb": b"H\x12\xcd\xd5`4-X\x08\x04\x01\xe8\x00\x00\x0f\x02{"
"0000fdcd-0000-1000-8000-00805f9b34fb": (
b"H\x12\xcd\xd5`4-X\x08\x04\x01\xe8\x00\x00\x0f\x02{"
)
},
rssi=-30,
)
@ -832,7 +836,9 @@ async def test_discovery_match_by_service_data_uuid_when_format_changes(
qingping_format_adv = generate_advertisement_data(
local_name="Qingping Temp RH M",
service_data={
"0000fdcd-0000-1000-8000-00805f9b34fb": b"\x08\x16\xa7%\x144-X\x01\x04\xdb\x00\xa6\x01\x02\x01d"
"0000fdcd-0000-1000-8000-00805f9b34fb": (
b"\x08\x16\xa7%\x144-X\x01\x04\xdb\x00\xa6\x01\x02\x01d"
)
},
)
# 1st discovery should not generate a flow because the

View File

@ -29,7 +29,9 @@ TEMP_HUMI_ENCRYPTED_SERVICE_INFO = BluetoothServiceInfoBleak(
rssi=-63,
manufacturer_data={},
service_data={
"0000181e-0000-1000-8000-00805f9b34fb": b'\xfb\xa45\xe4\xd3\xc3\x12\xfb\x00\x11"3W\xd9\n\x99'
"0000181e-0000-1000-8000-00805f9b34fb": (
b'\xfb\xa45\xe4\xd3\xc3\x12\xfb\x00\x11"3W\xd9\n\x99'
)
},
service_uuids=["0000181e-0000-1000-8000-00805f9b34fb"],
source="local",
@ -45,7 +47,9 @@ PRST_SERVICE_INFO = BluetoothServiceInfoBleak(
rssi=-63,
manufacturer_data={},
service_data={
"0000181c-0000-1000-8000-00805f9b34fb": b'\x02\x14\x00\n"\x02\xdd\n\x02\x03{\x12\x02\x0c\n\x0b'
"0000181c-0000-1000-8000-00805f9b34fb": (
b'\x02\x14\x00\n"\x02\xdd\n\x02\x03{\x12\x02\x0c\n\x0b'
)
},
service_uuids=["0000181c-0000-1000-8000-00805f9b34fb"],
source="local",

View File

@ -278,7 +278,9 @@ _LOGGER = logging.getLogger(__name__)
None,
[
{
"sensor_entity": "sensor.test_device_18b2_volatile_organic_compounds",
"sensor_entity": (
"sensor.test_device_18b2_volatile_organic_compounds"
),
"friendly_name": "Test Device 18B2 Volatile Organic Compounds",
"unit_of_measurement": "µg/m³",
"state_class": "measurement",
@ -630,7 +632,9 @@ async def test_v1_sensors(
None,
[
{
"sensor_entity": "sensor.test_device_18b2_volatile_organic_compounds",
"sensor_entity": (
"sensor.test_device_18b2_volatile_organic_compounds"
),
"friendly_name": "Test Device 18B2 Volatile Organic Compounds",
"unit_of_measurement": "µg/m³",
"state_class": "measurement",

View File

@ -138,10 +138,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data": {
"some": (
"to - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }} - "
"{{ trigger.id}}"
"to - {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }} "
"- {{ trigger.id }}"
)
},
},

View File

@ -2249,7 +2249,7 @@ async def test_cast_platform_play_media_local_media(
ATTR_ENTITY_ID: entity_id,
media_player.ATTR_MEDIA_CONTENT_TYPE: "application/vnd.apple.mpegurl",
media_player.ATTR_MEDIA_CONTENT_ID: (
f"{network.get_url(hass)}" "/api/hls/bla/master_playlist.m3u8?token=bla"
f"{network.get_url(hass)}/api/hls/bla/master_playlist.m3u8?token=bla"
),
},
blocking=True,

View File

@ -173,7 +173,10 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_hvac_mode - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_hvac_mode - {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -192,7 +195,10 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_preset_mode - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_preset_mode - {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},

View File

@ -518,8 +518,10 @@ async def test_websocket_update_preferences_alexa_report_state(
client = await hass_ws_client(hass)
with patch(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_get_access_token",
(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_get_access_token"
),
), patch(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.set_authorized"
) as set_authorized_mock:
@ -540,8 +542,10 @@ async def test_websocket_update_preferences_require_relink(
client = await hass_ws_client(hass)
with patch(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_get_access_token",
(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_get_access_token"
),
side_effect=alexa_errors.RequireRelink,
), patch(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.set_authorized"
@ -564,8 +568,10 @@ async def test_websocket_update_preferences_no_token(
client = await hass_ws_client(hass)
with patch(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_get_access_token",
(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_get_access_token"
),
side_effect=alexa_errors.NoTokenAvailable,
), patch(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig.set_authorized"
@ -770,8 +776,10 @@ async def test_sync_alexa_entities_timeout(
"""Test that timeout syncing Alexa entities."""
client = await hass_ws_client(hass)
with patch(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_sync_entities",
(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_sync_entities"
),
side_effect=asyncio.TimeoutError,
):
await client.send_json({"id": 5, "type": "cloud/alexa/sync"})
@ -787,8 +795,10 @@ async def test_sync_alexa_entities_no_token(
"""Test sync Alexa entities when we have no token."""
client = await hass_ws_client(hass)
with patch(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_sync_entities",
(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_sync_entities"
),
side_effect=alexa_errors.NoTokenAvailable,
):
await client.send_json({"id": 5, "type": "cloud/alexa/sync"})
@ -804,8 +814,10 @@ async def test_enable_alexa_state_report_fail(
"""Test enable Alexa entities state reporting when no token available."""
client = await hass_ws_client(hass)
with patch(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_sync_entities",
(
"homeassistant.components.cloud.alexa_config.CloudAlexaConfig"
".async_sync_entities"
),
side_effect=alexa_errors.NoTokenAvailable,
):
await client.send_json({"id": 5, "type": "cloud/alexa/sync"})

View File

@ -144,8 +144,10 @@ async def test_update_with_json_attrs(hass: HomeAssistant) -> None:
await setup_test_entities(
hass,
{
"command": 'echo { \\"key\\": \\"some_json_value\\", \\"another_key\\":\
\\"another_json_value\\", \\"key_three\\": \\"value_three\\" }',
"command": (
'echo { \\"key\\": \\"some_json_value\\", \\"another_key\\": '
'\\"another_json_value\\", \\"key_three\\": \\"value_three\\" }'
),
"json_attributes": ["key", "another_key", "key_three"],
},
)
@ -218,8 +220,10 @@ async def test_update_with_missing_json_attrs(
await setup_test_entities(
hass,
{
"command": 'echo { \\"key\\": \\"some_json_value\\", \\"another_key\\":\
\\"another_json_value\\", \\"key_three\\": \\"value_three\\" }',
"command": (
'echo { \\"key\\": \\"some_json_value\\", \\"another_key\\": '
'\\"another_json_value\\", \\"key_three\\": \\"value_three\\" }'
),
"json_attributes": ["key", "another_key", "key_three", "missing_key"],
},
)
@ -239,8 +243,10 @@ async def test_update_with_unnecessary_json_attrs(
await setup_test_entities(
hass,
{
"command": 'echo { \\"key\\": \\"some_json_value\\", \\"another_key\\":\
\\"another_json_value\\", \\"key_three\\": \\"value_three\\" }',
"command": (
'echo { \\"key\\": \\"some_json_value\\", \\"another_key\\": '
'\\"another_json_value\\", \\"key_three\\": \\"value_three\\" }'
),
"json_attributes": ["key", "another_key"],
},
)

View File

@ -93,7 +93,9 @@ async def test_state_value(hass: HomeAssistant) -> None:
"command_on": f"echo 1 > {path}",
"command_off": f"echo 0 > {path}",
"value_template": '{{ value=="1" }}',
"icon_template": '{% if value=="1" %} mdi:on {% else %} mdi:off {% endif %}',
"icon_template": (
'{% if value=="1" %} mdi:on {% else %} mdi:off {% endif %}'
),
}
},
)
@ -142,7 +144,10 @@ async def test_state_json_value(hass: HomeAssistant) -> None:
"command_on": f"echo '{oncmd}' > {path}",
"command_off": f"echo '{offcmd}' > {path}",
"value_template": '{{ value_json.status=="ok" }}',
"icon_template": '{% if value_json.status=="ok" %} mdi:on {% else %} mdi:off {% endif %}',
"icon_template": (
'{% if value_json.status=="ok" %} mdi:on'
"{% else %} mdi:off {% endif %}"
),
}
},
)

View File

@ -929,8 +929,10 @@ async def test_options_flow_with_invalid_data(hass, client):
assert resp.status == HTTPStatus.BAD_REQUEST
data = await resp.json()
assert data == {
"message": "User input malformed: invalid is not a valid option for "
"dictionary value @ data['choices']"
"message": (
"User input malformed: invalid is not a valid option for "
"dictionary value @ data['choices']"
)
}

View File

@ -340,7 +340,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_open - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_open "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -358,7 +362,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_closed - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_closed "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -376,7 +384,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_opening - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_opening "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -394,7 +406,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_closing - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_closing "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -457,14 +473,22 @@ async def test_if_position(hass, calls, caplog, enable_custom_integrations):
"sequence": {
"service": "test.automation",
"data_template": {
"some": "is_pos_gt_45 - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_pos_gt_45 "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
"default": {
"service": "test.automation",
"data_template": {
"some": "is_pos_not_gt_45 - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_pos_not_gt_45 "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -484,7 +508,11 @@ async def test_if_position(hass, calls, caplog, enable_custom_integrations):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_pos_lt_90 - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_pos_lt_90 "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -504,7 +532,11 @@ async def test_if_position(hass, calls, caplog, enable_custom_integrations):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_pos_gt_45_lt_90 - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_pos_gt_45_lt_90 "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -586,14 +618,22 @@ async def test_if_tilt_position(hass, calls, caplog, enable_custom_integrations)
"sequence": {
"service": "test.automation",
"data_template": {
"some": "is_pos_gt_45 - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_pos_gt_45 "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
"default": {
"service": "test.automation",
"data_template": {
"some": "is_pos_not_gt_45 - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_pos_not_gt_45 "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -613,7 +653,11 @@ async def test_if_tilt_position(hass, calls, caplog, enable_custom_integrations)
"action": {
"service": "test.automation",
"data_template": {
"some": "is_pos_lt_90 - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_pos_lt_90 "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -633,7 +677,11 @@ async def test_if_tilt_position(hass, calls, caplog, enable_custom_integrations)
"action": {
"service": "test.automation",
"data_template": {
"some": "is_pos_gt_45_lt_90 - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_pos_gt_45_lt_90 "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},

View File

@ -359,9 +359,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"opened - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"opened "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -378,9 +381,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"closed - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"closed "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -397,9 +403,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"opening - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"opening "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -416,9 +425,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"closing - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"closing "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -543,9 +555,12 @@ async def test_if_fires_on_position(hass, calls, enable_custom_integrations):
"service": "test.automation",
"data_template": {
"some": (
"is_pos_gt_45 - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"is_pos_gt_45 "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -565,9 +580,12 @@ async def test_if_fires_on_position(hass, calls, enable_custom_integrations):
"service": "test.automation",
"data_template": {
"some": (
"is_pos_lt_90 - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"is_pos_lt_90 "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -588,9 +606,12 @@ async def test_if_fires_on_position(hass, calls, enable_custom_integrations):
"service": "test.automation",
"data_template": {
"some": (
"is_pos_gt_45_lt_90 - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"is_pos_gt_45_lt_90 "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -611,7 +632,10 @@ async def test_if_fires_on_position(hass, calls, enable_custom_integrations):
[calls[0].data["some"], calls[1].data["some"], calls[2].data["some"]]
) == sorted(
[
"is_pos_gt_45_lt_90 - device - cover.set_position_cover - closed - open - None",
(
"is_pos_gt_45_lt_90 - device - cover.set_position_cover - closed - open"
" - None"
),
"is_pos_lt_90 - device - cover.set_position_cover - closed - open - None",
"is_pos_gt_45 - device - cover.set_position_cover - open - closed - None",
]
@ -670,9 +694,12 @@ async def test_if_fires_on_tilt_position(hass, calls, enable_custom_integrations
"service": "test.automation",
"data_template": {
"some": (
"is_pos_gt_45 - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"is_pos_gt_45 "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -692,9 +719,12 @@ async def test_if_fires_on_tilt_position(hass, calls, enable_custom_integrations
"service": "test.automation",
"data_template": {
"some": (
"is_pos_lt_90 - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"is_pos_lt_90 "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -715,9 +745,12 @@ async def test_if_fires_on_tilt_position(hass, calls, enable_custom_integrations
"service": "test.automation",
"data_template": {
"some": (
"is_pos_gt_45_lt_90 - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"is_pos_gt_45_lt_90 "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -740,7 +773,10 @@ async def test_if_fires_on_tilt_position(hass, calls, enable_custom_integrations
[calls[0].data["some"], calls[1].data["some"], calls[2].data["some"]]
) == sorted(
[
"is_pos_gt_45_lt_90 - device - cover.set_position_cover - closed - open - None",
(
"is_pos_gt_45_lt_90 - device - cover.set_position_cover - closed - open"
" - None"
),
"is_pos_lt_90 - device - cover.set_position_cover - closed - open - None",
"is_pos_gt_45 - device - cover.set_position_cover - open - closed - None",
]

View File

@ -34,6 +34,5 @@ async def test_setting_up_demo(mock_history, hass):
json.dumps(hass.states.async_all(), cls=JSONEncoder)
except Exception: # pylint: disable=broad-except
pytest.fail(
"Unable to convert all demo entities to JSON. "
"Wrong data in state machine!"
"Unable to convert all demo entities to JSON. Wrong data in state machine!"
)

View File

@ -47,7 +47,10 @@ async def test_demo_speech_wrong_metadata(hass_client):
response = await client.post(
"/api/stt/demo",
headers={
"X-Speech-Content": "format=wav; codec=pcm; sample_rate=8000; bit_rate=16; channel=1; language=de"
"X-Speech-Content": (
"format=wav; codec=pcm; sample_rate=8000; bit_rate=16; channel=1;"
" language=de"
)
},
data=b"Test",
)
@ -61,7 +64,10 @@ async def test_demo_speech(hass_client):
response = await client.post(
"/api/stt/demo",
headers={
"X-Speech-Content": "format=wav; codec=pcm; sample_rate=16000; bit_rate=16; channel=2; language=de"
"X-Speech-Content": (
"format=wav; codec=pcm; sample_rate=16000; bit_rate=16; channel=2;"
" language=de"
)
},
data=b"Test",
)

View File

@ -136,7 +136,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_home - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_home "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -154,7 +158,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_not_home - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_not_home "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},

View File

@ -165,9 +165,13 @@ async def test_if_fires_on_zone_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"enter - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.attributes.longitude|round(3)}} - "
"{{ trigger.to_state.attributes.longitude|round(3)}}"
"enter "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ "
" trigger.from_state.attributes.longitude|round(3) "
" }} "
"- {{ trigger.to_state.attributes.longitude|round(3) }}"
)
},
},
@ -185,9 +189,13 @@ async def test_if_fires_on_zone_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"leave - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.attributes.longitude|round(3)}} - "
"{{ trigger.to_state.attributes.longitude|round(3)}}"
"leave "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ "
" trigger.from_state.attributes.longitude|round(3) "
" }} "
"- {{ trigger.to_state.attributes.longitude|round(3)}}"
)
},
},

View File

@ -75,7 +75,7 @@ async def test_reading_broken_yaml_config(hass):
"badkey.yaml": "@:\n name: Device",
"noname.yaml": "my_device:\n",
"allok.yaml": "My Device:\n name: Device",
"oneok.yaml": ("My Device!:\n name: Device\nbad_device:\n nme: Device"),
"oneok.yaml": "My Device!:\n name: Device\nbad_device:\n nme: Device",
}
args = {"hass": hass, "consider_home": timedelta(seconds=60)}
with patch_yaml_files(files):

View File

@ -483,7 +483,7 @@ async def test_dhcp_invalid_option(hass):
("requested_addr", "192.168.208.55"),
("server_id", "192.168.208.1"),
("param_req_list", [1, 3, 28, 6]),
("hostname"),
"hostname",
]
async_handle_dhcp_packet = await _async_get_handle_dhcp_packet(

View File

@ -674,7 +674,9 @@ async def test_play_media_stopped(
{
ATTR_ENTITY_ID: mock_entity_id,
mp_const.ATTR_MEDIA_CONTENT_TYPE: MediaType.MUSIC,
mp_const.ATTR_MEDIA_CONTENT_ID: "http://198.51.100.20:8200/MediaItems/17621.mp3",
mp_const.ATTR_MEDIA_CONTENT_ID: (
"http://198.51.100.20:8200/MediaItems/17621.mp3"
),
mp_const.ATTR_MEDIA_ENQUEUE: False,
},
blocking=True,
@ -706,7 +708,9 @@ async def test_play_media_playing(
{
ATTR_ENTITY_ID: mock_entity_id,
mp_const.ATTR_MEDIA_CONTENT_TYPE: MediaType.MUSIC,
mp_const.ATTR_MEDIA_CONTENT_ID: "http://198.51.100.20:8200/MediaItems/17621.mp3",
mp_const.ATTR_MEDIA_CONTENT_ID: (
"http://198.51.100.20:8200/MediaItems/17621.mp3"
),
mp_const.ATTR_MEDIA_ENQUEUE: False,
},
blocking=True,
@ -739,7 +743,9 @@ async def test_play_media_no_autoplay(
{
ATTR_ENTITY_ID: mock_entity_id,
mp_const.ATTR_MEDIA_CONTENT_TYPE: MediaType.MUSIC,
mp_const.ATTR_MEDIA_CONTENT_ID: "http://198.51.100.20:8200/MediaItems/17621.mp3",
mp_const.ATTR_MEDIA_CONTENT_ID: (
"http://198.51.100.20:8200/MediaItems/17621.mp3"
),
mp_const.ATTR_MEDIA_ENQUEUE: False,
mp_const.ATTR_MEDIA_EXTRA: {"autoplay": False},
},
@ -770,7 +776,9 @@ async def test_play_media_metadata(
{
ATTR_ENTITY_ID: mock_entity_id,
mp_const.ATTR_MEDIA_CONTENT_TYPE: MediaType.MUSIC,
mp_const.ATTR_MEDIA_CONTENT_ID: "http://198.51.100.20:8200/MediaItems/17621.mp3",
mp_const.ATTR_MEDIA_CONTENT_ID: (
"http://198.51.100.20:8200/MediaItems/17621.mp3"
),
mp_const.ATTR_MEDIA_ENQUEUE: False,
mp_const.ATTR_MEDIA_EXTRA: {
"title": "Mock song",
@ -800,7 +808,9 @@ async def test_play_media_metadata(
{
ATTR_ENTITY_ID: mock_entity_id,
mp_const.ATTR_MEDIA_CONTENT_TYPE: MediaType.TVSHOW,
mp_const.ATTR_MEDIA_CONTENT_ID: "http://198.51.100.20:8200/MediaItems/123.mkv",
mp_const.ATTR_MEDIA_CONTENT_ID: (
"http://198.51.100.20:8200/MediaItems/123.mkv"
),
mp_const.ATTR_MEDIA_ENQUEUE: False,
mp_const.ATTR_MEDIA_EXTRA: {
"title": "Mock show",
@ -833,7 +843,9 @@ async def test_play_media_local_source(
{
ATTR_ENTITY_ID: mock_entity_id,
mp_const.ATTR_MEDIA_CONTENT_TYPE: "video/mp4",
mp_const.ATTR_MEDIA_CONTENT_ID: "media-source://media_source/local/Epic Sax Guy 10 Hours.mp4",
mp_const.ATTR_MEDIA_CONTENT_ID: (
"media-source://media_source/local/Epic Sax Guy 10 Hours.mp4"
),
},
blocking=True,
)
@ -888,7 +900,9 @@ async def test_play_media_didl_metadata(
{
ATTR_ENTITY_ID: mock_entity_id,
mp_const.ATTR_MEDIA_CONTENT_TYPE: "video/mp4",
mp_const.ATTR_MEDIA_CONTENT_ID: "media-source://media_source/local/Epic Sax Guy 10 Hours.mp4",
mp_const.ATTR_MEDIA_CONTENT_ID: (
"media-source://media_source/local/Epic Sax Guy 10 Hours.mp4"
),
},
blocking=True,
)
@ -1011,7 +1025,9 @@ async def test_browse_media(
"title": "Epic Sax Guy 10 Hours.mp4",
"media_class": "video",
"media_content_type": "video/mp4",
"media_content_id": "media-source://media_source/local/Epic Sax Guy 10 Hours.mp4",
"media_content_id": (
"media-source://media_source/local/Epic Sax Guy 10 Hours.mp4"
),
"can_play": True,
"can_expand": False,
"thumbnail": None,
@ -1104,7 +1120,9 @@ async def test_browse_media_unfiltered(
"title": "Epic Sax Guy 10 Hours.mp4",
"media_class": "video",
"media_content_type": "video/mp4",
"media_content_id": "media-source://media_source/local/Epic Sax Guy 10 Hours.mp4",
"media_content_id": (
"media-source://media_source/local/Epic Sax Guy 10 Hours.mp4"
),
"can_play": True,
"can_expand": False,
"thumbnail": None,
@ -1280,7 +1298,9 @@ async def test_unavailable_device(
mp_const.SERVICE_PLAY_MEDIA,
{
mp_const.ATTR_MEDIA_CONTENT_TYPE: MediaType.MUSIC,
mp_const.ATTR_MEDIA_CONTENT_ID: "http://198.51.100.20:8200/MediaItems/17621.mp3",
mp_const.ATTR_MEDIA_CONTENT_ID: (
"http://198.51.100.20:8200/MediaItems/17621.mp3"
),
mp_const.ATTR_MEDIA_ENQUEUE: False,
},
),

View File

@ -851,7 +851,9 @@ async def test_validation_gas(
"type": "entity_unexpected_unit_gas_price",
"affected_entities": {("sensor.gas_price_2", "EUR/invalid")},
"translation_placeholders": {
"price_units": "EUR/GJ, EUR/kWh, EUR/MWh, EUR/Wh, EUR/CCF, EUR/ft³, EUR/m³"
"price_units": (
"EUR/GJ, EUR/kWh, EUR/MWh, EUR/Wh, EUR/CCF, EUR/ft³, EUR/m³"
)
},
},
],

View File

@ -163,7 +163,9 @@ async def test_save_preferences(
assert msg["result"] == {
"cost_sensors": {
"sensor.heat_pump_meter_2": "sensor.heat_pump_meter_2_cost",
"sensor.return_to_grid_offpeak": "sensor.return_to_grid_offpeak_compensation",
"sensor.return_to_grid_offpeak": (
"sensor.return_to_grid_offpeak_compensation"
),
},
"solar_forecast_domains": ["some_domain"],
}

View File

@ -136,7 +136,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_on - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_on "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},
@ -154,7 +158,11 @@ async def test_if_state(hass, calls):
"action": {
"service": "test.automation",
"data_template": {
"some": "is_off - {{ trigger.platform }} - {{ trigger.event.event_type }}"
"some": (
"is_off "
"- {{ trigger.platform }} "
"- {{ trigger.event.event_type }}"
)
},
},
},

View File

@ -163,9 +163,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"turn_on - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"turn_on "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -182,9 +185,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"turn_off - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"turn_off "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},
@ -201,9 +207,12 @@ async def test_if_fires_on_state_change(hass, calls):
"service": "test.automation",
"data_template": {
"some": (
"turn_on_or_off - {{ trigger.platform}} - "
"{{ trigger.entity_id}} - {{ trigger.from_state.state}} - "
"{{ trigger.to_state.state}} - {{ trigger.for }}"
"turn_on_or_off "
"- {{ trigger.platform }} "
"- {{ trigger.entity_id }} "
"- {{ trigger.from_state.state }} "
"- {{ trigger.to_state.state }} "
"- {{ trigger.for }}"
)
},
},

View File

@ -480,8 +480,10 @@ def mock_device_tracker_conf():
devices.append(entity)
with patch(
"homeassistant.components.device_tracker.legacy"
".DeviceTracker.async_update_config",
(
"homeassistant.components.device_tracker.legacy"
".DeviceTracker.async_update_config"
),
side_effect=mock_update_config,
), patch(
"homeassistant.components.device_tracker.legacy.async_load_config",

View File

@ -1177,9 +1177,9 @@ async def test_component_config_exceptions(hass, caplog):
) == {"test_domain": []}
assert "ValueError: broken" in caplog.text
assert (
"Unknown error validating test_platform platform config with test_domain component platform schema"
in caplog.text
)
"Unknown error validating test_platform platform config "
"with test_domain component platform schema"
) in caplog.text
# platform.PLATFORM_SCHEMA
caplog.clear()
@ -1204,8 +1204,8 @@ async def test_component_config_exceptions(hass, caplog):
) == {"test_domain": []}
assert "ValueError: broken" in caplog.text
assert (
"Unknown error validating config for test_platform platform for test_domain component with PLATFORM_SCHEMA"
in caplog.text
"Unknown error validating config for test_platform platform for test_domain"
" component with PLATFORM_SCHEMA" in caplog.text
)
# get_platform("config") raising
@ -1219,7 +1219,10 @@ async def test_component_config_exceptions(hass, caplog):
domain="test_domain",
get_platform=Mock(
side_effect=ImportError(
"ModuleNotFoundError: No module named 'not_installed_something'",
(
"ModuleNotFoundError: No module named"
" 'not_installed_something'"
),
name="not_installed_something",
)
),
@ -1228,8 +1231,8 @@ async def test_component_config_exceptions(hass, caplog):
is None
)
assert (
"Error importing config platform test_domain: ModuleNotFoundError: No module named 'not_installed_something'"
in caplog.text
"Error importing config platform test_domain: ModuleNotFoundError: No module"
" named 'not_installed_something'" in caplog.text
)
# get_component raising

View File

@ -897,9 +897,10 @@ async def test_setup_raise_not_ready(hass, caplog):
assert len(mock_call.mock_calls) == 1
assert (
"Config entry 'test_title' for test integration not ready yet: The internet connection is offline"
in caplog.text
)
"Config entry 'test_title' for test integration not ready yet:"
" The internet connection is offline"
) in caplog.text
p_hass, p_wait_time, p_setup = mock_call.mock_calls[0][1]
assert p_hass is hass
@ -932,8 +933,8 @@ async def test_setup_raise_not_ready_from_exception(hass, caplog):
assert len(mock_call.mock_calls) == 1
assert (
"Config entry 'test_title' for test integration not ready yet: The device dropped the connection"
in caplog.text
"Config entry 'test_title' for test integration not ready yet: The device"
" dropped the connection" in caplog.text
)
@ -2950,8 +2951,8 @@ async def test_setup_not_raise_entry_error_from_future_coordinator_update(hass,
await entry.async_setup(hass)
await hass.async_block_till_done()
assert (
"Config entry setup failed while fetching any data: Incompatible firmware version"
in caplog.text
"Config entry setup failed while fetching any data: Incompatible firmware"
" version" in caplog.text
)
assert entry.state is config_entries.ConfigEntryState.LOADED

View File

@ -722,8 +722,7 @@ def test_state_repr():
datetime(1984, 12, 8, 12, 0, 0),
)
)
== "<state happy.happy=on; brightness=144 @ "
"1984-12-08T12:00:00+00:00>"
== "<state happy.happy=on; brightness=144 @ 1984-12-08T12:00:00+00:00>"
)

View File

@ -138,16 +138,16 @@ async def test_custom_integration_version_not_valid(
await loader.async_get_integration(hass, "test_no_version")
assert (
"The custom integration 'test_no_version' does not have a version key in the manifest file and was blocked from loading."
in caplog.text
)
"The custom integration 'test_no_version' does not have a version key in the"
" manifest file and was blocked from loading."
) in caplog.text
with pytest.raises(loader.IntegrationNotFound):
await loader.async_get_integration(hass, "test2")
assert (
"The custom integration 'test_bad_version' does not have a valid version key (bad) in the manifest file and was blocked from loading."
in caplog.text
)
"The custom integration 'test_bad_version' does not have a valid version key"
" (bad) in the manifest file and was blocked from loading."
) in caplog.text
async def test_get_integration(hass):