From 3415cd08a1c6bf75af19a3775a3293194813837a Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Fri, 28 May 2021 18:38:06 +0200 Subject: [PATCH] RSS: Add test checking exception from a feed doesn't affect other feeds. --- plugins/RSS/test.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/plugins/RSS/test.py b/plugins/RSS/test.py index eab10c61b..5362e393e 100644 --- a/plugins/RSS/test.py +++ b/plugins/RSS/test.py @@ -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