mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 04:50:05 +00:00
Remove manual rate_limit control directive from templates (#41225)
Increase default rate limit for all states and entire domain states to one minute Ensure specifically referenced entities are excluded from the rate limit
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""Test Home Assistant template helper methods."""
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime
|
||||
import math
|
||||
import random
|
||||
|
||||
@@ -2617,28 +2617,3 @@ async def test_unavailable_states(hass):
|
||||
hass,
|
||||
)
|
||||
assert tpl.async_render() == "light.none, light.unavailable, light.unknown"
|
||||
|
||||
|
||||
async def test_rate_limit(hass):
|
||||
"""Test we can pickup a rate limit directive."""
|
||||
tmp = template.Template("{{ states | count }}", hass)
|
||||
|
||||
info = tmp.async_render_to_info()
|
||||
assert info.rate_limit is None
|
||||
|
||||
tmp = template.Template("{{ rate_limit(minutes=1) }}{{ states | count }}", hass)
|
||||
|
||||
info = tmp.async_render_to_info()
|
||||
assert info.rate_limit == timedelta(minutes=1)
|
||||
|
||||
tmp = template.Template("{{ rate_limit(minutes=1) }}random", hass)
|
||||
|
||||
info = tmp.async_render_to_info()
|
||||
assert info.result() == "random"
|
||||
assert info.rate_limit == timedelta(minutes=1)
|
||||
|
||||
tmp = template.Template("{{ rate_limit(seconds=0) }}random", hass)
|
||||
|
||||
info = tmp.async_render_to_info()
|
||||
assert info.result() == "random"
|
||||
assert info.rate_limit == timedelta(seconds=0)
|
||||
|
||||
Reference in New Issue
Block a user