def main(): food_db_manager = CSVDatabaseManager("food_db.csv") exercise_db_manager = CSVDatabaseManager("excercise_db.csv") input_timeline_manager = CSVTimelineManager() # NOTE: you can change "test_case_1.csv" below to your own input file to run # it on your own input. input_timeline_manager.load_timeline("test_case_1.csv") input_timeline = input_timeline_manager.get_timeline() bss = BloodSugarSimulator(food_db_manager, exercise_db_manager, input_timeline) bss.run() bss.print_results()
def test_db_loading(self): """ This test saves TimelineEntries into a file and then opens them and checks to see that they all exist. Test case is small currently. """ ctm_writer = CSVTimelineManager() input_entries = [TimelineEntry('type1', 12, 'v2'), TimelineEntry('type2', 2, 'v42'), TimelineEntry('type1', 5, 'v4'), TimelineEntry('type1', 3, 'v424'), TimelineEntry('type2', 15, 'v432'), TimelineEntry('type2', 4, 'v4215') ] for entry in input_entries: ctm_writer.add_entry_with_sorting(entry) # timeline = ctm.get_timeline() ctm_writer.save_timeline("test_timeline_manager_1.csv") # output entries will be sorted output_entries = sorted(input_entries, key=lambda e: e.time) ctm_reader = CSVTimelineManager() ctm_reader.load_timeline("test_timeline_manager_1.csv") self.assertEquals(output_entries, ctm_reader.get_timeline())