mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-17 06:00:42 +01:00
RSS: Sort on time tuples instead of formatted dates.
This commit is contained in:
parent
c81d5d3151
commit
29ca3eb5e4
@ -132,7 +132,7 @@ def sort_feed_items(items, order):
|
||||
if order == 'newestFirst':
|
||||
reverse = True
|
||||
try:
|
||||
sitems = sorted(items, key=lambda i: i['published'], reverse=reverse)
|
||||
sitems = sorted(items, key=lambda i: i['published_parsed'], reverse=reverse)
|
||||
except KeyError:
|
||||
# feedparser normalizes required timestamp fields in ATOM and RSS
|
||||
# to the "published" field. Feeds missing it are unsortable by date.
|
||||
|
@ -69,7 +69,35 @@ class RSSTestCase(ChannelPluginTestCase):
|
||||
finally:
|
||||
self.assertNotError('rss remove xkcd')
|
||||
|
||||
def testInitialAnnounce(self):
|
||||
def testInitialAnnounceNewest(self):
|
||||
old_open = feedparser._open_resource
|
||||
feedparser._open_resource = constant(xkcd_new)
|
||||
try:
|
||||
with conf.supybot.plugins.RSS.initialAnnounceHeadlines.context(1):
|
||||
with conf.supybot.plugins.RSS.sortFeedItems.context('newestFirst'):
|
||||
self.assertNotError('rss add xkcd http://xkcd.com/rss.xml')
|
||||
self.assertNotError('rss announce add xkcd')
|
||||
self.assertRegexp(' ', 'Snake Facts')
|
||||
finally:
|
||||
self._feedMsg('rss announce remove xkcd')
|
||||
self._feedMsg('rss remove xkcd')
|
||||
feedparser._open_resource = old_open
|
||||
|
||||
def testInitialAnnounceOldest(self):
|
||||
old_open = feedparser._open_resource
|
||||
feedparser._open_resource = constant(xkcd_new)
|
||||
try:
|
||||
with conf.supybot.plugins.RSS.initialAnnounceHeadlines.context(1):
|
||||
with conf.supybot.plugins.RSS.sortFeedItems.context('oldestFirst'):
|
||||
self.assertNotError('rss add xkcd http://xkcd.com/rss.xml')
|
||||
self.assertNotError('rss announce add xkcd')
|
||||
self.assertRegexp(' ', 'Chaos')
|
||||
finally:
|
||||
self._feedMsg('rss announce remove xkcd')
|
||||
self._feedMsg('rss remove xkcd')
|
||||
feedparser._open_resource = old_open
|
||||
|
||||
def testNoInitialAnnounce(self):
|
||||
old_open = feedparser._open_resource
|
||||
feedparser._open_resource = constant(xkcd_old)
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user