def test_routes(self): b = general.General(db=None, config={}, dir='') act = Interaction() b.logging = Mock() b.logging.info = Mock(return_value=True) b.log_expense = Mock() b.config_set = Mock() b.time = Mock() b.datetime = Mock() response = b.handle(act) self.assertEqual(response, None) act.command = {'text': 'time'} b.handle(act) b.time.assert_called_once() act.command = {'text': 'set config something=avalue'} b.handle(act) b.config_set.assert_called_once() self.assertEqual(b.match.group(1), 'something') self.assertEqual(b.match.group(2), 'avalue') b.config_set = Mock() act.command = {'text': 'config something=anothervalue'} b.handle(act) b.config_set.assert_called_once() self.assertEqual(b.match.group(1), 'something') self.assertEqual(b.match.group(2), 'anothervalue')
def test_routes(self): b = monzo.Monzo(db=None, config={}, dir='') act = Interaction() b.logging = Mock() b.logging.info = Mock(return_value=True) b.log_expense = Mock() b.log_all_transactions = Mock() b.log_recent_transactions = Mock() b.add_token = Mock() response = b.handle(act) self.assertEqual(response, None) act.command = {'text': 'get transactions'} b.handle(act) b.log_all_transactions.assert_called_once() act.command = {'text': 'get recent transactions'} b.handle(act) b.log_recent_transactions.assert_called_once() act.command = {'text': 'add monzo token auth_code client_id client_secret'} b.handle(act) b.log_expense.add_token() self.assertEqual(b.match.group(1), 'auth_code') self.assertEqual(b.match.group(2), 'client_id') self.assertEqual(b.match.group(3), 'client_secret')
def test_routes(self): b = countdown.Countdown(db=None, config={}, dir='') act = Interaction() b.logging = Mock() b.logging.info = Mock(return_value=True) b.set_countdown = Mock() b.get_closest = Mock() b.get_all = Mock() response = b.handle(act) self.assertEqual(response, None) act.command = {'text': 'get countdowns'} b.handle(act) b.get_all.assert_called_once() act.command = {'text': 'get closest countdowns'} b.handle(act) b.get_closest.assert_called_once() act.command = {'text': 'countdown 12-05-2015 my countdown message'} b.handle(act) b.set_countdown.assert_called_once() self.assertEqual(b.match.group(1), '12-05-2015') self.assertEqual(b.match.group(2), 'my countdown message') b.set_countdown = Mock() act.command = {'text': "countdown 12-05-2015 Bob's Birthday"} b.handle(act) b.set_countdown.assert_called_once() self.assertEqual(b.match.group(1), '12-05-2015') self.assertEqual(b.match.group(2), "Bob's Birthday")
def test_routes(self): b = expenses.Expenses(db=None, config={}, dir='') act = Interaction() b.logging = Mock() b.logging.info = Mock(return_value=True) b.log_expense = Mock() b.expenses_remaining_weekly = Mock() b.expenses_remaining = Mock() b.expenses_get = Mock() response = b.handle(act) self.assertEqual(response, None) act.command = {'text': 'budget'} b.handle(act) b.expenses_remaining_weekly.assert_called_once() act.command = {'text': 'get expenses'} b.handle(act) b.expenses_get.assert_called_once() act.command = {'text': '12.35 test expense'} b.handle(act) b.log_expense.assert_called_once() self.assertEqual(b.match.group(1), '12.35') self.assertEqual(b.match.group(2), 'test expense')
def test_behaviour_handle(self): g = general.General(db=None, config={}, dir='') # Use general because Behaviour is abstract base class act = Interaction() g.logging = Mock() g.info = Mock(return_value=True) response = g.handle(act) self.assertEqual(response, None) act.command = {'text': 'time'} response = g.handle(act) self.assertNotEqual(response, None)
def test_routes(self): b = dictionary.Dictionary(db=None, config={}, dir='') act = Interaction() b.logging = Mock() b.logging.info = Mock(return_value=True) b.word_of_the_day = Mock() response = b.handle(act) self.assertEqual(response, None) act.command = {'text': 'word of the day'} b.handle(act) b.word_of_the_day.assert_called_once()