コード例 #1
0
    def test_obtain_strategy__no_debts(self, mock_obtain, mock_summary,
                                       mock_confirm, mock_print):
        test_ui = UI()
        mock_person = Mock()
        mock_person.name = 'Joe'
        mock_savings = Mock()
        test_ui.current_person = mock_person
        test_ui.remaining_disposable = Decimal('1000')
        test_ui.debts = []
        test_ui.savings = mock_savings
        mock_obtain.return_value = [{'MOCK_STRATEGY': 'STUFF'}]

        result = test_ui._obtain_strategy()

        expected_strategy = {
            'savings': [{
                'MOCK_STRATEGY': 'STUFF'
            }],
            'remaining': Decimal('1000')
        }
        self.assertDictEqual(result, expected_strategy)
        mock_print.assert_any_call(
            'Joe has ~£1000 disposable income per month.\n')
        mock_obtain.assert_called_once_with(mock_savings)
        mock_print.assert_any_call(
            '\nThank you. Here’s a summary of Joe’s monthly strategy:\n')
        mock_summary.assert_called_once_with(expected_strategy)
        mock_confirm.assert_called_once()
コード例 #2
0
    def test_new_strategy_hint__no_cleared(self):
        test_ui = UI()
        test_ui.recently_cleared = []
        mock_person = Mock()
        mock_person.name = 'Joe'
        test_ui.current_person = mock_person

        result = test_ui._new_strategy_hint()
        expected_hint = ('Please provide a new strategy for Joe.\n')
        self.assertEqual(result, expected_hint)
コード例 #3
0
    def test_new_strategy_hint__many_cleared(self):
        test_ui = UI()
        test_ui.recently_cleared = ['Credit Card', 'Car Loan', 'Overdraft']
        mock_person = Mock()
        mock_person.name = 'Joe'
        test_ui.current_person = mock_person

        result = test_ui._new_strategy_hint()
        expected_hint = (
            'Joe has paid off Credit Card, Car Loan and Overdraft. Please provide a new strategy for them.\n'
        )
        self.assertEqual(result, expected_hint)