mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
add min and max jinja filters (#5765)
This commit is contained in:
parent
1546ec7778
commit
7927a6b588
@ -425,6 +425,8 @@ ENV.filters['timestamp_custom'] = timestamp_custom
|
||||
ENV.filters['timestamp_local'] = timestamp_local
|
||||
ENV.filters['timestamp_utc'] = timestamp_utc
|
||||
ENV.filters['is_defined'] = fail_when_undefined
|
||||
ENV.filters['max'] = max
|
||||
ENV.filters['min'] = min
|
||||
ENV.globals['float'] = forgiving_float
|
||||
ENV.globals['now'] = dt_util.now
|
||||
ENV.globals['utcnow'] = dt_util.utcnow
|
||||
|
@ -186,6 +186,20 @@ class TestHelpersTemplate(unittest.TestCase):
|
||||
template.Template('{{ %s | timestamp_local }}' % inp,
|
||||
self.hass).render())
|
||||
|
||||
def test_min(self):
|
||||
"""Test the min filter."""
|
||||
self.assertEqual(
|
||||
'1',
|
||||
template.Template('{{ [1, 2, 3] | min }}',
|
||||
self.hass).render())
|
||||
|
||||
def test_max(self):
|
||||
"""Test the max filter."""
|
||||
self.assertEqual(
|
||||
'3',
|
||||
template.Template('{{ [1, 2, 3] | max }}',
|
||||
self.hass).render())
|
||||
|
||||
def test_timestamp_utc(self):
|
||||
"""Test the timestamps to local filter."""
|
||||
tests = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user