diff --git a/tests/test_action_block.py b/tests/test_action_block.py index 377bc03..b2ae385 100644 --- a/tests/test_action_block.py +++ b/tests/test_action_block.py @@ -47,19 +47,15 @@ def test_action_block_clean_no_links(): "internal_page": None, "new_window": False, } - internal_error_message = ( - '' - ) - external_error_message = ( - '' - ) + internal_error_message = "Please choose a page or enter a URL above." + external_error_message = "Please enter a URL or choose a page below." with pytest.raises(ValidationError) as excinfo: block.clean(value) - assert str(excinfo.value.params["internal_page"]) == internal_error_message - assert str(excinfo.value.params["external_url"]) == external_error_message - assert "['Validation error in ActionLinkBlock']" == str(excinfo.value) + assert internal_error_message in excinfo.value.params["internal_page"] + assert external_error_message in excinfo.value.params["external_url"] + assert excinfo.value.message == "Validation error in ActionLinkBlock" def test_action_block_clean_two_links(): @@ -70,13 +66,11 @@ def test_action_block_clean_two_links(): "internal_page": "https://internal.com/", "new_window": False, } - error_message = ( - '' - ) + error_message = "Please only enter a URL or choose a page." with pytest.raises(ValidationError) as excinfo: block.clean(value) - assert str(excinfo.value.params["internal_page"]) == error_message - assert str(excinfo.value.params["external_url"]) == error_message - assert "['Validation error in ActionLinkBlock']" == str(excinfo.value) + assert error_message in excinfo.value.params["internal_page"] + assert error_message in excinfo.value.params["external_url"] + assert excinfo.value.message == "Validation error in ActionLinkBlock" diff --git a/tests/test_card_clickable_block.py b/tests/test_card_clickable_block.py index 2f306ae..c48a467 100644 --- a/tests/test_card_clickable_block.py +++ b/tests/test_card_clickable_block.py @@ -14,31 +14,25 @@ def test_card_clickable_block_clean_one_link(): def test_card_clickable_block_clean_no_links(): block = CardClickableBlock() value = {"url": None, "internal_page": None} - internal_error_message = ( - '' - ) - external_error_message = ( - '' - ) + internal_error_message = "Please choose a page or enter a URL below." + external_error_message = "Please enter a URL or choose a page above." with pytest.raises(ValidationError) as excinfo: block.clean(value) - assert str(excinfo.value.params["internal_page"]) == internal_error_message - assert str(excinfo.value.params["url"]) == external_error_message - assert "['Validation error in CardClickableBlock']" == str(excinfo.value) + assert internal_error_message in excinfo.value.params["internal_page"] + assert external_error_message in excinfo.value.params["url"] + assert excinfo.value.message == "Validation error in CardClickableBlock" def test_card_clickable_block_clean_two_links(): block = CardClickableBlock() value = {"url": "https://example.com/", "internal_page": "https://internal.com/"} - error_message = ( - '' - ) + error_message = "Please only enter a URL or choose a page." with pytest.raises(ValidationError) as excinfo: block.clean(value) - assert str(excinfo.value.params["internal_page"]) == error_message - assert str(excinfo.value.params["url"]) == error_message - assert "['Validation error in CardClickableBlock']" == str(excinfo.value) + assert error_message in excinfo.value.params["internal_page"] + assert error_message in excinfo.value.params["url"] + assert excinfo.value.message == "Validation error in CardClickableBlock" diff --git a/tests/test_card_image_block.py b/tests/test_card_image_block.py index 59a83f6..a7243da 100644 --- a/tests/test_card_image_block.py +++ b/tests/test_card_image_block.py @@ -22,13 +22,11 @@ def test_card_image_block_clean_no_links(): def test_card_image_block_clean_two_links(): block = CardImageBlock() value = {"url": "https://example.com/", "internal_page": "https://internal.com/"} - error_message = ( - '' - ) + error_message = "Please only enter a URL or choose a page." with pytest.raises(ValidationError) as excinfo: block.clean(value) - assert str(excinfo.value.params["internal_page"]) == error_message - assert str(excinfo.value.params["url"]) == error_message - assert "['Validation error in CardImageBlock']" == str(excinfo.value) + assert error_message in excinfo.value.params["internal_page"] + assert error_message in excinfo.value.params["url"] + assert excinfo.value.message == "Validation error in CardImageBlock" diff --git a/tests/test_form_tags.py b/tests/test_form_tags.py index c6eed07..7d5ba71 100644 --- a/tests/test_form_tags.py +++ b/tests/test_form_tags.py @@ -55,7 +55,7 @@ def test_widget_is_not_checkbox(): def test_widget_is_checkbox(): - """Test widget is not a checkbox""" + """Test widget is a checkbox""" form = ExampleForm() field = form["checkbox"] assert is_checkbox(field) is True diff --git a/tests/test_pagination_tag.py b/tests/test_pagination_tag.py index cd922a7..1811741 100644 --- a/tests/test_pagination_tag.py +++ b/tests/test_pagination_tag.py @@ -15,7 +15,7 @@ def get_pagination_context(page, request): return new_context -def get_pagination_page(number): +def get_pagination_page_context(number): """ Get paginated page """ response = client.get(f"/home/pagination/pagination-page-{number}/") request = response.wsgi_request @@ -26,7 +26,7 @@ def get_pagination_page(number): @pytest.mark.django_db def test_first_page(db, django_db_setup): """ Check first page has next keys but no prev keys """ - context = get_pagination_page(1) + context = get_pagination_page_context(1) expected = { "next_label": "Pagination page 2", "next_url": "/pagination/pagination-page-2/", @@ -37,7 +37,7 @@ def test_first_page(db, django_db_setup): @pytest.mark.django_db def test_third_page(db, django_db_setup): """ Check third page has next and prev keys """ - context = get_pagination_page(3) + context = get_pagination_page_context(3) expected = { "prev_label": "Pagination page 2", "prev_url": "/pagination/pagination-page-2/", @@ -49,8 +49,8 @@ def test_third_page(db, django_db_setup): @pytest.mark.django_db def test_final_page(db, django_db_setup): - """ Check third page has only prev keys """ - context = get_pagination_page(4) + """ Check fourth page has only prev keys """ + context = get_pagination_page_context(4) print(context) expected = { "prev_label": "Pagination page 3",