fix feedreader handling unrecognized published date (#28225)
parent
82729bef70
commit
d200c2dca2
|
@ -139,9 +139,10 @@ class FeedManager:
|
|||
|
||||
def _update_and_fire_entry(self, entry):
|
||||
"""Update last_entry_timestamp and fire entry."""
|
||||
# We are lucky, `published_parsed` data available, let's make use of
|
||||
# it to publish only new available entries since the last run
|
||||
if "published_parsed" in entry.keys():
|
||||
# Check if the entry has a published date.
|
||||
if "published_parsed" in entry.keys() and entry.published_parsed:
|
||||
# We are lucky, `published_parsed` data available, let's make use of
|
||||
# it to publish only new available entries since the last run
|
||||
self._has_published_parsed = True
|
||||
self._last_entry_timestamp = max(
|
||||
entry.published_parsed, self._last_entry_timestamp
|
||||
|
|
|
@ -163,6 +163,12 @@ class TestFeedreaderComponent(unittest.TestCase):
|
|||
manager, events = self.setup_manager(feed_data)
|
||||
assert len(events) == 3
|
||||
|
||||
def test_feed_with_unrecognized_publication_date(self):
|
||||
"""Test simple feed with entry with unrecognized publication date."""
|
||||
feed_data = load_fixture("feedreader4.xml")
|
||||
manager, events = self.setup_manager(feed_data)
|
||||
assert len(events) == 1
|
||||
|
||||
def test_feed_invalid_data(self):
|
||||
"""Test feed with invalid data."""
|
||||
feed_data = "INVALID DATA"
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>RSS Sample</title>
|
||||
<description>This is an example of an RSS feed</description>
|
||||
<link>http://www.example.com/main.html</link>
|
||||
<lastBuildDate>Mon, 26 Oct 2019 12:00:00 +1000 </lastBuildDate>
|
||||
<pubDate>Mon, 26 Oct 2019 15:00:00 +1000</pubDate>
|
||||
<ttl>1800</ttl>
|
||||
|
||||
<item>
|
||||
<title>Title 1</title>
|
||||
<description>Description 1</description>
|
||||
<link>http://www.example.com/link/1</link>
|
||||
<guid isPermaLink="false">GUID 1</guid>
|
||||
<pubDate>26.10.2019 - 12:06:24</pubDate>
|
||||
</item>
|
||||
|
||||
</channel>
|
||||
</rss>
|
Loading…
Reference in New Issue