Add typing to tests with single hass argument (2) (#87675)

* Add typing to tests with single hass argument (2)

* a few more
This commit is contained in:
epenet 2023-02-08 08:51:43 +01:00 committed by GitHub
parent 1bbc03d0ba
commit c98b4e3204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 816 additions and 671 deletions

View file

@ -1,6 +1,7 @@
"""Test script variables."""
import pytest
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, template
@ -46,14 +47,14 @@ async def test_static_vars_run_args_no_default() -> None:
assert orig == orig_copy
async def test_template_vars(hass):
async def test_template_vars(hass: HomeAssistant) -> None:
"""Test template vars."""
var = cv.SCRIPT_VARIABLES_SCHEMA({"hello": "{{ 1 + 1 }}"})
rendered = var.async_render(hass, None)
assert rendered == {"hello": 2}
async def test_template_vars_run_args(hass):
async def test_template_vars_run_args(hass: HomeAssistant) -> None:
"""Test template vars."""
var = cv.SCRIPT_VARIABLES_SCHEMA(
{
@ -75,14 +76,14 @@ async def test_template_vars_run_args(hass):
}
async def test_template_vars_no_default(hass):
async def test_template_vars_no_default(hass: HomeAssistant) -> None:
"""Test template vars."""
var = cv.SCRIPT_VARIABLES_SCHEMA({"hello": "{{ 1 + 1 }}"})
rendered = var.async_render(hass, None, render_as_defaults=False)
assert rendered == {"hello": 2}
async def test_template_vars_run_args_no_default(hass):
async def test_template_vars_run_args_no_default(hass: HomeAssistant) -> None:
"""Test template vars."""
var = cv.SCRIPT_VARIABLES_SCHEMA(
{
@ -105,7 +106,7 @@ async def test_template_vars_run_args_no_default(hass):
}
async def test_template_vars_error(hass):
async def test_template_vars_error(hass: HomeAssistant) -> None:
"""Test template vars."""
var = cv.SCRIPT_VARIABLES_SCHEMA({"hello": "{{ canont.work }}"})
with pytest.raises(template.TemplateError):