mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Updated to make the tests pass.
This commit is contained in:
parent
4a4aa6ec27
commit
7f2578a13e
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user