示例#1
0
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()
示例#2
0
def test_journal_add_new_content():
    if os.path.exists(file_path):
        os.remove(file_path)
    entry_1 = 'This is my first entry journal entry'
    expected = 'Your 1 journal entry\n\n1. {}\n'.format(entry_1)
    journal = Journal()
    journal.add(entry_1)
    actual = journal.list()
    assert expected == actual
示例#3
0
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()