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

@ -252,14 +252,14 @@ class TestInfluxDB(unittest.TestCase):
state = mock.MagicMock(
state=1,
domain="fake",
entity_id="fake.{}".format(entity_id),
entity_id=f"fake.{entity_id}",
object_id=entity_id,
attributes={},
)
event = mock.MagicMock(data={"new_state": state}, time_fired=12345)
body = [
{
"measurement": "fake.{}".format(entity_id),
"measurement": f"fake.{entity_id}",
"tags": {"domain": "fake", "entity_id": entity_id},
"time": 12345,
"fields": {"value": 1},
@ -284,14 +284,14 @@ class TestInfluxDB(unittest.TestCase):
state = mock.MagicMock(
state=1,
domain=domain,
entity_id="{}.something".format(domain),
entity_id=f"{domain}.something",
object_id="something",
attributes={},
)
event = mock.MagicMock(data={"new_state": state}, time_fired=12345)
body = [
{
"measurement": "{}.something".format(domain),
"measurement": f"{domain}.something",
"tags": {"domain": domain, "entity_id": "something"},
"time": 12345,
"fields": {"value": 1},
@ -326,14 +326,14 @@ class TestInfluxDB(unittest.TestCase):
state = mock.MagicMock(
state=1,
domain="fake",
entity_id="fake.{}".format(entity_id),
entity_id=f"fake.{entity_id}",
object_id=entity_id,
attributes={},
)
event = mock.MagicMock(data={"new_state": state}, time_fired=12345)
body = [
{
"measurement": "fake.{}".format(entity_id),
"measurement": f"fake.{entity_id}",
"tags": {"domain": "fake", "entity_id": entity_id},
"time": 12345,
"fields": {"value": 1},
@ -368,14 +368,14 @@ class TestInfluxDB(unittest.TestCase):
state = mock.MagicMock(
state=1,
domain=domain,
entity_id="{}.something".format(domain),
entity_id=f"{domain}.something",
object_id="something",
attributes={},
)
event = mock.MagicMock(data={"new_state": state}, time_fired=12345)
body = [
{
"measurement": "{}.something".format(domain),
"measurement": f"{domain}.something",
"tags": {"domain": domain, "entity_id": "something"},
"time": 12345,
"fields": {"value": 1},
@ -410,14 +410,14 @@ class TestInfluxDB(unittest.TestCase):
state = mock.MagicMock(
state=1,
domain=domain,
entity_id="{}.something".format(domain),
entity_id=f"{domain}.something",
object_id="something",
attributes={},
)
event = mock.MagicMock(data={"new_state": state}, time_fired=12345)
body = [
{
"measurement": "{}.something".format(domain),
"measurement": f"{domain}.something",
"tags": {"domain": domain, "entity_id": "something"},
"time": 12345,
"fields": {"value": 1},
@ -438,14 +438,14 @@ class TestInfluxDB(unittest.TestCase):
state = mock.MagicMock(
state=1,
domain="other",
entity_id="other.{}".format(entity_id),
entity_id=f"other.{entity_id}",
object_id=entity_id,
attributes={},
)
event = mock.MagicMock(data={"new_state": state}, time_fired=12345)
body = [
{
"measurement": "other.{}".format(entity_id),
"measurement": f"other.{entity_id}",
"tags": {"domain": "other", "entity_id": entity_id},
"time": 12345,
"fields": {"value": 1},
@ -532,7 +532,7 @@ class TestInfluxDB(unittest.TestCase):
state = mock.MagicMock(
state=1,
domain="fake",
entity_id="fake.{}".format(entity_id),
entity_id=f"fake.{entity_id}",
object_id=entity_id,
attributes={},
)