def test_empty_db(): """ tests that you can initilize an empty DB """ db = model.DonorDB() donor_list = db.list_donors() print(donor_list) # no donors assert donor_list.strip() == "Donor list:"
def test_database_save(): db = model.DonorDB(model.get_sample_data()) json_dict = db.to_json_compat() db2 = model.DonorDB.from_json_dict(json_dict) print(db2) assert db2 == db assert db2.donor_data == db.donor_data
The only code in here should deal with the command line interface. Nothing to do with the logic code, etc that does the real work. """ import sys import math # handy utility to make pretty printing easier from textwrap import dedent from mailroom import model # create a DB with the sample data db = model.DonorDB(model.get_sample_data()) def main_menu_selection(): """ Print out the main application menu and then read the user input. """ action = input(dedent(''' Choose an action: 1 - Send a Thank You 2 - Create a Report 3 - Send letters to everyone 4 - Quit > '''))
def sample_db(): """ creates a clean sample database for the tests to use """ return model.DonorDB(model.get_sample_data())
def test_save_load_file(): db = model.DonorDB(model.get_sample_data()) db.save_to_file("test.json") db2 = model.DonorDB.load_from_file("test.json") assert db == db2