예제 #1
0
def test_select_action_dictionary_upper_bound_invalid(capsys):
    test_input = ['11', '1']
    with mock.patch('builtins.input', side_effect=test_input):
        mailroom.select_action_dictionary('1', mailroom.switch_func_dict)
        captured = capsys.readouterr()
        out = captured.out.strip()
        assert out.startswith("Please enter only one of the listed options.")
예제 #2
0
def test_select_action_dictionary_exit(capsys):
    test_input = ['1']
    with mock.patch('builtins.input', side_effect=test_input):
        mailroom.select_action_dictionary('1', mailroom.switch_func_dict)
        captured = capsys.readouterr()
        out = captured.out.strip()
        assert out == "Before quitting."
예제 #3
0
def test_calculate_report(capsys):
    test_input = ['2', '1']
    with mock.patch('builtins.input', side_effect=test_input):
        mailroom.select_action_dictionary('1', mailroom.switch_func_dict)
        captured = capsys.readouterr()
        out = captured.out.strip('\n')
        err = captured.err.strip()
        assert "Robin Hood" in out
예제 #4
0
def test_add_donation(capsys):
    test_input = ['6', "Toni Orlando", '500', '1']
    with mock.patch('builtins.input', side_effect=test_input):
        mailroom.select_action_dictionary('1', mailroom.switch_func_dict)
        captured = capsys.readouterr()
        out = captured.out.strip('\n')
        err = captured.err.strip()
        assert(" was succesfully added") in out
예제 #5
0
def test_delete_donor(capsys):
    test_input = ['7', "Bruno Mars", '1']
    with mock.patch('builtins.input', side_effect=test_input):
        mailroom.select_action_dictionary('1', mailroom.switch_func_dict)
        captured = capsys.readouterr()
        out = captured.out.strip('\n')
        err = captured.err.strip()
        assert(test_input[1] + " was succesfully deleted") in out
예제 #6
0
def test_sending_thank_you(capsys):
    test_input = ['4', 'Toni Orlando', 100, '1']
    with mock.patch('builtins.input', side_effect=test_input):
        mailroom.select_action_dictionary('1', mailroom.switch_func_dict)
        captured = capsys.readouterr()
        out = captured.out.strip()
        err = captured.err.strip()
        assert ('Dear {}, Thank you for your generous contribution of ${'
                ':.2f} to our program.'.format(test_input[1],test_input[2])) in out
예제 #7
0
def test_donor_list(capsys):
    test_input = ['10', '1']
    with mock.patch('builtins.input', side_effect=test_input):
        mailroom.select_action_dictionary('1', mailroom.switch_func_dict)
        captured = capsys.readouterr()
        out = captured.out.strip('\n')
        err = captured.err.strip()
        file_list = ['Amanda Clark', 'Toni Orlando', 'Robin Hood',
                 'Gina Travis', 'Mark Johnson']
        for name in file_list:
            assert name in out