Geo Location -> Geolocation (class names and unit test comments) (#19877)
* fixed geolocation naming in class names * fixed geolocation naming in comments in unit test
This commit is contained in:
parent
f73bda1218
commit
6d3343e4d1
8 changed files with 16 additions and 16 deletions
|
@ -35,7 +35,7 @@ async def async_setup(hass, config):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class GeoLocationEvent(Entity):
|
class GeolocationEvent(Entity):
|
||||||
"""This represents an external event with an associated geolocation."""
|
"""This represents an external event with an associated geolocation."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -10,7 +10,7 @@ from math import cos, pi, radians, sin
|
||||||
import random
|
import random
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from homeassistant.components.geo_location import GeoLocationEvent
|
from homeassistant.components.geo_location import GeolocationEvent
|
||||||
from homeassistant.helpers.event import track_time_interval
|
from homeassistant.helpers.event import track_time_interval
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -62,7 +62,7 @@ class DemoManager:
|
||||||
cos(radians(home_latitude))
|
cos(radians(home_latitude))
|
||||||
|
|
||||||
event_name = random.choice(EVENT_NAMES)
|
event_name = random.choice(EVENT_NAMES)
|
||||||
return DemoGeoLocationEvent(event_name, radius_in_km, latitude,
|
return DemoGeolocationEvent(event_name, radius_in_km, latitude,
|
||||||
longitude, DEFAULT_UNIT_OF_MEASUREMENT)
|
longitude, DEFAULT_UNIT_OF_MEASUREMENT)
|
||||||
|
|
||||||
def _init_regular_updates(self):
|
def _init_regular_updates(self):
|
||||||
|
@ -90,7 +90,7 @@ class DemoManager:
|
||||||
self._add_entities(new_devices)
|
self._add_entities(new_devices)
|
||||||
|
|
||||||
|
|
||||||
class DemoGeoLocationEvent(GeoLocationEvent):
|
class DemoGeolocationEvent(GeolocationEvent):
|
||||||
"""This represents a demo geolocation event."""
|
"""This represents a demo geolocation event."""
|
||||||
|
|
||||||
def __init__(self, name, distance, latitude, longitude,
|
def __init__(self, name, distance, latitude, longitude,
|
||||||
|
|
|
@ -11,7 +11,7 @@ from typing import Optional
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.geo_location import (
|
from homeassistant.components.geo_location import (
|
||||||
PLATFORM_SCHEMA, GeoLocationEvent)
|
PLATFORM_SCHEMA, GeolocationEvent)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_RADIUS, CONF_SCAN_INTERVAL, CONF_URL, EVENT_HOMEASSISTANT_START,
|
CONF_RADIUS, CONF_SCAN_INTERVAL, CONF_URL, EVENT_HOMEASSISTANT_START,
|
||||||
CONF_LATITUDE, CONF_LONGITUDE)
|
CONF_LATITUDE, CONF_LONGITUDE)
|
||||||
|
@ -108,7 +108,7 @@ class GeoJsonFeedEntityManager:
|
||||||
dispatcher_send(self._hass, SIGNAL_DELETE_ENTITY.format(external_id))
|
dispatcher_send(self._hass, SIGNAL_DELETE_ENTITY.format(external_id))
|
||||||
|
|
||||||
|
|
||||||
class GeoJsonLocationEvent(GeoLocationEvent):
|
class GeoJsonLocationEvent(GeolocationEvent):
|
||||||
"""This represents an external event with GeoJSON data."""
|
"""This represents an external event with GeoJSON data."""
|
||||||
|
|
||||||
def __init__(self, feed_manager, external_id):
|
def __init__(self, feed_manager, external_id):
|
||||||
|
|
|
@ -11,7 +11,7 @@ from typing import Optional
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.geo_location import (
|
from homeassistant.components.geo_location import (
|
||||||
PLATFORM_SCHEMA, GeoLocationEvent)
|
PLATFORM_SCHEMA, GeolocationEvent)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION, ATTR_LOCATION, CONF_RADIUS, CONF_SCAN_INTERVAL,
|
ATTR_ATTRIBUTION, ATTR_LOCATION, CONF_RADIUS, CONF_SCAN_INTERVAL,
|
||||||
EVENT_HOMEASSISTANT_START, CONF_LATITUDE, CONF_LONGITUDE)
|
EVENT_HOMEASSISTANT_START, CONF_LATITUDE, CONF_LONGITUDE)
|
||||||
|
@ -129,7 +129,7 @@ class NswRuralFireServiceFeedEntityManager:
|
||||||
dispatcher_send(self._hass, SIGNAL_DELETE_ENTITY.format(external_id))
|
dispatcher_send(self._hass, SIGNAL_DELETE_ENTITY.format(external_id))
|
||||||
|
|
||||||
|
|
||||||
class NswRuralFireServiceLocationEvent(GeoLocationEvent):
|
class NswRuralFireServiceLocationEvent(GeolocationEvent):
|
||||||
"""This represents an external event with NSW Rural Fire Service data."""
|
"""This represents an external event with NSW Rural Fire Service data."""
|
||||||
|
|
||||||
def __init__(self, feed_manager, external_id):
|
def __init__(self, feed_manager, external_id):
|
||||||
|
|
|
@ -11,7 +11,7 @@ from typing import Optional
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.geo_location import (
|
from homeassistant.components.geo_location import (
|
||||||
PLATFORM_SCHEMA, GeoLocationEvent)
|
PLATFORM_SCHEMA, GeolocationEvent)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION, CONF_RADIUS, CONF_SCAN_INTERVAL,
|
ATTR_ATTRIBUTION, CONF_RADIUS, CONF_SCAN_INTERVAL,
|
||||||
EVENT_HOMEASSISTANT_START, CONF_LATITUDE, CONF_LONGITUDE)
|
EVENT_HOMEASSISTANT_START, CONF_LATITUDE, CONF_LONGITUDE)
|
||||||
|
@ -148,7 +148,7 @@ class UsgsEarthquakesFeedEntityManager:
|
||||||
dispatcher_send(self._hass, SIGNAL_DELETE_ENTITY.format(external_id))
|
dispatcher_send(self._hass, SIGNAL_DELETE_ENTITY.format(external_id))
|
||||||
|
|
||||||
|
|
||||||
class UsgsEarthquakesEvent(GeoLocationEvent):
|
class UsgsEarthquakesEvent(GeolocationEvent):
|
||||||
"""This represents an external event with USGS Earthquake data."""
|
"""This represents an external event with USGS Earthquake data."""
|
||||||
|
|
||||||
def __init__(self, feed_manager, external_id):
|
def __init__(self, feed_manager, external_id):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""The tests for the geo location trigger."""
|
"""The tests for the geolocation trigger."""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components import automation, zone
|
from homeassistant.components import automation, zone
|
||||||
|
|
|
@ -39,7 +39,7 @@ class TestDemoPlatform(unittest.TestCase):
|
||||||
with assert_setup_component(1, geo_location.DOMAIN):
|
with assert_setup_component(1, geo_location.DOMAIN):
|
||||||
assert setup_component(self.hass, geo_location.DOMAIN, CONFIG)
|
assert setup_component(self.hass, geo_location.DOMAIN, CONFIG)
|
||||||
|
|
||||||
# In this test, only entities of the geo location domain have been
|
# In this test, only entities of the geolocation domain have been
|
||||||
# generated.
|
# generated.
|
||||||
all_states = self.hass.states.all()
|
all_states = self.hass.states.all()
|
||||||
assert len(all_states) == NUMBER_OF_DEMO_DEVICES
|
assert len(all_states) == NUMBER_OF_DEMO_DEVICES
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
"""The tests for the geo location component."""
|
"""The tests for the geolocation component."""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components import geo_location
|
from homeassistant.components import geo_location
|
||||||
from homeassistant.components.geo_location import GeoLocationEvent
|
from homeassistant.components.geo_location import GeolocationEvent
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ async def test_setup_component(hass):
|
||||||
|
|
||||||
|
|
||||||
async def test_event(hass):
|
async def test_event(hass):
|
||||||
"""Simple test of the geo location event class."""
|
"""Simple test of the geolocation event class."""
|
||||||
entity = GeoLocationEvent()
|
entity = GeolocationEvent()
|
||||||
|
|
||||||
assert entity.state is None
|
assert entity.state is None
|
||||||
assert entity.distance is None
|
assert entity.distance is None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue