1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Improve ecobee service schemas (#26955)

* Validate date and time in create vaction

Improve validation with utility functions.

* Improve validate ATTR_VACATION_NAME

* Add tests for ecobee.util functions

* Revise tests as standalone functions
This commit is contained in:
Mark Coombes
2019-09-28 05:32:22 -04:00
committed by Martin Hjelmare
parent 1c72a246a0
commit 2dfdc5f6f8
3 changed files with 67 additions and 6 deletions

View File

@@ -0,0 +1,35 @@
"""Tests for the ecobee.util module."""
import pytest
import voluptuous as vol
from homeassistant.components.ecobee.util import ecobee_date, ecobee_time
def test_ecobee_date_with_valid_input():
"""Test that the date function returns the expected result."""
test_input = "2019-09-27"
assert ecobee_date(test_input) == test_input
def test_ecobee_date_with_invalid_input():
"""Test that the date function raises the expected exception."""
test_input = "20190927"
with pytest.raises(vol.Invalid):
ecobee_date(test_input)
def test_ecobee_time_with_valid_input():
"""Test that the time function returns the expected result."""
test_input = "20:55:15"
assert ecobee_time(test_input) == test_input
def test_ecobee_time_with_invalid_input():
"""Test that the time function raises the expected exception."""
test_input = "20:55"
with pytest.raises(vol.Invalid):
ecobee_time(test_input)