Example #1
0
def test_get_sorted_donors():
    """ test sorting of donors """
    mailroom = Mailroom()
    for donor, amount in INITIAL_DONORS.items():
        mailroom.add_donation(donor, amount)

    mailroom.add_donation("Monty Python", 10)
    sorted_donors = [
        donor_obj.name for donor_obj in mailroom.sort_donors_by_donation()
    ]

    assert [
        "Monty Python", "John Adams", "Thomas Jefferson", "John Quincy Adams",
        "George Washington", "James Madison"
    ] == sorted_donors
Example #2
0
def test_get_sorted_donors_with_passed_in_list_of_donors():
    """ test sorting of donor with external donor list """
    mailroom = Mailroom()
    for donor, amount in INITIAL_DONORS.items():
        mailroom.add_donation(donor, amount)

    mailroom.add_donation("Monty Python", 10)

    d1 = Donor("Test One", [1])
    d2 = Donor("Test Two", [1, 2, 3])
    donor_list = [d1, d2]
    sorted_donors = [
        donor_obj.name
        for donor_obj in mailroom.sort_donors_by_donation(donor_list)
    ]

    assert ["Test Two", "Test One"] == sorted_donors