示例#1
0
 def test_parse_user_input_invalid_key(self, test_parse_document_list):
     key = "FRANKOCEAN"
     with mock.patch('sys.stdout', new=io.StringIO()) as console_print:
         library_app.parse_user_input(key)
         expected_string = "Document Not found! Please use a valid key"
         assert expected_string in console_print.getvalue().strip()
示例#2
0
 def test_parse_user_input_conference(self, test_parse_document_list):
     key = "Abernethy2000"
     with mock.patch('sys.stdout', new=io.StringIO()) as console_print:
         library_app.parse_user_input(key)
         expected_string = "March 6-8, 2000"
         assert expected_string in console_print.getvalue().strip()
示例#3
0
 def test_parse_user_input_book(self, test_parse_document_list):
     key = "Norris2013"
     with mock.patch('sys.stdout', new=io.StringIO()) as console_print:
         library_app.parse_user_input(key)
         expected_string = "Harper Collins Publishers"
         assert expected_string in console_print.getvalue().strip()
示例#4
0
 def test_parse_user_input_journal(self, test_parse_document_list):
     key = "Inclezan2015"
     with mock.patch('sys.stdout', new=io.StringIO()) as console_print:
         library_app.parse_user_input(key)
         expected_string = "An Application of ASP to the Field of Second Language Acquisition"
         assert expected_string in console_print.getvalue().strip()
示例#5
0
from app import library_app

if __name__ == '__main__':
    """
    The main method of the program
    """
    # The list of books to read in and save
    book_info_list1 = open("Step1Data.txt").readlines()
    book_info_list2 = open("Step2Data.txt").readlines()
    book_info_list3 = open("Step3Data.txt").readlines()
    library_app.parse_document_list(book_info_list1)  # Parse the file and add each book to the dictionary
    library_app.parse_document_list(book_info_list2)  # Parse the file and add each book to the dictionary
    library_app.parse_document_list(book_info_list3)  # Parse the file and add each book to the dictionary

    isRunning = True  # Sets flag in order to be able to break out of the loop
    while isRunning:
        key = input("Which document would you like to access? (Or type END to exit the program): ").lower()
        if key.lower() == "end":  # ends program is user chooses to do so
            isRunning = not isRunning
        else:
            library_app.parse_user_input(key)  # parses key user inputs