From bf55297f439b8d1fb039e9423455e6ad0471a447 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Fri, 15 Jun 2012 20:04:44 -0700 Subject: [PATCH] add test cases for mediawiki modules --- modules/test/test_archwiki.py | 31 +++++++++++++++++++++++++++++++ modules/test/test_vtluugwiki.py | 31 +++++++++++++++++++++++++++++++ modules/test/test_wikipedia.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 modules/test/test_archwiki.py create mode 100644 modules/test/test_vtluugwiki.py create mode 100644 modules/test/test_wikipedia.py diff --git a/modules/test/test_archwiki.py b/modules/test/test_archwiki.py new file mode 100644 index 0000000..54ef6db --- /dev/null +++ b/modules/test/test_archwiki.py @@ -0,0 +1,31 @@ +""" +test_archwiki.py - tests for the arch wiki module +author: mutantmonkey +""" + +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)) diff --git a/modules/test/test_vtluugwiki.py b/modules/test/test_vtluugwiki.py new file mode 100644 index 0000000..b5be482 --- /dev/null +++ b/modules/test/test_vtluugwiki.py @@ -0,0 +1,31 @@ +""" +test_vtluugwiki.py - tests for the VTLUUG wiki module +author: mutantmonkey +""" + +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)) diff --git a/modules/test/test_wikipedia.py b/modules/test/test_wikipedia.py new file mode 100644 index 0000000..a3900ff --- /dev/null +++ b/modules/test/test_wikipedia.py @@ -0,0 +1,31 @@ +""" +test_wikipedia.py - tests for the wikipedia module +author: mutantmonkey +""" + +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))