mirror of
https://github.com/home-assistant/core.git
synced 2026-05-03 07:01:43 +01:00
Streamline template tests (#154586)
This commit is contained in:
@@ -5,7 +5,8 @@ from __future__ import annotations
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import template
|
||||
|
||||
from tests.helpers.template.helpers import render
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -18,26 +19,19 @@ from homeassistant.helpers import template
|
||||
)
|
||||
def test_base64_encode(hass: HomeAssistant, value_template: str, expected: str) -> None:
|
||||
"""Test the base64_encode filter."""
|
||||
assert template.Template(value_template, hass).async_render() == expected
|
||||
assert render(hass, value_template) == expected
|
||||
|
||||
|
||||
def test_base64_decode(hass: HomeAssistant) -> None:
|
||||
"""Test the base64_decode filter."""
|
||||
assert (
|
||||
template.Template(
|
||||
'{{ "aG9tZWFzc2lzdGFudA==" | base64_decode }}', hass
|
||||
).async_render()
|
||||
== "homeassistant"
|
||||
render(hass, '{{ "aG9tZWFzc2lzdGFudA==" | base64_decode }}') == "homeassistant"
|
||||
)
|
||||
assert (
|
||||
template.Template(
|
||||
'{{ "aG9tZWFzc2lzdGFudA==" | base64_decode(None) }}', hass
|
||||
).async_render()
|
||||
render(hass, '{{ "aG9tZWFzc2lzdGFudA==" | base64_decode(None) }}')
|
||||
== b"homeassistant"
|
||||
)
|
||||
assert (
|
||||
template.Template(
|
||||
'{{ "aG9tZWFzc2lzdGFudA==" | base64_decode("ascii") }}', hass
|
||||
).async_render()
|
||||
render(hass, '{{ "aG9tZWFzc2lzdGFudA==" | base64_decode("ascii") }}')
|
||||
== "homeassistant"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user