From 7f2578a13ec98a8abe9bd8fb1a01b62cdab7567e Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 31 Jan 2004 22:04:46 +0000 Subject: [PATCH] Updated to make the tests pass. --- plugins/URL.py | 8 ++++---- test/test_URL.py | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/plugins/URL.py b/plugins/URL.py index e24255aa8..986c2d5cf 100644 --- a/plugins/URL.py +++ b/plugins/URL.py @@ -81,7 +81,7 @@ conf.registerChannelValue(conf.supybot.plugins.URL, 'tinyurlSnarfer', supybot.plugins.URL.tinyurlSnarfer.minimumLength) it will post a smaller from tinyurl.com.""")) conf.registerChannelValue(conf.supybot.plugins.URL.tinyurlSnarfer, - 'maximumLength', + 'minimumLength', registry.PositiveInteger(48, """The minimum length a URL must be before the tinyurl snarfer will snarf it.""")) conf.registerChannelValue(conf.supybot.plugins.URL, 'titleSnarfer', @@ -173,7 +173,7 @@ class URL(callbacks.PrivmsgCommandAndRegexp, channel = msg.args[0] if self.registryValue('tinyurlSnarfer', channel): url = match.group(0) - minlen = self.registryValue('tinyurlSnarfer.maximumLength',channel) + minlen = self.registryValue('tinyurlSnarfer.minimumLength',channel) if len(url) >= minlen: db = self.getDb(channel) cursor = db.cursor() @@ -245,7 +245,7 @@ class URL(callbacks.PrivmsgCommandAndRegexp, return (tinyurl, updateDb) def _formatUrl(self, url, added, addedBy): - when = time.strftime(conf.supybot.supybot.humanTimestampFormat(), + when = time.strftime(conf.supybot.humanTimestampFormat(), time.localtime(int(added))) return '<%s> (added by %s at %s)' % (url, addedBy, when) @@ -279,7 +279,7 @@ class URL(callbacks.PrivmsgCommandAndRegexp, return channel = msg.args[0] snarf = self.registryValue('tinyurlSnarfer', channel) - minlen = self.registryValue('tinyurlMinimumLength', channel) + minlen = self.registryValue('tinyurlSnarfer.minimumLength', channel) if snarf and len(url) >= minlen: return (tinyurl, updateDb) = self._getTinyUrl(url, channel, cmd=True) diff --git a/test/test_URL.py b/test/test_URL.py index 8b633ba23..36a5405ba 100644 --- a/test/test_URL.py +++ b/test/test_URL.py @@ -75,17 +75,17 @@ if sqlite is not None: class URLTestCase(ChannelPluginTestCase, PluginDocumentation): plugins = ('URL',) def setUp(self): + ChannelPluginTestCase.setUp(self) conf.supybot.plugins.URL.tinyurlSnarfer.setValue(False) - ChannePluginTestCase.setUp(self) def test(self): counter = 0 self.assertNotError('url random') for url in urls: - self.assertRegexp('url num', str(counter)) + self.assertRegexp('url stats', str(counter)) self.feedMsg(url) counter += 1 - self.assertRegexp('url num', str(counter)) + self.assertRegexp('url stats', str(counter)) self.assertRegexp('url last', re.escape(urls[-1])) self.assertRegexp('url last --proto https', re.escape(urls[-3])) self.assertRegexp('url last --at gameknot.com',re.escape(urls[-2])) @@ -132,11 +132,11 @@ if sqlite is not None: conf.supybot.plugins.URL.tinyurlSnarfer.setValue(True) self.assertRegexp('http://sourceforge.net/tracker/?' 'func=add&group_id=58965&atid=489447', - r'http://tinyurl.com/rqac.* \(was') + r'http://tinyurl.com/rqac.* \(at') self.assertRegexp( 'http://www.urbandictionary.com/define.php?' 'term=all+your+base+are+belong+to+us', - r'http://tinyurl.com/u479.* \(was') + r'http://tinyurl.com/u479.* \(at') finally: conf.supybot.plugins.URL.tinyurlSnarfer.setValue(False) @@ -144,7 +144,8 @@ if sqlite is not None: try: conf.supybot.plugins.URL.titleSnarfer.setValue(True) self.assertResponse('http://microsoft.com/', - 'Title: Microsoft Corporation') + 'Title: Microsoft Corporation' + ' (at microsoft.com)') finally: conf.supybot.plugins.URL.titleSnarfer.setValue(False)