Pytest tests (#17750)
* Convert core tests
* Convert component tests to use pytest assert
* Lint 🤷♂️
* Fix test
* Fix 3 typos in docs
This commit is contained in:
parent
4222f7562b
commit
08fe7c3ece
223 changed files with 6747 additions and 7237 deletions
|
@ -101,8 +101,8 @@ class TestPlant(unittest.TestCase):
|
|||
{ATTR_UNIT_OF_MEASUREMENT: 'us/cm'})
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get('plant.'+plant_name)
|
||||
self.assertEqual(STATE_PROBLEM, state.state)
|
||||
self.assertEqual(5, state.attributes[plant.READING_MOISTURE])
|
||||
assert STATE_PROBLEM == state.state
|
||||
assert 5 == state.attributes[plant.READING_MOISTURE]
|
||||
|
||||
@pytest.mark.skipif(plant.ENABLE_LOAD_HISTORY is False,
|
||||
reason="tests for loading from DB are unstable, thus"
|
||||
|
@ -132,10 +132,10 @@ class TestPlant(unittest.TestCase):
|
|||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('plant.'+plant_name)
|
||||
self.assertEqual(STATE_UNKNOWN, state.state)
|
||||
assert STATE_UNKNOWN == state.state
|
||||
max_brightness = state.attributes.get(
|
||||
plant.ATTR_MAX_BRIGHTNESS_HISTORY)
|
||||
self.assertEqual(30, max_brightness)
|
||||
assert 30 == max_brightness
|
||||
|
||||
def test_brightness_history(self):
|
||||
"""Test the min_brightness check."""
|
||||
|
@ -149,19 +149,19 @@ class TestPlant(unittest.TestCase):
|
|||
{ATTR_UNIT_OF_MEASUREMENT: 'lux'})
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get('plant.'+plant_name)
|
||||
self.assertEqual(STATE_PROBLEM, state.state)
|
||||
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)
|
||||
self.assertEqual(STATE_OK, state.state)
|
||||
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)
|
||||
self.assertEqual(STATE_OK, state.state)
|
||||
assert STATE_OK == state.state
|
||||
|
||||
|
||||
class TestDailyHistory(unittest.TestCase):
|
||||
|
@ -170,7 +170,7 @@ class TestDailyHistory(unittest.TestCase):
|
|||
def test_no_data(self):
|
||||
"""Test with empty history."""
|
||||
dh = plant.DailyHistory(3)
|
||||
self.assertIsNone(dh.max)
|
||||
assert dh.max is None
|
||||
|
||||
def test_one_day(self):
|
||||
"""Test storing data for the same day."""
|
||||
|
@ -179,8 +179,8 @@ class TestDailyHistory(unittest.TestCase):
|
|||
for i in range(len(values)):
|
||||
dh.add_measurement(values[i])
|
||||
max_value = max(values[0:i+1])
|
||||
self.assertEqual(1, len(dh._days))
|
||||
self.assertEqual(dh.max, max_value)
|
||||
assert 1 == len(dh._days)
|
||||
assert dh.max == max_value
|
||||
|
||||
def test_multiple_days(self):
|
||||
"""Test storing data for different days."""
|
||||
|
@ -195,4 +195,4 @@ class TestDailyHistory(unittest.TestCase):
|
|||
|
||||
for i in range(len(days)):
|
||||
dh.add_measurement(values[i], days[i])
|
||||
self.assertEqual(max_values[i], dh.max)
|
||||
assert max_values[i] == dh.max
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue