Avoid CI fail in command_line tests (#96324)
* Avoid CI fail in command_line tests * Speedup tests manual update
This commit is contained in:
parent
d9f27400b7
commit
f12f8bca03
4 changed files with 34 additions and 38 deletions
|
@ -240,16 +240,18 @@ async def test_updating_to_often(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(called) == 1
|
assert called
|
||||||
assert (
|
assert (
|
||||||
"Updating Command Line Binary Sensor Test took longer than the scheduled update interval"
|
"Updating Command Line Binary Sensor Test took longer than the scheduled update interval"
|
||||||
not in caplog.text
|
not in caplog.text
|
||||||
)
|
)
|
||||||
|
called.clear()
|
||||||
|
caplog.clear()
|
||||||
|
|
||||||
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=1))
|
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=1))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(called) == 2
|
assert called
|
||||||
assert (
|
assert (
|
||||||
"Updating Command Line Binary Sensor Test took longer than the scheduled update interval"
|
"Updating Command Line Binary Sensor Test took longer than the scheduled update interval"
|
||||||
in caplog.text
|
in caplog.text
|
||||||
|
@ -266,13 +268,11 @@ async def test_updating_manually(
|
||||||
called = []
|
called = []
|
||||||
|
|
||||||
class MockCommandBinarySensor(CommandBinarySensor):
|
class MockCommandBinarySensor(CommandBinarySensor):
|
||||||
"""Mock entity that updates slow."""
|
"""Mock entity that updates."""
|
||||||
|
|
||||||
async def _async_update(self) -> None:
|
async def _async_update(self) -> None:
|
||||||
"""Update slow."""
|
"""Update."""
|
||||||
called.append(1)
|
called.append(1)
|
||||||
# Add waiting time
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.command_line.binary_sensor.CommandBinarySensor",
|
"homeassistant.components.command_line.binary_sensor.CommandBinarySensor",
|
||||||
|
@ -297,7 +297,8 @@ async def test_updating_manually(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(called) == 1
|
assert called
|
||||||
|
called.clear
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
HA_DOMAIN,
|
HA_DOMAIN,
|
||||||
|
@ -306,6 +307,4 @@ async def test_updating_manually(
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(called) == 2
|
assert called
|
||||||
|
|
||||||
await asyncio.sleep(0.2)
|
|
||||||
|
|
|
@ -326,16 +326,18 @@ async def test_updating_to_often(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(called) == 0
|
assert not called
|
||||||
assert (
|
assert (
|
||||||
"Updating Command Line Cover Test took longer than the scheduled update interval"
|
"Updating Command Line Cover Test took longer than the scheduled update interval"
|
||||||
not in caplog.text
|
not in caplog.text
|
||||||
)
|
)
|
||||||
|
called.clear()
|
||||||
|
caplog.clear()
|
||||||
|
|
||||||
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=1))
|
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=1))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(called) == 1
|
assert called
|
||||||
assert (
|
assert (
|
||||||
"Updating Command Line Cover Test took longer than the scheduled update interval"
|
"Updating Command Line Cover Test took longer than the scheduled update interval"
|
||||||
in caplog.text
|
in caplog.text
|
||||||
|
@ -352,13 +354,11 @@ async def test_updating_manually(
|
||||||
called = []
|
called = []
|
||||||
|
|
||||||
class MockCommandCover(CommandCover):
|
class MockCommandCover(CommandCover):
|
||||||
"""Mock entity that updates slow."""
|
"""Mock entity that updates."""
|
||||||
|
|
||||||
async def _async_update(self) -> None:
|
async def _async_update(self) -> None:
|
||||||
"""Update slow."""
|
"""Update."""
|
||||||
called.append(1)
|
called.append(1)
|
||||||
# Add waiting time
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.command_line.cover.CommandCover",
|
"homeassistant.components.command_line.cover.CommandCover",
|
||||||
|
@ -384,7 +384,8 @@ async def test_updating_manually(
|
||||||
|
|
||||||
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=10))
|
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=10))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(called) == 1
|
assert called
|
||||||
|
called.clear()
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
HA_DOMAIN,
|
HA_DOMAIN,
|
||||||
|
@ -393,6 +394,4 @@ async def test_updating_manually(
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(called) == 2
|
assert called
|
||||||
|
|
||||||
await asyncio.sleep(0.2)
|
|
||||||
|
|
|
@ -575,16 +575,18 @@ async def test_updating_to_often(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(called) == 1
|
assert called
|
||||||
assert (
|
assert (
|
||||||
"Updating Command Line Sensor Test took longer than the scheduled update interval"
|
"Updating Command Line Sensor Test took longer than the scheduled update interval"
|
||||||
not in caplog.text
|
not in caplog.text
|
||||||
)
|
)
|
||||||
|
called.clear()
|
||||||
|
caplog.clear()
|
||||||
|
|
||||||
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=1))
|
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=1))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(called) == 2
|
assert called
|
||||||
assert (
|
assert (
|
||||||
"Updating Command Line Sensor Test took longer than the scheduled update interval"
|
"Updating Command Line Sensor Test took longer than the scheduled update interval"
|
||||||
in caplog.text
|
in caplog.text
|
||||||
|
@ -601,13 +603,11 @@ async def test_updating_manually(
|
||||||
called = []
|
called = []
|
||||||
|
|
||||||
class MockCommandSensor(CommandSensor):
|
class MockCommandSensor(CommandSensor):
|
||||||
"""Mock entity that updates slow."""
|
"""Mock entity that updates."""
|
||||||
|
|
||||||
async def _async_update(self) -> None:
|
async def _async_update(self) -> None:
|
||||||
"""Update slow."""
|
"""Update slow."""
|
||||||
called.append(1)
|
called.append(1)
|
||||||
# Add waiting time
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.command_line.sensor.CommandSensor",
|
"homeassistant.components.command_line.sensor.CommandSensor",
|
||||||
|
@ -630,7 +630,8 @@ async def test_updating_manually(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(called) == 1
|
assert called
|
||||||
|
called.clear()
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
HA_DOMAIN,
|
HA_DOMAIN,
|
||||||
|
@ -639,6 +640,4 @@ async def test_updating_manually(
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(called) == 2
|
assert called
|
||||||
|
|
||||||
await asyncio.sleep(0.2)
|
|
||||||
|
|
|
@ -684,16 +684,18 @@ async def test_updating_to_often(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(called) == 0
|
assert not called
|
||||||
assert (
|
assert (
|
||||||
"Updating Command Line Switch Test took longer than the scheduled update interval"
|
"Updating Command Line Switch Test took longer than the scheduled update interval"
|
||||||
not in caplog.text
|
not in caplog.text
|
||||||
)
|
)
|
||||||
|
called.clear()
|
||||||
|
caplog.clear()
|
||||||
|
|
||||||
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=1))
|
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=1))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert len(called) == 1
|
assert called
|
||||||
assert (
|
assert (
|
||||||
"Updating Command Line Switch Test took longer than the scheduled update interval"
|
"Updating Command Line Switch Test took longer than the scheduled update interval"
|
||||||
in caplog.text
|
in caplog.text
|
||||||
|
@ -710,13 +712,11 @@ async def test_updating_manually(
|
||||||
called = []
|
called = []
|
||||||
|
|
||||||
class MockCommandSwitch(CommandSwitch):
|
class MockCommandSwitch(CommandSwitch):
|
||||||
"""Mock entity that updates slow."""
|
"""Mock entity that updates."""
|
||||||
|
|
||||||
async def _async_update(self) -> None:
|
async def _async_update(self) -> None:
|
||||||
"""Update slow."""
|
"""Update slow."""
|
||||||
called.append(1)
|
called.append(1)
|
||||||
# Add waiting time
|
|
||||||
await asyncio.sleep(1)
|
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.command_line.switch.CommandSwitch",
|
"homeassistant.components.command_line.switch.CommandSwitch",
|
||||||
|
@ -743,7 +743,8 @@ async def test_updating_manually(
|
||||||
|
|
||||||
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=10))
|
async_fire_time_changed(hass, dt_util.now() + timedelta(seconds=10))
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(called) == 1
|
assert called
|
||||||
|
called.clear()
|
||||||
|
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
HA_DOMAIN,
|
HA_DOMAIN,
|
||||||
|
@ -752,6 +753,4 @@ async def test_updating_manually(
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert len(called) == 2
|
assert called
|
||||||
|
|
||||||
await asyncio.sleep(0.2)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue