Added tests for author and publisher searches

pull/8/head
Dylan DiGeronimo 2020-04-19 21:53:50 -04:00
parent b43901482a
commit 808be30a08
1 changed files with 27 additions and 5 deletions

View File

@ -12,13 +12,35 @@ def test_successful_title_search(client):
assert res.status_code == 200
assert b'<div class = "results">' in res.data
# Test that an unsuccessful title search returns to the home screen
def test_unsuccessful_full_text_search(client):
# Test that an unsuccessful title search renders an error message
def test_unsuccessful_title_search(client):
res = client.get("/?title=blahhblahblahblah&author=&publisher=&registration=&renewal=")
assert res.status_code == 200
assert b'No results found. Please try another search.' in res.data
# TODO: add author and publisher tests when necessary functionality is complete
# Test that a successful author search yields results
def test_successful_author_search(client):
res = client.get("/?title=&author=Smith&publisher=&registration=&renewal=")
assert res.status_code == 200
assert b'<div class = "results">' in res.data
# Test that an unsuccessful title search renders an error message
def test_unsuccessful_author_search(client):
res = client.get("/?title=&author=IAMNOTANAUTHOR&publisher=&registration=&renewal=")
assert res.status_code == 200
assert b'No results found. Please try another search.' in res.data
# Test that a successful publisher search yields results
def test_successful_publisher_search(client):
res = client.get("/?title=&author=&publisher=Penguin&registration=&renewal=")
assert res.status_code == 200
assert b'<div class = "results">' in res.data
# Test that an unsuccessful publisher search renders an error message
def test_unsuccessful_publisher_search(client):
res = client.get("/?title=&author=&publisher=FAKEPUBLISHERINC&registration=&renewal=")
assert res.status_code == 200
assert b'No results found. Please try another search.' in res.data
# Test that a successful registration number search yields results
def test_successful_registration_number_search(client):
@ -26,7 +48,7 @@ def test_successful_registration_number_search(client):
assert res.status_code == 200
assert b'<div class = "results">' in res.data
# Test that an unsuccessful registration number search returns to the home screen
# Test that an unsuccessful registration number search renders an error message
def test_unsuccessful_registration_number_search(client):
res = client.get("/?title=&author=&publisher=&registration=NOTANUMBER&renewal=")
assert res.status_code == 200
@ -38,7 +60,7 @@ def test_successful_renewal_number_search(client):
assert res.status_code == 200
assert b'<div class = "results">' in res.data
# Test that an unsuccessful registration number search returns to the home screen
# Test that an unsuccessful registration number search renders an error message
def test_unsuccessful_renewal_number_search(client):
res = client.get("/?title=&author=&publisher=&registration=&renewal=NOTANUMBER")
assert res.status_code == 200