Пример #1
0
def test_report():
    """ test report generation """
    mailroom = Mailroom()
    for donor, amount in INITIAL_DONORS.items():
        mailroom.add_donation(donor, amount)

    mailroom.add_donation("Monty Python", 10)
    assert EXPECTED_REPORT == mailroom.report()
Пример #2
0
class TestMailroom(unittest.TestCase):
    """ Unit tests for mailroom """
    def setUp(self):
        donors = {
            "George Washington": [1],
            "John Adams": [3],
            "Thomas Jefferson": [3],
            "John Quincy Adams": [2],
            "James Madison": [1]
        }

        self.mailroom = Mailroom(donors)

    def test_get_menu(self):
        """ test menu """
        self.assertEqual(
            {
                1: "Send a Thank You",
                2: "Create a Report",
                3: "Quit"
            }, self.mailroom.get_menu())

    def test_thanks(self):
        """ test thank you letter """
        self.assertEqual("\n\nDear Monty Python,\nThank you for your " \
                         "donation of 10.\n\n",
                         self.mailroom.thanks("Monty Python", 10))

    def test_report(self):
        """ test report generation """
        self.mailroom.thanks("Monty Python", 10)
        self.assertEqual(EXPECTED_REPORT, self.mailroom.report())

    def test_get_sorted_donors(self):
        """ test sorting of donors """
        self.mailroom.thanks("Monty Python", 10)
        self.assertEqual([
            "Monty Python", "John Adams", "Thomas Jefferson",
            "John Quincy Adams", "George Washington", "James Madison"
        ], self.mailroom._get_sorted_donors())