Fix error when passing a whole number to location selector (#108952)

* Fix error when passing an integer to location selector

* fix tests

* more fix tests

* don't mutate original dict

* remove string testcase
This commit is contained in:
karwosts 2024-01-28 08:13:00 -05:00 committed by GitHub
parent c6ffd453d2
commit a2d707442a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -879,9 +879,9 @@ class LocationSelector(Selector[LocationSelectorConfig]):
) )
DATA_SCHEMA = vol.Schema( DATA_SCHEMA = vol.Schema(
{ {
vol.Required("latitude"): float, vol.Required("latitude"): vol.Coerce(float),
vol.Required("longitude"): float, vol.Required("longitude"): vol.Coerce(float),
vol.Optional("radius"): float, vol.Optional("radius"): vol.Coerce(float),
} }
) )

View File

@ -858,6 +858,11 @@ def test_language_selector_schema(schema, valid_selections, invalid_selections)
"longitude": 2.0, "longitude": 2.0,
"radius": 3.0, "radius": 3.0,
}, },
{
"latitude": 1,
"longitude": 2,
"radius": 3,
},
), ),
( (
None, None,
@ -865,7 +870,6 @@ def test_language_selector_schema(schema, valid_selections, invalid_selections)
{}, {},
{"latitude": 1.0}, {"latitude": 1.0},
{"longitude": 1.0}, {"longitude": 1.0},
{"latitude": 1.0, "longitude": "1.0"},
), ),
), ),
), ),