Exemple #1
0
def page_entries(entries):
    """Display each record with paging options.

    :param entries: list of entries found with search criteria
    :return:None
    """

    index = 0
    paging = True

    while paging:
        entry = entries[index]
        entry_id = entry.id

        clear_screen()
        print("Result {} out of {}".format(index + 1, len(entries)))
        print('=' * 10)
        print_entry(entry)
        print('=' * 10)
        print(page_menu(index, entries))
        user_choice = input("\n> ")

        if user_choice == "n":
            if index == (len(entries) - 1):
                print("\nCan't go forward!\n")
                input("Press any key to continue...")
            else:
                index += 1
            continue
        elif user_choice == "b":
            if index < 1:
                print("\nCan't go back!\n")
                input("Press any key to continue...")
            else:
                index -= 1
            continue
        elif user_choice == "e":
            edit_entry(entry, entry_id)
            break
        elif user_choice == "d":
            del_entry(entry_id)
            clear_screen()
            print("Entry has been deleted!\n")
            input("Press any key to continue...")
            break
        elif user_choice == "r":
            break
        else:
            input("\nNot a valid option! Press any key to continue...")
Exemple #2
0
 def test_page_menu_at_begin(self):
     result = page_menu(0, ["entry1" , "entry2"])
     self.assertEqual(result, "[N]ext, [E]dit, [D]elete, [R]eturn to Search Menu")
Exemple #3
0
 def test_page_menu_at_mid(self):
     result = page_menu(1, ["entry1" , "entry2", "entry3"])
     self.assertEqual(result, "[N]ext, [B]ack, [E]dit, [D]elete, [R]eturn to Search Menu")
Exemple #4
0
 def test_page_menu_with_one_entry(self):
     result = page_menu(1, ["entry1"])
     self.assertEqual(result, "[E]dit, [D]elete, [R]eturn to Search Menu")