Upgrade black to 20.8b1 (#39287)

This commit is contained in:
Franck Nijhof 2020-08-27 13:56:20 +02:00 committed by GitHub
parent 0d7eec710c
commit 1c2ebdf307
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
574 changed files with 4389 additions and 1725 deletions

View file

@ -105,7 +105,9 @@ async def test_fail_setup_without_command_topic(hass, mqtt_mock):
async def test_update_state_via_state_topic(hass, mqtt_mock):
"""Test updating with via state topic."""
assert await async_setup_component(
hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG,
hass,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
)
await hass.async_block_till_done()
@ -131,7 +133,9 @@ async def test_update_state_via_state_topic(hass, mqtt_mock):
async def test_ignore_update_state_if_unknown_via_state_topic(hass, mqtt_mock):
"""Test ignoring updates via state topic."""
assert await async_setup_component(
hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG,
hass,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
)
await hass.async_block_till_done()
@ -146,7 +150,9 @@ async def test_ignore_update_state_if_unknown_via_state_topic(hass, mqtt_mock):
async def test_arm_home_publishes_mqtt(hass, mqtt_mock):
"""Test publishing of MQTT messages while armed."""
assert await async_setup_component(
hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG,
hass,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
)
await hass.async_block_till_done()
@ -162,7 +168,9 @@ async def test_arm_home_not_publishes_mqtt_with_invalid_code_when_req(hass, mqtt
When code_arm_required = True
"""
assert await async_setup_component(
hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG_CODE,
hass,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG_CODE,
)
call_count = mqtt_mock.async_publish.call_count
@ -177,7 +185,11 @@ async def test_arm_home_publishes_mqtt_when_code_not_req(hass, mqtt_mock):
"""
config = copy.deepcopy(DEFAULT_CONFIG_CODE)
config[alarm_control_panel.DOMAIN]["code_arm_required"] = False
assert await async_setup_component(hass, alarm_control_panel.DOMAIN, config,)
assert await async_setup_component(
hass,
alarm_control_panel.DOMAIN,
config,
)
await hass.async_block_till_done()
await common.async_alarm_arm_home(hass)
@ -189,7 +201,9 @@ async def test_arm_home_publishes_mqtt_when_code_not_req(hass, mqtt_mock):
async def test_arm_away_publishes_mqtt(hass, mqtt_mock):
"""Test publishing of MQTT messages while armed."""
assert await async_setup_component(
hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG,
hass,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
)
await hass.async_block_till_done()
@ -205,7 +219,9 @@ async def test_arm_away_not_publishes_mqtt_with_invalid_code_when_req(hass, mqtt
When code_arm_required = True
"""
assert await async_setup_component(
hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG_CODE,
hass,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG_CODE,
)
call_count = mqtt_mock.async_publish.call_count
@ -220,7 +236,11 @@ async def test_arm_away_publishes_mqtt_when_code_not_req(hass, mqtt_mock):
"""
config = copy.deepcopy(DEFAULT_CONFIG_CODE)
config[alarm_control_panel.DOMAIN]["code_arm_required"] = False
assert await async_setup_component(hass, alarm_control_panel.DOMAIN, config,)
assert await async_setup_component(
hass,
alarm_control_panel.DOMAIN,
config,
)
await hass.async_block_till_done()
await common.async_alarm_arm_away(hass)
@ -232,7 +252,9 @@ async def test_arm_away_publishes_mqtt_when_code_not_req(hass, mqtt_mock):
async def test_arm_night_publishes_mqtt(hass, mqtt_mock):
"""Test publishing of MQTT messages while armed."""
assert await async_setup_component(
hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG,
hass,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
)
await hass.async_block_till_done()
@ -248,7 +270,9 @@ async def test_arm_night_not_publishes_mqtt_with_invalid_code_when_req(hass, mqt
When code_arm_required = True
"""
assert await async_setup_component(
hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG_CODE,
hass,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG_CODE,
)
call_count = mqtt_mock.async_publish.call_count
@ -263,7 +287,11 @@ async def test_arm_night_publishes_mqtt_when_code_not_req(hass, mqtt_mock):
"""
config = copy.deepcopy(DEFAULT_CONFIG_CODE)
config[alarm_control_panel.DOMAIN]["code_arm_required"] = False
assert await async_setup_component(hass, alarm_control_panel.DOMAIN, config,)
assert await async_setup_component(
hass,
alarm_control_panel.DOMAIN,
config,
)
await hass.async_block_till_done()
await common.async_alarm_arm_night(hass)
@ -352,7 +380,9 @@ async def test_arm_custom_bypass_publishes_mqtt_when_code_not_req(hass, mqtt_moc
async def test_disarm_publishes_mqtt(hass, mqtt_mock):
"""Test publishing of MQTT messages while disarmed."""
assert await async_setup_component(
hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG,
hass,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG,
)
await hass.async_block_till_done()
@ -370,7 +400,11 @@ async def test_disarm_publishes_mqtt_with_template(hass, mqtt_mock):
config[alarm_control_panel.DOMAIN]["command_template"] = (
'{"action":"{{ action }}",' '"code":"{{ code }}"}'
)
assert await async_setup_component(hass, alarm_control_panel.DOMAIN, config,)
assert await async_setup_component(
hass,
alarm_control_panel.DOMAIN,
config,
)
await hass.async_block_till_done()
await common.async_alarm_disarm(hass, 1234)
@ -387,7 +421,11 @@ async def test_disarm_publishes_mqtt_when_code_not_req(hass, mqtt_mock):
config = copy.deepcopy(DEFAULT_CONFIG_CODE)
config[alarm_control_panel.DOMAIN]["code"] = "1234"
config[alarm_control_panel.DOMAIN]["code_disarm_required"] = False
assert await async_setup_component(hass, alarm_control_panel.DOMAIN, config,)
assert await async_setup_component(
hass,
alarm_control_panel.DOMAIN,
config,
)
await hass.async_block_till_done()
await common.async_alarm_disarm(hass)
@ -400,7 +438,9 @@ async def test_disarm_not_publishes_mqtt_with_invalid_code_when_req(hass, mqtt_m
When code_disarm_required = True
"""
assert await async_setup_component(
hass, alarm_control_panel.DOMAIN, DEFAULT_CONFIG_CODE,
hass,
alarm_control_panel.DOMAIN,
DEFAULT_CONFIG_CODE,
)
call_count = mqtt_mock.async_publish.call_count

View file

@ -74,7 +74,11 @@ async def help_test_default_availability_payload(
# Add availability settings to config
config = copy.deepcopy(config)
config[domain]["availability_topic"] = "availability-topic"
assert await async_setup_component(hass, domain, config,)
assert await async_setup_component(
hass,
domain,
config,
)
await hass.async_block_till_done()
state = hass.states.get(f"{domain}.test")
@ -123,7 +127,11 @@ async def help_test_default_availability_list_payload(
{"topic": "availability-topic1"},
{"topic": "availability-topic2"},
]
assert await async_setup_component(hass, domain, config,)
assert await async_setup_component(
hass,
domain,
config,
)
await hass.async_block_till_done()
state = hass.states.get(f"{domain}.test")
@ -185,7 +193,11 @@ async def help_test_default_availability_list_single(
{"topic": "availability-topic1"},
]
config[domain]["availability_topic"] = "availability-topic"
assert await async_setup_component(hass, domain, config,)
assert await async_setup_component(
hass,
domain,
config,
)
await hass.async_block_till_done()
state = hass.states.get(f"{domain}.test")
@ -214,7 +226,11 @@ async def help_test_custom_availability_payload(
config[domain]["availability_topic"] = "availability-topic"
config[domain]["payload_available"] = "good"
config[domain]["payload_not_available"] = "nogood"
assert await async_setup_component(hass, domain, config,)
assert await async_setup_component(
hass,
domain,
config,
)
await hass.async_block_till_done()
state = hass.states.get(f"{domain}.test")
@ -336,7 +352,11 @@ async def help_test_setting_attribute_via_mqtt_json_message(
# Add JSON attributes settings to config
config = copy.deepcopy(config)
config[domain]["json_attributes_topic"] = "attr-topic"
assert await async_setup_component(hass, domain, config,)
assert await async_setup_component(
hass,
domain,
config,
)
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "attr-topic", '{ "val": "100" }')
@ -354,7 +374,11 @@ async def help_test_setting_attribute_with_template(hass, mqtt_mock, domain, con
config = copy.deepcopy(config)
config[domain]["json_attributes_topic"] = "attr-topic"
config[domain]["json_attributes_template"] = "{{ value_json['Timer1'] | tojson }}"
assert await async_setup_component(hass, domain, config,)
assert await async_setup_component(
hass,
domain,
config,
)
await hass.async_block_till_done()
async_fire_mqtt_message(
@ -376,7 +400,11 @@ async def help_test_update_with_json_attrs_not_dict(
# Add JSON attributes settings to config
config = copy.deepcopy(config)
config[domain]["json_attributes_topic"] = "attr-topic"
assert await async_setup_component(hass, domain, config,)
assert await async_setup_component(
hass,
domain,
config,
)
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "attr-topic", '[ "list", "of", "things"]')
@ -396,7 +424,11 @@ async def help_test_update_with_json_attrs_bad_JSON(
# Add JSON attributes settings to config
config = copy.deepcopy(config)
config[domain]["json_attributes_topic"] = "attr-topic"
assert await async_setup_component(hass, domain, config,)
assert await async_setup_component(
hass,
domain,
config,
)
await hass.async_block_till_done()
async_fire_mqtt_message(hass, "attr-topic", "This is not JSON")
@ -670,7 +702,11 @@ async def help_test_entity_id_update_subscriptions(
topics = ["avty-topic", "test-topic"]
assert len(topics) > 0
registry = mock_registry(hass, {})
assert await async_setup_component(hass, domain, config,)
assert await async_setup_component(
hass,
domain,
config,
)
await hass.async_block_till_done()
state = hass.states.get(f"{domain}.test")

View file

@ -505,7 +505,8 @@ async def test_options_bad_birth_message_fails(hass, mock_try_connection):
assert result["step_id"] == "options"
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"birth_topic": "ha_state/online/#"},
result["flow_id"],
user_input={"birth_topic": "ha_state/online/#"},
)
assert result["type"] == "form"
assert result["errors"]["base"] == "bad_birth"
@ -540,7 +541,8 @@ async def test_options_bad_will_message_fails(hass, mock_try_connection):
assert result["step_id"] == "options"
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"will_topic": "ha_state/offline/#"},
result["flow_id"],
user_input={"will_topic": "ha_state/offline/#"},
)
assert result["type"] == "form"
assert result["errors"]["base"] == "bad_will"

View file

@ -791,7 +791,8 @@ async def test_default_birth_message(hass, mqtt_client_mock, mqtt_mock):
@pytest.mark.parametrize(
"mqtt_config", [{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_BIRTH_MESSAGE: {}}],
"mqtt_config",
[{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_BIRTH_MESSAGE: {}}],
)
async def test_no_birth_message(hass, mqtt_client_mock, mqtt_mock):
"""Test disabling birth message."""
@ -829,7 +830,8 @@ async def test_default_will_message(hass, mqtt_client_mock, mqtt_mock):
@pytest.mark.parametrize(
"mqtt_config", [{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_WILL_MESSAGE: {}}],
"mqtt_config",
[{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_WILL_MESSAGE: {}}],
)
async def test_no_will_message(hass, mqtt_client_mock, mqtt_mock):
"""Test will message."""
@ -837,7 +839,8 @@ async def test_no_will_message(hass, mqtt_client_mock, mqtt_mock):
@pytest.mark.parametrize(
"mqtt_config", [{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_BIRTH_MESSAGE: {}}],
"mqtt_config",
[{mqtt.CONF_BROKER: "mock-broker", mqtt.CONF_BIRTH_MESSAGE: {}}],
)
async def test_mqtt_subscribes_topics_on_connect(hass, mqtt_client_mock, mqtt_mock):
"""Test subscription to topic on connect."""

View file

@ -1006,7 +1006,9 @@ async def test_invalid_values(hass, mqtt_mock):
# Bad HS color values
async_fire_mqtt_message(
hass, "test_light_rgb", '{"state":"ON",' '"color":{"h":"bad","s":"val"}}',
hass,
"test_light_rgb",
'{"state":"ON",' '"color":{"h":"bad","s":"val"}}',
)
# Color should not have changed
@ -1028,7 +1030,9 @@ async def test_invalid_values(hass, mqtt_mock):
# Bad XY color values
async_fire_mqtt_message(
hass, "test_light_rgb", '{"state":"ON",' '"color":{"x":"bad","y":"val"}}',
hass,
"test_light_rgb",
'{"state":"ON",' '"color":{"x":"bad","y":"val"}}',
)
# Color should not have changed