Program 3 Test Cases Fall 2017

Some thoughts about the user inputs
All inputs from the user are strings. It is impossible to crash an input with a string; any character is allowed in a string. So there are no test cases with "non-numeric input" on this program.
 

Test cases for function get_data

DescriptionInput (filename) Expected Output/Behavior
1. Normal run, filename that exists "test1.txt" which exists and contains
http://www.aol.com, Commercial Internet service
http://www.toyota.com, car sales
http://www.uky.edu, school research Kentucky university Lexington
all data is returned in a list
[["http://www.aol.com", "Commercial Internet service"],
["http://www.toyota.com", "car sales"]
["http://www.uky.edu", "school research Kentucky university Lexington"]
]
2. Normal run, one filename that does not exist then one that does "test2.txt" (does not exist) then "test1.txt" exists as in Case 1 prompt, "test1.txt", message "test2.txt cannot be opened", another prompt, "test1.txt", all data returned in a list
[["http://www.aol.com", "Commercial Internet service"],
["http://www.toyota.com", "car sales"]
["http://www.uky.edu", "school research Kentucky university Lexington"]
]
3. Normal run, two filenames that do not exist then one that does prompt, "test1.txt", message "test2.txt cannot be opened", another prompt, "test3.txt", message "test3.txt cannot be opened", another prompt, "test1.txt" all data returned in a list, "Data retrieved from file" on shell
[["http://www.aol.com", "Commercial Internet service"],
["http://www.toyota.com", "car sales"]
["http://www.uky.edu", "school research Kentucky university Lexington"]
]
4. Normal run, file with one line in it "test1.txt" which exists and contains
http://www.aol.com, Commercial Internet service
all data is returned in a list
[["http://www.aol.com", "Commercial Internet service"] ]
5. Normal run, file with no data in it "test1.txt" which exists and contains just one space on a line

NO data is returned ([]) and a message "Data is not well formatted, no data is retrieved"

Test cases for function do_a_search

DescriptionInputs (datalist, key phrase, outputfilename) Expected Output/Behavior
6. Normal, no hits
[["http://www.aol.com", "Commercial Internet service"],
["http://www.toyota.com", "car sales"]
["http://www.uky.edu", "school research Kentucky university Lexington"]
]
, dog, myhits.html
Creation of html file myhits.html that says the string "dog" was not found, a zero is returned
7. Normal, one hit
[["http://www.aol.com", "Commercial Internet service"],
["http://www.toyota.com", "car sales"]
["http://www.uky.edu", "school research Kentucky university Lexington"]
]
"Internet", myhits.html
Creation of html file myhits.html with a header that mentions "Internet" and a table with one row including the info in the hit list (one column "http://www.aol.com", one column "Commercial Internet service" and Internet bolded, the number 1 is returned
8. Normal, two hits
[["http://www.aol.com", "Commercial Internet service"],
["http://www.toyota.com", "car sales"]
["http://www.uky.edu", "school research Kentucky university Lexington"]
]
, "se", myhits.html
Creation of html file myhits.html with a header that mentions "se" and a table with two rows including the info in the hit list (first column contains "http://www.aol.com" and "http://www.uky.edu", second column contains "Commercial Internet service" and "school research Kentucky university Lexington" and "se" bolded, the number 2 is returned

Test cases for function report_failed

DescriptionInputs (search phrase, outfilename) Expected Output/Behavior
9. Normal case, search failed (no hits) dog, myhits.htmlCreation of html file myhits.html that says the string "dog" was not found

Test cases for function report_hits

DescriptionInputs (hits, search phrase, outfilename) Expected Output/Behavior
10. Normal, one hit [["http://www.aol.com", "Commercial Internet service"]], "Internet", myhits.html Creation of html file myhits.html with a header that mentions "Internet" and a table with one row including the info in the hit list (one column "http://www.aol.com", one column "Commercial Internet service" and Internet bolded
11. Normal, two hits [["http://www.aol.com", "Commercial Internet service"], ["http://www.uky.edu", "school research Kentucky university Lexington"] "se", myhits.html Creation of html file myhits.html with a header that mentions "se" and a table with two rows including the info in the hit list (first column "http://www.aol.com", "http://www.uky.edu", second column "Commercial Internet service" and "school research Kentucky university Lexington" and "se" bolded

Test cases for function add_to_log

DescriptionInputs (user id, search phrase) Expected Output/Behavior
12. Normal case, secret.txt already exists keen, rental car the two inputs added to the end of secret.txt, two separate lines, userid first
13. Normal case, secret.txt does not exist keen, rental car secret.txt created with the two inputs in it, two separate lines, userid first

Test cases for function main

DescriptionInputs (user id, search phrase, database file) Expected Output/Behavior
14. Normal, empty database, unsuccessful search, case sensitive keen, "abc",
  just a space
header output, prompts, data file not read, result showing failure in html file, secret.txt updated with userid and search phrase
15. Normal, database file with 3 lines, unsuccessful search, case not sensitive keen, "DOG",
[["http://www.aol.com", "Commercial Internet service"],
["http://www.toyota.com", "car sales"]
["http://www.uky.edu", "school research Kentucky university Lexington"]
]
header output, prompts, test1.txt data read, results showing 0 hits in html file, secret.txt updated with userid and search phrase
16. Normal, database file with 3 lines, successful search with 2 hits, case not sensitive keen, "SE",
[["http://www.aol.com", "Commercial Internet service"],
["http://www.toyota.com", "car sales"]
["http://www.uky.edu", "school research Kentucky university Lexington"]
]
header output, prompts, test1.txt data read, results showing 2 hits in html file, secret.txt updated with userid and search phrase