From 5c5ab2cf749e1c2dcb79c2836084b7bd218002e7 Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 6 Oct 2014 19:02:12 -0700 Subject: [PATCH] Isup/NoTrigger/PassGen/PkgInfo: add unittests (#13) --- Isup/test.py | 4 ++++ NoTrigger/test.py | 17 +++++++++++++++-- PassGen/test.py | 6 ++++++ PkgInfo/test.py | 20 ++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Isup/test.py b/Isup/test.py index f9fbc6b..a6eb470 100644 --- a/Isup/test.py +++ b/Isup/test.py @@ -33,5 +33,9 @@ from supybot.test import * class IsupTestCase(PluginTestCase): plugins = ('Isup',) + def testBasics(self): + self.assertRegexp('check google.com', "It's just you") + self.assertRegexp('check dhjeheiaoij', "invalid|url|error", re.I) + self.assertRegexp('check dhjeheiao.invalid', "invalid|url|error", re.I) # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/NoTrigger/test.py b/NoTrigger/test.py index 22eb092..f455d5e 100644 --- a/NoTrigger/test.py +++ b/NoTrigger/test.py @@ -30,8 +30,21 @@ from supybot.test import * -class NoTriggerTestCase(PluginTestCase): - plugins = ('NoTrigger',) +class NoTriggerTestCase(ChannelPluginTestCase): + plugins = ('NoTrigger','Utilities', 'Reply') + config = {'supybot.plugins.notrigger.enable': True, + 'supybot.plugins.notrigger.spaceBeforeNicks': True, + 'supybot.plugins.notrigger.blockCtcp': True} + def testSpaceBeforePrefixes(self): + self.assertResponse('echo !test', ' !test') + + def testSpaceBeforeNicks(self): + self.assertResponse('echo example: hello', ' example: hello') + self.assertResponse('echo user1, hello', ' user1, hello') + + def testCTCPBlocking(self): + self.assertResponse('echo \x01PING abcd\x01', 'PING abcd') + self.assertAction('reply action jumps around', 'jumps around') # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/PassGen/test.py b/PassGen/test.py index 5fa34d4..5b2684b 100644 --- a/PassGen/test.py +++ b/PassGen/test.py @@ -32,6 +32,12 @@ from supybot.test import * class PassGenTestCase(PluginTestCase): plugins = ('PassGen',) + config = {'supybot.plugins.passgen.maxLength': 30} + def testmaxLen(self): + self.assertError('mkpasswd 70') + + def testBasics(self): + self.assertNotError('mkpasswd 20') # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/PkgInfo/test.py b/PkgInfo/test.py index 98f63c5..3e5a549 100644 --- a/PkgInfo/test.py +++ b/PkgInfo/test.py @@ -32,6 +32,26 @@ from supybot.test import * class PkgInfoTestCase(PluginTestCase): plugins = ('PkgInfo',) + def testPackageCommandBasics(self): + self.assertRegexp('package sid bash', 'Package: .*?bash' + ' .*?; View more at: http://packages.debian.org/sid/bash') + self.assertRegexp('package trusty apt', 'Package: .*?apt' + ' .*?; View more at: http://packages.ubuntu.com/trusty/apt') + self.assertError('package afdsfsadf asfasfasf') + self.assertRegexp('package sid afsadfasfsa', 'no such package', re.I) + def testVlistCommandBasics(self): + self.assertError('vlist all afdsafas') + self.assertError('vlist invalid-distro firefox') + self.assertNotError('vlist debian bash') + + def testArchpkg(self): + self.assertError('archpkg afdsfbjeiog') + self.assertNotError('archpkg bash') + self.assertRegexp('archpkg pacman --exact', 'Found 1.*?pacman -.*?') + + def testArchaur(self): + self.assertError('archaur wjoitgjwotgjv') + self.assertNotError('archaur yaourt') # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: