1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 11:22:24 +01:00

Feature/fix unit tests (#1129)

This commit is contained in:
Peter Kuehne
2020-07-14 12:11:58 +01:00
committed by GitHub
parent c8a4eb426c
commit 2012c769f6
4 changed files with 56 additions and 52 deletions

View File

@@ -9,22 +9,24 @@ from esphome.config_validation import Invalid
from esphome.core import Lambda, HexInt
def test_check_not_tamplatable__invalid():
def test_check_not_templatable__invalid():
with pytest.raises(Invalid, match="This option is not templatable!"):
config_validation.check_not_templatable(Lambda(""))
@given(one_of(
booleans(),
integers(),
text(alphabet=string.ascii_letters + string.digits)),
)
@pytest.mark.parametrize("value", ("foo", 1, "D12", False))
def test_alphanumeric__valid(value):
actual = config_validation.alphanumeric(value)
assert actual == str(value)
@pytest.mark.parametrize("value", ("£23", "Foo!"))
def test_alphanumeric__invalid(value):
with pytest.raises(Invalid):
actual = config_validation.alphanumeric(value)
@given(value=text(alphabet=string.ascii_lowercase + string.digits + "_"))
def test_valid_name__valid(value):
actual = config_validation.valid_name(value)
@@ -110,4 +112,3 @@ def hex_int__valid(value):
assert isinstance(actual, HexInt)
assert actual == value