diff --git a/aio_georss_gdacs/feed_entry.py b/aio_georss_gdacs/feed_entry.py index e277baf..4f3887b 100644 --- a/aio_georss_gdacs/feed_entry.py +++ b/aio_georss_gdacs/feed_entry.py @@ -1,11 +1,12 @@ """GDACS feed entry.""" from collections.abc import Mapping from datetime import datetime -from typing import Optional, Tuple, Union +from typing import Optional, Tuple, Union, List, Type import dateparser from aio_georss_client.feed_entry import FeedEntry from aio_georss_client.xml_parser.feed_item import FeedItem +from aio_georss_client.xml_parser.geometry import Geometry, Polygon, Point from .consts import (ATTRIBUTION, EVENT_TYPE_MAP, XML_ATTRIBUTE_VALUE, XML_TAG_GDACS_ALERT_LEVEL, XML_TAG_GDACS_COUNTRY, @@ -27,6 +28,11 @@ def __init__(self, """Initialise this service.""" super().__init__(home_coordinates, feature) + @property + def features(self) -> List[Type[Geometry]]: + """Only consider Point and Polygon in this integration.""" + return [Point, Polygon] + @property def attribution(self) -> Optional[str]: """Return the attribution of this entry.""" diff --git a/tests/fixtures/gdacs-2.xml b/tests/fixtures/gdacs-2.xml index a19b7d1..4870a8c 100644 --- a/tests/fixtures/gdacs-2.xml +++ b/tests/fixtures/gdacs-2.xml @@ -8,5 +8,21 @@ stefano.paris@ext.ec.europa.eu Mon, 30 Dec 2019 01:35:11 GMT + + Entry with only bounding box geometry to be discarded + From 29/12/2019 to 29/12/2019, a Tropical Storm (maximum wind speed of 93 km/h) CALVINIA-19 was active in SWIndian. The cyclone affects these countries: Mauritius (vulnerability Medium). Estimated population affected by category 1 (120 km/h) wind speeds or higher is 0. + false + http://www.gdacs.org/report.aspx?eventtype=TC&eventid=1000643 + Sun, 29 Dec 2019 12:00:00 GMT + true + Sun, 29 Dec 2019 12:00:00 GMT + Sun, 29 Dec 2019 12:00:00 GMT + 0 + 2019 + TC1 + TC1000643 + + 55.0780533046962 81.0780533046962 -46.7828750315965 -20.7828750315965 + \ No newline at end of file diff --git a/tests/test_feed.py b/tests/test_feed.py index 26193fe..509ae03 100644 --- a/tests/test_feed.py +++ b/tests/test_feed.py @@ -44,7 +44,7 @@ async def test_update_ok(aresponses, event_loop): assert feed_entry.external_id == "TC1000643" assert feed_entry.coordinates[0] == pytest.approx(-19.4) assert feed_entry.coordinates[1] == pytest.approx(59.8) - assert round(abs(feed_entry.distance_to_home - 7398.9), 1) == 0 + assert round(abs(feed_entry.distance_to_home - 10517.9), 1) == 0 assert repr(feed_entry) == "" assert feed_entry.attribution == ATTRIBUTION assert feed_entry.category == "Tropical Cyclone" @@ -117,7 +117,7 @@ async def test_update_ok_with_categories_filter(aresponses, event_loop): assert feed_entry.external_id == "DR1013682" assert feed_entry.coordinates[0] == pytest.approx(39.544) assert feed_entry.coordinates[1] == pytest.approx(31.926) - assert round(abs(feed_entry.distance_to_home - 16401.1), 1) == 0 + assert round(abs(feed_entry.distance_to_home - 16880.3), 1) == 0 assert repr(feed_entry) == "" feed_entry = entries[1]