add test cases for mediawiki modules

master
mutantmonkey 2012-06-15 20:04:44 -07:00
parent ce2d548ff4
commit bf55297f43
3 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,31 @@
"""
test_archwiki.py - tests for the arch wiki module
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
"""
import re
import unittest
from mock import MagicMock, Mock
from modules import archwiki
class TestArchwiki(unittest.TestCase):
def setUp(self):
self.phenny = MagicMock()
def test_awik(self):
input = Mock(groups=lambda: ['', "KVM"])
archwiki.awik(self.phenny, input)
out = self.phenny.say.call_args[0][0]
m = re.match('^.* - https:\/\/wiki\.archlinux\.org\/index\.php\/KVM$',
out, flags=re.UNICODE)
self.assertTrue(m)
def test_awik_none(self):
term = "Ajgoajh"
input = Mock(groups=lambda: ['', term])
archwiki.awik(self.phenny, input)
self.phenny.say.assert_called_once_with( "Can't find anything in "\
"the ArchWiki for \"{0}\".".format(term))

View File

@ -0,0 +1,31 @@
"""
test_vtluugwiki.py - tests for the VTLUUG wiki module
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
"""
import re
import unittest
from mock import MagicMock, Mock
from modules import vtluugwiki
class TestVtluugwiki(unittest.TestCase):
def setUp(self):
self.phenny = MagicMock()
def test_vtluug(self):
input = Mock(groups=lambda: ['', "VT-Wireless"])
vtluugwiki.vtluug(self.phenny, input)
out = self.phenny.say.call_args[0][0]
m = re.match('^.* - https:\/\/vtluug\.org\/wiki\/VT-Wireless$',
out, flags=re.UNICODE)
self.assertTrue(m)
def test_vtluug_none(self):
term = "Ajgoajh"
input = Mock(groups=lambda: ['', term])
vtluugwiki.vtluug(self.phenny, input)
self.phenny.say.assert_called_once_with( "Can't find anything in "\
"the VTLUUG Wiki for \"{0}\".".format(term))

View File

@ -0,0 +1,31 @@
"""
test_wikipedia.py - tests for the wikipedia module
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
"""
import re
import unittest
from mock import MagicMock, Mock
from modules import wikipedia
class TestWikipedia(unittest.TestCase):
def setUp(self):
self.phenny = MagicMock()
def test_wik(self):
input = Mock(groups=lambda: ['', "Human back"])
wikipedia.wik(self.phenny, input)
out = self.phenny.say.call_args[0][0]
m = re.match('^.* - https:\/\/en\.wikipedia\.org\/wiki\/Human_back$',
out, flags=re.UNICODE)
self.assertTrue(m)
def test_wik_none(self):
term = "Ajgoajh"
input = Mock(groups=lambda: ['', term])
wikipedia.wik(self.phenny, input)
self.phenny.say.assert_called_once_with( "Can't find anything in "\
"Wikipedia for \"{0}\".".format(term))