From 62aa5c35c9b8775c3177473b3d06f0c29c743686 Mon Sep 17 00:00:00 2001 From: Dylan DiGeronimo Date: Wed, 29 Jan 2020 21:55:55 -0500 Subject: [PATCH] Added tests for successful and unsuccessful full text searches Also removed extraneous comments --- tests/test_search.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/test_search.py b/tests/test_search.py index 96d57ab..f193899 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -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

Results

assert b'

Results

' 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

Results

assert b'

Results

' 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'

Results

' 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 \ No newline at end of file