RSS: Add test checking exception from a feed doesn't affect other feeds.

This commit is contained in:
Valentin Lorentz 2021-05-28 18:38:06 +02:00
parent 7c68b2cb53
commit 3415cd08a1
1 changed files with 34 additions and 0 deletions

View File

@ -174,6 +174,40 @@ class RSSTestCase(ChannelPluginTestCase):
self._feedMsg('rss announce remove xkcd')
self._feedMsg('rss remove xkcd')
def testAnnounceError(self):
"""Tests error from a single feed does not prevent other feeds from
being announced."""
mock = MockResponse()
mock._data = xkcd_old
def open(request):
if request.full_url == 'http://xkcd.com/rss.xml':
return mock
else:
raise Exception('oops, feed crashed')
with patch("urllib.request.OpenerDirector.open", side_effect=open):
timeFastForward(1.1)
try:
self.assertNotError('rss add buggy http://example.org/foo')
self.assertNotError('rss add xkcd http://xkcd.com/rss.xml')
self.assertNotError('rss announce add buggy')
self.assertNotError('rss announce add xkcd')
self.assertNotError(' ')
with conf.supybot.plugins.RSS.sortFeedItems.context('oldestFirst'):
with conf.supybot.plugins.RSS.waitPeriod.context(1):
timeFastForward(1.1)
self.assertNoResponse(' ', timeout=0.1)
mock._data = xkcd_new
self.assertNoResponse(' ', timeout=0.1)
timeFastForward(1.1)
self.assertRegexp(' ', 'Chaos')
self.assertRegexp(' ', 'Telescopes')
self.assertNoResponse(' ')
finally:
self._feedMsg('rss announce remove buggy')
self._feedMsg('rss remove buggy')
self._feedMsg('rss announce remove xkcd')
self._feedMsg('rss remove xkcd')
@mock_urllib
def testMaxAnnounces(self, mock):
mock._data = xkcd_old