From 99d732b9748948799b50aaef8ff5acc30a6a70fe Mon Sep 17 00:00:00 2001 From: guillempages Date: Sun, 22 Mar 2020 01:48:18 +0100 Subject: [PATCH] Revert "Validate UUID for tankerkoenig (#32805)" (#33123) This reverts commit 49c2a4a4e3290de32cf3a10fd17f5c7a1f0234de. The validation was causing more problems than it was fixing, so removed it completely --- .../components/tankerkoenig/__init__.py | 20 ++---------- requirements_test_all.txt | 3 -- tests/components/tankerkoenig/__init__.py | 1 - .../test_tankerkoenig_validators.py | 32 ------------------- 4 files changed, 2 insertions(+), 54 deletions(-) delete mode 100755 tests/components/tankerkoenig/__init__.py delete mode 100755 tests/components/tankerkoenig/test_tankerkoenig_validators.py diff --git a/homeassistant/components/tankerkoenig/__init__.py b/homeassistant/components/tankerkoenig/__init__.py index 3f654f24522..e8b4e92327c 100755 --- a/homeassistant/components/tankerkoenig/__init__.py +++ b/homeassistant/components/tankerkoenig/__init__.py @@ -2,7 +2,6 @@ from datetime import timedelta import logging from math import ceil -from uuid import UUID import pytankerkoenig import voluptuous as vol @@ -26,26 +25,11 @@ _LOGGER = logging.getLogger(__name__) DEFAULT_RADIUS = 2 DEFAULT_SCAN_INTERVAL = timedelta(minutes=30) - -def uuid4_string(value): - """Validate a v4 UUID in string format.""" - try: - result = UUID(value, version=4) - except (ValueError, AttributeError, TypeError) as error: - raise vol.Invalid("Invalid Version4 UUID", error_message=str(error)) - - if str(result) != value.lower(): - # UUID() will create a uuid4 if input is invalid - raise vol.Invalid("Invalid Version4 UUID") - - return str(result) - - CONFIG_SCHEMA = vol.Schema( { DOMAIN: vol.Schema( { - vol.Required(CONF_API_KEY): uuid4_string, + vol.Required(CONF_API_KEY): cv.string, vol.Optional( CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL ): cv.time_period, @@ -66,7 +50,7 @@ CONFIG_SCHEMA = vol.Schema( cv.positive_int, vol.Range(min=1) ), vol.Optional(CONF_STATIONS, default=[]): vol.All( - cv.ensure_list, [uuid4_string] + cv.ensure_list, [cv.string] ), } ) diff --git a/requirements_test_all.txt b/requirements_test_all.txt index f0df372cde9..ba6f4d05565 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -588,9 +588,6 @@ pysonos==0.0.25 # homeassistant.components.spc pyspcwebgw==0.4.0 -# homeassistant.components.tankerkoenig -pytankerkoenig==0.0.6 - # homeassistant.components.ecobee python-ecobee-api==0.2.2 diff --git a/tests/components/tankerkoenig/__init__.py b/tests/components/tankerkoenig/__init__.py deleted file mode 100755 index c420d23e157..00000000000 --- a/tests/components/tankerkoenig/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Tests for the tankerkoenig integration.""" diff --git a/tests/components/tankerkoenig/test_tankerkoenig_validators.py b/tests/components/tankerkoenig/test_tankerkoenig_validators.py deleted file mode 100755 index 7dba88b24fb..00000000000 --- a/tests/components/tankerkoenig/test_tankerkoenig_validators.py +++ /dev/null @@ -1,32 +0,0 @@ -"""The tests for the custom tankerkoenig validators.""" -import unittest -import uuid - -import pytest -import voluptuous as vol - -from homeassistant.components.tankerkoenig import uuid4_string - - -class TestUUID4StringValidator(unittest.TestCase): - """Test the UUID4 string custom validator.""" - - def test_uuid4_string(caplog): - """Test string uuid validation.""" - schema = vol.Schema(uuid4_string) - - for value in ["Not a hex string", "0", 0]: - with pytest.raises(vol.Invalid): - schema(value) - - with pytest.raises(vol.Invalid): - # the third block should start with 4 - schema("a03d31b2-2eee-2acc-bb90-eec40be6ed23") - - with pytest.raises(vol.Invalid): - # the fourth block should start with 8-a - schema("a03d31b2-2eee-4acc-1b90-eec40be6ed23") - - _str = str(uuid.uuid4()) - assert schema(_str) == _str - assert schema(_str.upper()) == _str