String formatting improvements for tests (#33663)

This commit is contained in:
Franck Nijhof 2020-04-05 00:26:08 +02:00 committed by GitHub
parent 1c25468b21
commit 906385172a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 129 additions and 155 deletions

View file

@ -97,9 +97,7 @@ async def test_remove_entry(hass, client):
"""Test removing an entry via the API."""
entry = MockConfigEntry(domain="demo", state=core_ce.ENTRY_STATE_LOADED)
entry.add_to_hass(hass)
resp = await client.delete(
"/api/config/config_entries/entry/{}".format(entry.entry_id)
)
resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}")
assert resp.status == 200
data = await resp.json()
assert data == {"require_restart": True}
@ -111,9 +109,7 @@ async def test_remove_entry_unauth(hass, client, hass_admin_user):
hass_admin_user.groups = []
entry = MockConfigEntry(domain="demo", state=core_ce.ENTRY_STATE_LOADED)
entry.add_to_hass(hass)
resp = await client.delete(
"/api/config/config_entries/entry/{}".format(entry.entry_id)
)
resp = await client.delete(f"/api/config/config_entries/entry/{entry.entry_id}")
assert resp.status == 401
assert len(hass.config_entries.async_entries()) == 1
@ -124,7 +120,7 @@ async def test_available_flows(hass, client):
resp = await client.get("/api/config/config_entries/flow_handlers")
assert resp.status == 200
data = await resp.json()
assert set(data) == set(["hello", "world"])
assert set(data) == {"hello", "world"}
############################
@ -294,7 +290,7 @@ async def test_two_step_flow(hass, client):
with patch.dict(HANDLERS, {"test": TestFlow}):
resp = await client.post(
"/api/config/config_entries/flow/{}".format(flow_id),
f"/api/config/config_entries/flow/{flow_id}",
json={"user_title": "user-title"},
)
assert resp.status == 200
@ -352,8 +348,7 @@ async def test_continue_flow_unauth(hass, client, hass_admin_user):
hass_admin_user.groups = []
resp = await client.post(
"/api/config/config_entries/flow/{}".format(flow_id),
json={"user_title": "user-title"},
f"/api/config/config_entries/flow/{flow_id}", json={"user_title": "user-title"},
)
assert resp.status == 401
@ -559,7 +554,7 @@ async def test_two_step_options_flow(hass, client):
with patch.dict(HANDLERS, {"test": TestFlow}):
resp = await client.post(
"/api/config/config_entries/options/flow/{}".format(flow_id),
f"/api/config/config_entries/options/flow/{flow_id}",
json={"enabled": True},
)
assert resp.status == 200