def test_journal_save_content(): if os.path.exists(file_path): os.remove(file_path) entry_1 = 'This is my first entry journal entry' expected = '{}\n'.format(entry_1) journal = Journal() journal.add(entry_1) journal.save() actual = open(file_path, 'r').read() assert expected == actual
def run_event_loop(): my_journal = Journal('personal') command = query_user() while command != 'x': if command == 'l': my_journal.list() elif command == 'a': my_journal.add(input('Enter your journal entry:\n')) command = query_user() my_journal.save()
def main(): journal = Journal() menu = Menu() selection = menu.prompt() while selection != 'x': if selection == 'l': print(journal.list()) elif selection == 'a': journal.add(input('Enter your journal entry:\n')) selection = menu.prompt() journal.save()
def test_journal_add_content(): if os.path.exists(file_path): os.remove(file_path) entry_1 = 'This is my first entry journal entry' entry_2 = 'Now we have excellent history features.' expected = "{}\n{}\n".format(entry_1, entry_2) journal = Journal() journal.add(entry_1) journal.save() journal = Journal() journal.add(entry_2) journal.save() actual = open(file_path, 'r').read() assert expected == actual
def run_program_loop(journal: Journal): """ Runs the program loop: asking the user what do to, until the user chooses to exit the app. :param journal: The Journal object to work with :return: """ cmd = "." while cmd and cmd != "x": cmd = ui.read_menu_input() if cmd == "l": ui.print_entries(journal.entries) elif cmd == "a": text = ui.read_add_entry_input() journal.add_entry(text) elif cmd == "x": journal.save(journal_file_name) exit(0)