def test_validate_postcode_should_return_true_when_valid_postcode_present( postcode): with _current_app.test_request_context() as test_request_ctx: is_valid = validation.validate_postcode(format_postcode(postcode), "postcode") assert is_valid is True assert len(test_request_ctx.session) == 0
def test_validate_postcode_should_return_false_when_invalid_postcode_present( postcode): with _current_app.test_request_context() as test_request_ctx: is_valid = validation.validate_postcode(format_postcode(postcode), "postcode") assert is_valid is False assert len(test_request_ctx.session) == 1 assert test_request_ctx.session["error_items"]["postcode"][ "postcode"] == "Enter a real postcode"
def test_validate_postcode_should_return_false_when_no_postcode_present( postcode): with _current_app.test_request_context() as test_request_ctx: is_valid = validation.validate_postcode(format_postcode(postcode), "postcode") assert is_valid is False assert len(test_request_ctx.session) == 1 assert test_request_ctx.session["error_items"]["postcode"]["postcode"] \ == "What is the postcode where you need support?"
def test_format_postcode_should_convert_to_uppercase(postcode, expected_output): formatted_postcode = format_postcode(postcode) assert formatted_postcode == expected_output
def test_format_postcode_should_remove_whitespace_characters(postcode, expected_output): formatted_postcode = format_postcode(postcode) assert formatted_postcode == expected_output
def test_format_postcode_should_return_none_for_none_truthy_intput_values(postcode): formatted_postcode = format_postcode(postcode) assert formatted_postcode is None