Skip to content

Commit

Permalink
Merge 1b95296 into 9db8e1d
Browse files Browse the repository at this point in the history
  • Loading branch information
exxamalte committed Nov 2, 2020
2 parents 9db8e1d + 1b95296 commit 9cd68d4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
8 changes: 7 additions & 1 deletion 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,
Expand All @@ -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."""
Expand Down
16 changes: 16 additions & 0 deletions tests/fixtures/gdacs-2.xml
Expand Up @@ -8,5 +8,21 @@
<webMaster>stefano.paris@ext.ec.europa.eu</webMaster>
<pubDate>Mon, 30 Dec 2019 01:35:11 GMT</pubDate>
<atom:link href="http://www.gdacs.org/xml/rss.xml" rel="self" type="application/rss+xml" />
<item>
<title>Entry with only bounding box geometry to be discarded</title>
<description>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.</description>
<gdacs:temporary>false</gdacs:temporary>
<link>http://www.gdacs.org/report.aspx?eventtype=TC&amp;eventid=1000643</link>
<pubDate>Sun, 29 Dec 2019 12:00:00 GMT</pubDate>
<gdacs:iscurrent>true</gdacs:iscurrent>
<gdacs:fromdate>Sun, 29 Dec 2019 12:00:00 GMT</gdacs:fromdate>
<gdacs:todate>Sun, 29 Dec 2019 12:00:00 GMT</gdacs:todate>
<gdacs:durationinweek>0</gdacs:durationinweek>
<gdacs:year>2019</gdacs:year>
<dc:subject>TC1</dc:subject>
<guid isPermaLink="false">TC1000643</guid>
<!--gdacs:bbox format = lonmin lonmax latmin latmax-->
<gdacs:bbox>55.0780533046962 81.0780533046962 -46.7828750315965 -20.7828750315965</gdacs:bbox>
</item>
</channel>
</rss>
4 changes: 2 additions & 2 deletions tests/test_feed.py
Expand Up @@ -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) == "<GdacsFeedEntry(id=TC1000643)>"
assert feed_entry.attribution == ATTRIBUTION
assert feed_entry.category == "Tropical Cyclone"
Expand Down Expand Up @@ -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) == "<GdacsFeedEntry(id=DR1013682)>"

feed_entry = entries[1]
Expand Down

0 comments on commit 9cd68d4

Please sign in to comment.