2013-11-17 15:37:14 -05:00
|
|
|
# coding=utf-8
|
2012-06-02 17:23:26 -04:00
|
|
|
"""
|
|
|
|
test_calc.py - tests for the calc module
|
|
|
|
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
|
|
|
"""
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
from mock import MagicMock, Mock
|
2016-03-06 17:55:50 -05:00
|
|
|
from modules.calc import c
|
2012-06-02 17:23:26 -04:00
|
|
|
|
|
|
|
|
|
|
|
class TestCalc(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.phenny = MagicMock()
|
|
|
|
|
|
|
|
def test_c(self):
|
|
|
|
input = Mock(group=lambda x: '5*5')
|
|
|
|
c(self.phenny, input)
|
|
|
|
|
|
|
|
self.phenny.say.assert_called_once_with('25')
|
|
|
|
|
2013-11-17 15:37:14 -05:00
|
|
|
def test_c_sqrt(self):
|
|
|
|
input = Mock(group=lambda x: '4^(1/2)')
|
|
|
|
c(self.phenny, input)
|
|
|
|
|
|
|
|
self.phenny.say.assert_called_once_with('2')
|
|
|
|
|
2012-06-05 21:24:43 -04:00
|
|
|
def test_c_scientific(self):
|
|
|
|
input = Mock(group=lambda x: '2^64')
|
|
|
|
c(self.phenny, input)
|
|
|
|
|
2017-05-29 17:27:58 -04:00
|
|
|
self.phenny.say.assert_called_once_with('1.84467441 * 10^19')
|
2012-06-05 21:24:43 -04:00
|
|
|
|
2012-06-19 21:04:00 -04:00
|
|
|
def test_c_none(self):
|
|
|
|
input = Mock(group=lambda x: 'aif')
|
|
|
|
c(self.phenny, input)
|
|
|
|
|
|
|
|
self.phenny.reply.assert_called_once_with('Sorry, no result.')
|
2017-07-07 00:28:10 -04:00
|
|
|
|
|
|
|
def test_c_quirk(self):
|
|
|
|
input = Mock(group=lambda x: '24/50')
|
|
|
|
c(self.phenny, input)
|
|
|
|
|
|
|
|
self.phenny.say.assert_called_once_with('0.48')
|