ShrinkUrl: Fix tests.

This commit is contained in:
Valentin Lorentz 2013-01-04 22:56:12 +01:00
parent fe39d35b2f
commit 4c23fae4d3

View File

@ -34,20 +34,19 @@ class ShrinkUrlTestCase(ChannelPluginTestCase):
plugins = ('ShrinkUrl',) plugins = ('ShrinkUrl',)
config = {'supybot.snarfThrottle': 0} config = {'supybot.snarfThrottle': 0}
sfUrl ='http://sourceforge.net/tracker/?func=add&group_id=58965&atid=48947' sfUrl ='http://sourceforge.net/p/supybot/bugs/?source=navbar'
udUrl = 'http://www.urbandictionary.com/define.php?' \ udUrl = 'http://www.urbandictionary.com/define.php?' \
'term=all+your+base+are+belong+to+us' 'term=all+your+base+are+belong+to+us'
tests = {'tiny': [(sfUrl, r'http://tinyurl.com/yg8r28z'), tests = {'tiny': [(sfUrl, r'http://tinyurl.com/b7wyvfz'),
(udUrl, r'http://tinyurl.com/u479')], (udUrl, r'http://tinyurl.com/u479')],
'ln': [(sfUrl, r'http://ln-s.net/4LVF'), 'ln': [(sfUrl, r'http://ln-s.net/\+PE-'),
(udUrl, r'http://ln-s.net/2\$K')], (udUrl, r'http://ln-s.net/2\$K')],
'xrl': [(sfUrl, r'http://xrl.us/bfq8ik'), 'xrl': [(udUrl, r'http://xrl.us/bfnyji')],
(udUrl, r'http://xrl.us/bfnyji')], 'goo': [(sfUrl, r'http://goo.gl/krnNC'),
'goo': [(sfUrl, r'http://goo.gl/3c59N'), (udUrl, r'http://goo.gl/1ejCD')],
(udUrl, r'http://goo.gl/ocTga')], 'ur1': [(sfUrl, r'http://ur1.ca/ceqh8'),
'ur1': [(sfUrl, r'http://ur1.ca/9xl25'),
(udUrl, r'http://ur1.ca/9xl9k')], (udUrl, r'http://ur1.ca/9xl9k')],
'x0': [(sfUrl, r'http://x0.no/0l2j'), 'x0': [(sfUrl, r'http://x0.no/a53s'),
(udUrl, r'http://x0.no/0l2k')] (udUrl, r'http://x0.no/0l2k')]
} }
if network: if network:
@ -68,11 +67,11 @@ class ShrinkUrlTestCase(ChannelPluginTestCase):
self.assertError( self.assertError(
'config plugins.ShrinkUrl.serviceRotation ln x1') 'config plugins.ShrinkUrl.serviceRotation ln x1')
snarfer.setValue(True) snarfer.setValue(True)
self.assertSnarfRegexp(self.udUrl, r'%s.* \(at' % self.assertSnarfRegexp(self.udUrl, r'.*%s.* \(at' %
self.tests['ln'][1][1]) self.tests['ln'][1][1])
self.assertSnarfRegexp(self.udUrl, r'%s.* \(at' % self.assertSnarfRegexp(self.udUrl, r'.*%s.* \(at' %
self.tests['x0'][1][1]) self.tests['x0'][1][1])
self.assertSnarfRegexp(self.udUrl, r'%s.* \(at' % self.assertSnarfRegexp(self.udUrl, r'.*%s.* \(at' %
self.tests['ln'][1][1]) self.tests['ln'][1][1])
finally: finally:
cycle.setValue(origcycle) cycle.setValue(origcycle)
@ -86,7 +85,7 @@ class ShrinkUrlTestCase(ChannelPluginTestCase):
shrink.shrinkSnarfer.setValue(True) shrink.shrinkSnarfer.setValue(True)
try: try:
for (url, shrunkurl) in self.tests[service]: for (url, shrunkurl) in self.tests[service]:
teststr = r'%s.* \(at' % shrunkurl teststr = r'.*%s.* \(at' % shrunkurl
self.assertSnarfRegexp(url, teststr) self.assertSnarfRegexp(url, teststr)
finally: finally:
shrink.default.setValue(origService) shrink.default.setValue(origService)
@ -133,8 +132,8 @@ class ShrinkUrlTestCase(ChannelPluginTestCase):
def testExpand(self): def testExpand(self):
self.assertResponse('expand http://x0.no/0l2k', self.udUrl) self.assertResponse('expand http://x0.no/0l2k', self.udUrl)
self.assertResponse('expand http://x0.no/0l2k', self.udUrl) self.assertResponse('expand http://x0.no/0l2k', self.udUrl)
self.assertResponse('expand http://x0.no/0l2j', self.sfUrl) self.assertResponse('expand http://x0.no/a53s', self.sfUrl)
self.assertResponse('expand http://x0.no/0l2j', self.sfUrl) self.assertResponse('expand http://x0.no/a53s', self.sfUrl)
self.assertResponse('expand http://x0.no/0l2k', self.udUrl) self.assertResponse('expand http://x0.no/0l2k', self.udUrl)
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: