mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-12 05:02:32 +01:00
RSS: Make @remove completely clean up feeds
This commit is contained in:
parent
556bd788b5
commit
97a7aa304e
@ -290,11 +290,17 @@ class RSS(callbacks.Plugin):
|
|||||||
self.feeds[url] = Feed(name, url, initial,
|
self.feeds[url] = Feed(name, url, initial,
|
||||||
plugin_is_loading, announced)
|
plugin_is_loading, announced)
|
||||||
|
|
||||||
def remove_feed(self, feed):
|
def remove_feed(self, name_or_url):
|
||||||
del self.feed_names[feed.name]
|
self.feed_names.pop(name_or_url, None)
|
||||||
del self.feeds[feed.url]
|
while True:
|
||||||
conf.supybot.plugins.RSS.feeds().remove(feed.name)
|
try:
|
||||||
conf.supybot.plugins.RSS.feeds.unregister(feed.name)
|
conf.supybot.plugins.RSS.feeds().remove(name_or_url)
|
||||||
|
except KeyError:
|
||||||
|
break
|
||||||
|
try:
|
||||||
|
conf.supybot.plugins.RSS.feeds.unregister(name_or_url)
|
||||||
|
except (KeyError, registry.NonExistentRegistryEntry):
|
||||||
|
pass
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Methods handling
|
# Methods handling
|
||||||
@ -517,7 +523,6 @@ class RSS(callbacks.Plugin):
|
|||||||
if not feed:
|
if not feed:
|
||||||
irc.error(_('That\'s not a valid RSS feed command name.'))
|
irc.error(_('That\'s not a valid RSS feed command name.'))
|
||||||
return
|
return
|
||||||
self.remove_feed(feed)
|
|
||||||
|
|
||||||
# If the feed was first created "anonymously", eg. with
|
# If the feed was first created "anonymously", eg. with
|
||||||
# `@rss announce add http://example.org/rss`, then as a named feed
|
# `@rss announce add http://example.org/rss`, then as a named feed
|
||||||
@ -525,8 +530,8 @@ class RSS(callbacks.Plugin):
|
|||||||
# `self.get_feed(name)` above gets only one of them; so let's
|
# `self.get_feed(name)` above gets only one of them; so let's
|
||||||
# remove the aliased name or URL from the feed names too,
|
# remove the aliased name or URL from the feed names too,
|
||||||
# or we would have a dangling entry here.
|
# or we would have a dangling entry here.
|
||||||
self.feed_names.pop(name, None)
|
self.remove_feed(feed.url)
|
||||||
self.feed_names.pop(feed.url, None)
|
self.remove_feed(name)
|
||||||
assert self.get_feed(name) is None
|
assert self.get_feed(name) is None
|
||||||
|
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
@ -109,7 +109,6 @@ class RSSTestCase(ChannelPluginTestCase):
|
|||||||
self.assertNotError('rss announce remove http://xkcd.com/rss.xml')
|
self.assertNotError('rss announce remove http://xkcd.com/rss.xml')
|
||||||
self.assertNotError('rss remove xkcd')
|
self.assertNotError('rss remove xkcd')
|
||||||
self.assertEqual(self.irc.getCallback('RSS').feed_names, {})
|
self.assertEqual(self.irc.getCallback('RSS').feed_names, {})
|
||||||
self.assertEqual(self.irc.getCallback('RSS').feeds, {})
|
|
||||||
|
|
||||||
@mock_urllib
|
@mock_urllib
|
||||||
def testInitialAnnounceNewest(self, mock):
|
def testInitialAnnounceNewest(self, mock):
|
||||||
@ -213,6 +212,8 @@ class RSSTestCase(ChannelPluginTestCase):
|
|||||||
self.assertNoResponse(' ', timeout=0.1)
|
self.assertNoResponse(' ', timeout=0.1)
|
||||||
timeFastForward(1.1)
|
timeFastForward(1.1)
|
||||||
self.assertRegexp(' ', 'Telescopes')
|
self.assertRegexp(' ', 'Telescopes')
|
||||||
|
self.assertRegexp(' ', 'Chaos')
|
||||||
|
self.assertNoResponse(' ', timeout=0.1)
|
||||||
finally:
|
finally:
|
||||||
self._feedMsg('rss announce remove http://xkcd.com/rss.xml')
|
self._feedMsg('rss announce remove http://xkcd.com/rss.xml')
|
||||||
self._feedMsg('rss remove http://xkcd.com/rss.xml')
|
self._feedMsg('rss remove http://xkcd.com/rss.xml')
|
||||||
|
Loading…
Reference in New Issue
Block a user