Improve string formatting v6 (#33698)
This commit is contained in:
1 parent
d7e3b0b755
commit
eae21be5b9
43 files changed
+81
-87
No files matched your search
@@ -99,7 +99,7 @@ class TestPlant(unittest.TestCase):
|
||||
self.hass, plant.DOMAIN, {plant.DOMAIN: {plant_name: GOOD_CONFIG}}
|
||||
)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get("plant." + plant_name)
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
assert 5 == state.attributes[plant.READING_MOISTURE]
|
||||
|
||||
def test_update_states(self):
|
||||
@@ -113,7 +113,7 @@ class TestPlant(unittest.TestCase):
|
||||
)
|
||||
self.hass.states.set(MOISTURE_ENTITY, 5, {ATTR_UNIT_OF_MEASUREMENT: "us/cm"})
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get("plant." + plant_name)
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
assert STATE_PROBLEM == state.state
|
||||
assert 5 == state.attributes[plant.READING_MOISTURE]
|
||||
|
||||
@@ -130,7 +130,7 @@ class TestPlant(unittest.TestCase):
|
||||
MOISTURE_ENTITY, STATE_UNAVAILABLE, {ATTR_UNIT_OF_MEASUREMENT: "us/cm"}
|
||||
)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get("plant." + plant_name)
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
assert state.state == STATE_PROBLEM
|
||||
assert state.attributes[plant.READING_MOISTURE] == STATE_UNAVAILABLE
|
||||
|
||||
@@ -145,14 +145,14 @@ class TestPlant(unittest.TestCase):
|
||||
)
|
||||
self.hass.states.set(MOISTURE_ENTITY, 42, {ATTR_UNIT_OF_MEASUREMENT: "us/cm"})
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get("plant." + plant_name)
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
assert state.state == STATE_OK
|
||||
assert state.attributes[plant.READING_MOISTURE] == 42
|
||||
self.hass.states.set(
|
||||
MOISTURE_ENTITY, STATE_UNAVAILABLE, {ATTR_UNIT_OF_MEASUREMENT: "us/cm"}
|
||||
)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get("plant." + plant_name)
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
assert state.state == STATE_PROBLEM
|
||||
assert state.attributes[plant.READING_MOISTURE] == STATE_UNAVAILABLE
|
||||
|
||||
@@ -184,7 +184,7 @@ class TestPlant(unittest.TestCase):
|
||||
)
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get("plant." + plant_name)
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
assert STATE_UNKNOWN == state.state
|
||||
max_brightness = state.attributes.get(plant.ATTR_MAX_BRIGHTNESS_HISTORY)
|
||||
assert 30 == max_brightness
|
||||
@@ -197,17 +197,17 @@ class TestPlant(unittest.TestCase):
|
||||
)
|
||||
self.hass.states.set(BRIGHTNESS_ENTITY, 100, {ATTR_UNIT_OF_MEASUREMENT: "lux"})
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get("plant." + plant_name)
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
assert STATE_PROBLEM == state.state
|
||||
|
||||
self.hass.states.set(BRIGHTNESS_ENTITY, 600, {ATTR_UNIT_OF_MEASUREMENT: "lux"})
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get("plant." + plant_name)
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
assert STATE_OK == state.state
|
||||
|
||||
self.hass.states.set(BRIGHTNESS_ENTITY, 100, {ATTR_UNIT_OF_MEASUREMENT: "lux"})
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get("plant." + plant_name)
|
||||
state = self.hass.states.get(f"plant.{plant_name}")
|
||||
assert STATE_OK == state.state
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user