Move imports in geo_rss_events component (#27313)
* move imports to top-level * fixed patch path * added myself as codeowner * regenerated codeownerspull/27322/head
parent
5645d43bd1
commit
15c56f1f64
homeassistant/components/geo_rss_events
tests/components/geo_rss_events
|
@ -105,6 +105,7 @@ homeassistant/components/fronius/* @nielstron
|
|||
homeassistant/components/frontend/* @home-assistant/frontend
|
||||
homeassistant/components/gearbest/* @HerrHofrat
|
||||
homeassistant/components/geniushub/* @zxdavb
|
||||
homeassistant/components/geo_rss_events/* @exxamalte
|
||||
homeassistant/components/geonetnz_quakes/* @exxamalte
|
||||
homeassistant/components/gitter/* @fabaff
|
||||
homeassistant/components/glances/* @fabaff
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
"domain": "geo_rss_events",
|
||||
"name": "Geo rss events",
|
||||
"name": "Geo RSS events",
|
||||
"documentation": "https://www.home-assistant.io/integrations/geo_rss_events",
|
||||
"requirements": [
|
||||
"georss_generic_client==0.2"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": []
|
||||
"codeowners": [
|
||||
"@exxamalte"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import logging
|
|||
from datetime import timedelta
|
||||
|
||||
import voluptuous as vol
|
||||
from georss_client import UPDATE_OK, UPDATE_OK_NO_DATA
|
||||
from georss_client.generic_feed import GenericFeed
|
||||
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
|
@ -108,7 +110,6 @@ class GeoRssServiceSensor(Entity):
|
|||
self._state = None
|
||||
self._state_attributes = None
|
||||
self._unit_of_measurement = unit_of_measurement
|
||||
from georss_client.generic_feed import GenericFeed
|
||||
|
||||
self._feed = GenericFeed(
|
||||
coordinates,
|
||||
|
@ -146,10 +147,9 @@ class GeoRssServiceSensor(Entity):
|
|||
|
||||
def update(self):
|
||||
"""Update this sensor from the GeoRSS service."""
|
||||
import georss_client
|
||||
|
||||
status, feed_entries = self._feed.update()
|
||||
if status == georss_client.UPDATE_OK:
|
||||
if status == UPDATE_OK:
|
||||
_LOGGER.debug(
|
||||
"Adding events to sensor %s: %s", self.entity_id, feed_entries
|
||||
)
|
||||
|
@ -159,7 +159,7 @@ class GeoRssServiceSensor(Entity):
|
|||
for entry in feed_entries:
|
||||
matrix[entry.title] = f"{entry.distance_to_home:.0f}km"
|
||||
self._state_attributes = matrix
|
||||
elif status == georss_client.UPDATE_OK_NO_DATA:
|
||||
elif status == UPDATE_OK_NO_DATA:
|
||||
_LOGGER.debug("Update successful, but no data received from %s", self._feed)
|
||||
# Don't change the state or state attributes.
|
||||
else:
|
||||
|
|
|
@ -59,7 +59,7 @@ class TestGeoRssServiceUpdater(unittest.TestCase):
|
|||
feed_entry.category = category
|
||||
return feed_entry
|
||||
|
||||
@mock.patch("georss_client.generic_feed.GenericFeed")
|
||||
@mock.patch("homeassistant.components.geo_rss_events.sensor.GenericFeed")
|
||||
def test_setup(self, mock_feed):
|
||||
"""Test the general setup of the platform."""
|
||||
# Set up some mock feed entries for this test.
|
||||
|
@ -122,7 +122,7 @@ class TestGeoRssServiceUpdater(unittest.TestCase):
|
|||
ATTR_ICON: "mdi:alert",
|
||||
}
|
||||
|
||||
@mock.patch("georss_client.generic_feed.GenericFeed")
|
||||
@mock.patch("homeassistant.components.geo_rss_events.sensor.GenericFeed")
|
||||
def test_setup_with_categories(self, mock_feed):
|
||||
"""Test the general setup of the platform."""
|
||||
# Set up some mock feed entries for this test.
|
||||
|
|
Loading…
Reference in New Issue