mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-10-14 17:59:29 +02: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':
|
if order == 'newestFirst':
|
||||||
reverse = True
|
reverse = True
|
||||||
try:
|
try:
|
||||||
sitems = sorted(items, key=lambda i: i['published'], reverse=reverse)
|
sitems = sorted(items, key=lambda i: i['published_parsed'], reverse=reverse)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# feedparser normalizes required timestamp fields in ATOM and RSS
|
# feedparser normalizes required timestamp fields in ATOM and RSS
|
||||||
# to the "published" field. Feeds missing it are unsortable by date.
|
# to the "published" field. Feeds missing it are unsortable by date.
|
||||||
|
@ -69,7 +69,35 @@ class RSSTestCase(ChannelPluginTestCase):
|
|||||||
finally:
|
finally:
|
||||||
self.assertNotError('rss remove xkcd')
|
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
|
old_open = feedparser._open_resource
|
||||||
feedparser._open_resource = constant(xkcd_old)
|
feedparser._open_resource = constant(xkcd_old)
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user