diff --git a/modules/calc.py b/modules/calc.py index 44c534c..8f2f409 100644 --- a/modules/calc.py +++ b/modules/calc.py @@ -48,27 +48,5 @@ c.commands = ['c'] c.example = '.c 5 + 3' -def wa(phenny, input): - if not input.group(2): - return phenny.reply("No search term.") - query = input.group(2) - - re_output = re.compile(r'{"stringified": "(.*?)",') - - uri = 'http://www.wolframalpha.com/input/?i={}' - out = web.get(uri.format(web.quote(query))) - answers = re_output.findall(out) - if len(answers) <= 0: - phenny.reply("Sorry, no result.") - return - - answer = answers[1] - for sub in subs: - answer = answer.replace(sub[0], sub[1]) - - phenny.say(answer) -wa.commands = ['wa'] -wa.example = '.wa answer to life' - if __name__ == '__main__': print(__doc__.strip()) diff --git a/modules/test/test_calc.py b/modules/test/test_calc.py index a271683..c154359 100644 --- a/modules/test/test_calc.py +++ b/modules/test/test_calc.py @@ -37,36 +37,3 @@ class TestCalc(unittest.TestCase): c(self.phenny, input) self.phenny.reply.assert_called_once_with('Sorry, no result.') - - def test_wa(self): - input = Mock(group=lambda x: 'airspeed of an unladen swallow') - wa(self.phenny, input) - - self.phenny.say.assert_called_once_with('25 mph (miles per hour); '\ - '(asked, but not answered, about a general swallow in the '\ - '1975 film Monty Python and the Holy Grail)') - - def test_wa_math(self): - input = Mock(group=lambda x: '2+2') - wa(self.phenny, input) - - self.phenny.say.assert_called_once_with('4') - - def test_wa_convert_deg(self): - input = Mock(group=lambda x: '30 degrees C in F') - wa(self.phenny, input) - - self.phenny.say.assert_called_once_with('86 °F (degrees Fahrenheit)') - - def test_wa_convert_bytes(self): - input = Mock(group=lambda x: '5 MB/s in Mbps') - wa(self.phenny, input) - - self.phenny.say.assert_called_once_with( - '40 Mb/s (megabits per second)') - - def test_wa_none(self): - input = Mock(group=lambda x: "jajoajaj ojewphjqo I!tj") - wa(self.phenny, input) - - self.phenny.reply.assert_called_once_with('Sorry, no result.')