1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Use f-strings in integrations starting with "F"and"G" (#32150)

* Use f-strings in integrations starting with F

* Use f-strings in tests for integrations starting with F

* Use f-strings in integrations starting with G

* Use f-strings in tests for integrations starting with G

* Fix pylint error

* Fix broken test
This commit is contained in:
springstan
2020-02-25 02:54:20 +01:00
committed by GitHub
parent 496bd3dddf
commit ad102b3840
59 changed files with 219 additions and 344 deletions

View File

@@ -163,7 +163,7 @@ async def webhook_id(hass, geofency_client):
async def test_data_validation(geofency_client, webhook_id):
"""Test data validation."""
url = "/api/webhook/{}".format(webhook_id)
url = f"/api/webhook/{webhook_id}"
# No data
req = await geofency_client.post(url)
@@ -181,14 +181,14 @@ async def test_data_validation(geofency_client, webhook_id):
async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
"""Test GPS based zone enter and exit."""
url = "/api/webhook/{}".format(webhook_id)
url = f"/api/webhook/{webhook_id}"
# Enter the Home zone
req = await geofency_client.post(url, data=GPS_ENTER_HOME)
await hass.async_block_till_done()
assert req.status == HTTP_OK
device_name = slugify(GPS_ENTER_HOME["device"])
state_name = hass.states.get("{}.{}".format("device_tracker", device_name)).state
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_HOME == state_name
# Exit the Home zone
@@ -196,7 +196,7 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
await hass.async_block_till_done()
assert req.status == HTTP_OK
device_name = slugify(GPS_EXIT_HOME["device"])
state_name = hass.states.get("{}.{}".format("device_tracker", device_name)).state
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_NOT_HOME == state_name
# Exit the Home zone with "Send Current Position" enabled
@@ -208,13 +208,13 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
await hass.async_block_till_done()
assert req.status == HTTP_OK
device_name = slugify(GPS_EXIT_HOME["device"])
current_latitude = hass.states.get(
"{}.{}".format("device_tracker", device_name)
).attributes["latitude"]
current_latitude = hass.states.get(f"device_tracker.{device_name}").attributes[
"latitude"
]
assert NOT_HOME_LATITUDE == current_latitude
current_longitude = hass.states.get(
"{}.{}".format("device_tracker", device_name)
).attributes["longitude"]
current_longitude = hass.states.get(f"device_tracker.{device_name}").attributes[
"longitude"
]
assert NOT_HOME_LONGITUDE == current_longitude
dev_reg = await hass.helpers.device_registry.async_get_registry()
@@ -226,43 +226,43 @@ async def test_gps_enter_and_exit_home(hass, geofency_client, webhook_id):
async def test_beacon_enter_and_exit_home(hass, geofency_client, webhook_id):
"""Test iBeacon based zone enter and exit - a.k.a stationary iBeacon."""
url = "/api/webhook/{}".format(webhook_id)
url = f"/api/webhook/{webhook_id}"
# Enter the Home zone
req = await geofency_client.post(url, data=BEACON_ENTER_HOME)
await hass.async_block_till_done()
assert req.status == HTTP_OK
device_name = slugify("beacon_{}".format(BEACON_ENTER_HOME["name"]))
state_name = hass.states.get("{}.{}".format("device_tracker", device_name)).state
device_name = slugify(f"beacon_{BEACON_ENTER_HOME['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_HOME == state_name
# Exit the Home zone
req = await geofency_client.post(url, data=BEACON_EXIT_HOME)
await hass.async_block_till_done()
assert req.status == HTTP_OK
device_name = slugify("beacon_{}".format(BEACON_ENTER_HOME["name"]))
state_name = hass.states.get("{}.{}".format("device_tracker", device_name)).state
device_name = slugify(f"beacon_{BEACON_ENTER_HOME['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_NOT_HOME == state_name
async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
"""Test use of mobile iBeacon."""
url = "/api/webhook/{}".format(webhook_id)
url = f"/api/webhook/{webhook_id}"
# Enter the Car away from Home zone
req = await geofency_client.post(url, data=BEACON_ENTER_CAR)
await hass.async_block_till_done()
assert req.status == HTTP_OK
device_name = slugify("beacon_{}".format(BEACON_ENTER_CAR["name"]))
state_name = hass.states.get("{}.{}".format("device_tracker", device_name)).state
device_name = slugify(f"beacon_{BEACON_ENTER_CAR['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_NOT_HOME == state_name
# Exit the Car away from Home zone
req = await geofency_client.post(url, data=BEACON_EXIT_CAR)
await hass.async_block_till_done()
assert req.status == HTTP_OK
device_name = slugify("beacon_{}".format(BEACON_ENTER_CAR["name"]))
state_name = hass.states.get("{}.{}".format("device_tracker", device_name)).state
device_name = slugify(f"beacon_{BEACON_ENTER_CAR['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_NOT_HOME == state_name
# Enter the Car in the Home zone
@@ -272,29 +272,29 @@ async def test_beacon_enter_and_exit_car(hass, geofency_client, webhook_id):
req = await geofency_client.post(url, data=data)
await hass.async_block_till_done()
assert req.status == HTTP_OK
device_name = slugify("beacon_{}".format(data["name"]))
state_name = hass.states.get("{}.{}".format("device_tracker", device_name)).state
device_name = slugify(f"beacon_{data['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_HOME == state_name
# Exit the Car in the Home zone
req = await geofency_client.post(url, data=data)
await hass.async_block_till_done()
assert req.status == HTTP_OK
device_name = slugify("beacon_{}".format(data["name"]))
state_name = hass.states.get("{}.{}".format("device_tracker", device_name)).state
device_name = slugify(f"beacon_{data['name']}")
state_name = hass.states.get(f"device_tracker.{device_name}").state
assert STATE_HOME == state_name
async def test_load_unload_entry(hass, geofency_client, webhook_id):
"""Test that the appropriate dispatch signals are added and removed."""
url = "/api/webhook/{}".format(webhook_id)
url = f"/api/webhook/{webhook_id}"
# Enter the Home zone
req = await geofency_client.post(url, data=GPS_ENTER_HOME)
await hass.async_block_till_done()
assert req.status == HTTP_OK
device_name = slugify(GPS_ENTER_HOME["device"])
state_1 = hass.states.get("{}.{}".format("device_tracker", device_name))
state_1 = hass.states.get(f"device_tracker.{device_name}")
assert STATE_HOME == state_1.state
assert len(hass.data[DOMAIN]["devices"]) == 1
@@ -307,7 +307,7 @@ async def test_load_unload_entry(hass, geofency_client, webhook_id):
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
state_2 = hass.states.get("{}.{}".format("device_tracker", device_name))
state_2 = hass.states.get(f"device_tracker.{device_name}")
assert state_2 is not None
assert state_1 is not state_2