Move imports in geo_rss_events component (#27313)

* move imports to top-level

* fixed patch path

* added myself as codeowner

* regenerated codeowners
This commit is contained in:
Malte Franken 2019-10-08 21:50:46 +11:00 committed by Fabian Affolter
parent 5645d43bd1
commit 15c56f1f64
4 changed files with 11 additions and 8 deletions

View File

@ -105,6 +105,7 @@ homeassistant/components/fronius/* @nielstron
homeassistant/components/frontend/* @home-assistant/frontend homeassistant/components/frontend/* @home-assistant/frontend
homeassistant/components/gearbest/* @HerrHofrat homeassistant/components/gearbest/* @HerrHofrat
homeassistant/components/geniushub/* @zxdavb homeassistant/components/geniushub/* @zxdavb
homeassistant/components/geo_rss_events/* @exxamalte
homeassistant/components/geonetnz_quakes/* @exxamalte homeassistant/components/geonetnz_quakes/* @exxamalte
homeassistant/components/gitter/* @fabaff homeassistant/components/gitter/* @fabaff
homeassistant/components/glances/* @fabaff homeassistant/components/glances/* @fabaff

View File

@ -1,10 +1,12 @@
{ {
"domain": "geo_rss_events", "domain": "geo_rss_events",
"name": "Geo rss events", "name": "Geo RSS events",
"documentation": "https://www.home-assistant.io/integrations/geo_rss_events", "documentation": "https://www.home-assistant.io/integrations/geo_rss_events",
"requirements": [ "requirements": [
"georss_generic_client==0.2" "georss_generic_client==0.2"
], ],
"dependencies": [], "dependencies": [],
"codeowners": [] "codeowners": [
"@exxamalte"
]
} }

View File

@ -12,6 +12,8 @@ import logging
from datetime import timedelta from datetime import timedelta
import voluptuous as vol 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 import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.components.sensor import PLATFORM_SCHEMA
@ -108,7 +110,6 @@ class GeoRssServiceSensor(Entity):
self._state = None self._state = None
self._state_attributes = None self._state_attributes = None
self._unit_of_measurement = unit_of_measurement self._unit_of_measurement = unit_of_measurement
from georss_client.generic_feed import GenericFeed
self._feed = GenericFeed( self._feed = GenericFeed(
coordinates, coordinates,
@ -146,10 +147,9 @@ class GeoRssServiceSensor(Entity):
def update(self): def update(self):
"""Update this sensor from the GeoRSS service.""" """Update this sensor from the GeoRSS service."""
import georss_client
status, feed_entries = self._feed.update() status, feed_entries = self._feed.update()
if status == georss_client.UPDATE_OK: if status == UPDATE_OK:
_LOGGER.debug( _LOGGER.debug(
"Adding events to sensor %s: %s", self.entity_id, feed_entries "Adding events to sensor %s: %s", self.entity_id, feed_entries
) )
@ -159,7 +159,7 @@ class GeoRssServiceSensor(Entity):
for entry in feed_entries: for entry in feed_entries:
matrix[entry.title] = f"{entry.distance_to_home:.0f}km" matrix[entry.title] = f"{entry.distance_to_home:.0f}km"
self._state_attributes = matrix 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) _LOGGER.debug("Update successful, but no data received from %s", self._feed)
# Don't change the state or state attributes. # Don't change the state or state attributes.
else: else:

View File

@ -59,7 +59,7 @@ class TestGeoRssServiceUpdater(unittest.TestCase):
feed_entry.category = category feed_entry.category = category
return feed_entry 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): def test_setup(self, mock_feed):
"""Test the general setup of the platform.""" """Test the general setup of the platform."""
# Set up some mock feed entries for this test. # Set up some mock feed entries for this test.
@ -122,7 +122,7 @@ class TestGeoRssServiceUpdater(unittest.TestCase):
ATTR_ICON: "mdi:alert", 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): def test_setup_with_categories(self, mock_feed):
"""Test the general setup of the platform.""" """Test the general setup of the platform."""
# Set up some mock feed entries for this test. # Set up some mock feed entries for this test.