Added tests for successful and unsuccessful full text searches
Also removed extraneous commentsmaster
parent
7aa8fbfe09
commit
62aa5c35c9
|
@ -11,17 +11,14 @@ def test_search_page(client):
|
|||
|
||||
# Test that a successful full text search yields results
|
||||
def test_successful_full_text_search(client):
|
||||
# Search for a title that will result in numerous matches
|
||||
res = client.get("/?type=ft&term=I+Ching")
|
||||
assert res.status_code == 200
|
||||
# Search for the existence of <h2>Results</h2>
|
||||
assert b'<h2>Results</h2>' in res.data
|
||||
# TODO: Convert to more intelligent solution using beautiful soup?
|
||||
# page = BeautifulSoup(res.data, 'html.parser')
|
||||
|
||||
# Test that an unsuccessful full text search returns to the home screen
|
||||
def test_unsuccessful_full_text_search(client):
|
||||
# Search for a nonexistent title
|
||||
res = client.get("/?type=ft&term=blahblahblahblahblahblah")
|
||||
assert res.status_code == 200
|
||||
result_page = BeautifulSoup(res.data, 'html.parser')
|
||||
|
@ -31,17 +28,14 @@ def test_unsuccessful_full_text_search(client):
|
|||
|
||||
# Test that a successful registration number search yields results
|
||||
def test_successful_registration_number_search(client):
|
||||
# Search for a registration number that will result in a match
|
||||
res = client.get("/?type=reg&term=A45173")
|
||||
assert res.status_code == 200
|
||||
# Search for the existence of <h2>Results</h2>
|
||||
assert b'<h2>Results</h2>' in res.data
|
||||
# TODO: Convert to more intelligent solution using beautiful soup?
|
||||
# page = BeautifulSoup(res.data, 'html.parser')
|
||||
|
||||
# Test that an unsuccessful registration number search returns to the home screen
|
||||
def test_unsuccessful_registration_number_search(client):
|
||||
# Search for a nonexistant registration number
|
||||
res = client.get("/?type=reg&term=ThisIsNotARegistrationNumber")
|
||||
assert res.status_code == 200
|
||||
result_page = BeautifulSoup(res.data, 'html.parser')
|
||||
|
@ -49,7 +43,19 @@ def test_unsuccessful_registration_number_search(client):
|
|||
home_page = BeautifulSoup(home_res.data, 'html.parser')
|
||||
assert result_page.string == home_page.string
|
||||
|
||||
# TODO: test_successful_renewal_number_search(client)
|
||||
# TODO: test_successful_renewal_number_search(client)
|
||||
|
||||
# Test that a successful renewal number search yields results
|
||||
def test_successful_renewal_number_search(client):
|
||||
res = client.get("/?type=ren&term=R673507")
|
||||
assert res.status_code == 200
|
||||
assert b'<h2>Results</h2>' in res.data
|
||||
# TODO: Convert to more intelligent solution using beautiful soup?
|
||||
# page = BeautifulSoup(res.data, 'html.parser')
|
||||
|
||||
# Test that an unsuccessful registration number search returns to the home screen
|
||||
def test_unsuccessful_renewal_number_search(client):
|
||||
res = client.get("/?type=ren&term=ThisIsNotARenewalNumber")
|
||||
assert res.status_code == 200
|
||||
result_page = BeautifulSoup(res.data, 'html.parser')
|
||||
home_res = client.get("/")
|
||||
home_page = BeautifulSoup(home_res.data, 'html.parser')
|
||||
assert result_page.string == home_page.string
|
Loading…
Reference in New Issue