def handle(self):
        expense = Expense(category=self._expense_category())
        expense.save()

        new_state = self._compose_new_state(expense)
        self.state_manager.set(new_state)

        self.telegram.reply(self.message, self.TELEGRAM_REPLY)
    def test_handle_publishes_the_expense(self, state, message, sns_client):
        expected_expense = Expense(id='abcdef', category='Some category', amount=42.24, notes='description of the expense')
        expected_expense.save()
        action = self.build_action(message, state)
        action._expense = expected_expense

        action.handle()

        sns_client.money_spent.assert_called_once_with(expected_expense)
    def test_handle_updates_the_expense(self, state, message, sns_client):
        expense = Expense(id='abcdef', category='random category')
        expense.save()
        action = self.build_action(message, state)

        assert not expense.notes

        action.handle()

        expense.refresh()
        assert expense.notes == 'Description of the expense'
    def test_handle_updates_the_expense(self, state, message):
        expense = Expense(id='abcdef', category='random category')
        expense.save()
        action = self.build_action(message, state)

        assert not expense.amount

        action.handle()

        expense.refresh()
        assert expense.amount == 12.40