fix wiktionary and add tests

This commit is contained in:
mutantmonkey
2012-06-01 21:01:56 -07:00
parent b272cfd0f9
commit da77b275e0
2 changed files with 64 additions and 25 deletions

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
"""
test_wiktionary.py - tests for the wiktionary module
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
"""
import re
import unittest
from mock import MagicMock, Mock
from modules import wiktionary
class TestWiktionary(unittest.TestCase):
def setUp(self):
self.phenny = MagicMock()
def test_wiktionary(self):
w = wiktionary.wiktionary('test')
assert len(w[0]) > 0
assert len(w[1]) > 0
def test_w(self):
input = Mock(group=lambda x: 'test')
wiktionary.w(self.phenny, input)
out = self.phenny.say.call_args[0][0]
m = re.match('^test — noun: .*$', out, flags=re.UNICODE)
self.assertTrue(m)