Skip to content

Commit

Permalink
Passing Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rparke committed Jul 11, 2024
1 parent 8ffeadb commit 62b250b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions app/schema_validation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ def validate_uuid(instance):
return True


@format_checker.checks("phone_number", raises=InvalidPhoneError)
@format_checker.checks("phone_number", raises=ValidationError)
def validate_schema_phone_number(instance):
if isinstance(instance, str):
try:
validate_phone_number(instance, international=True)
except InvalidPhoneError as e:
# msg = e.get_legacy_v2_api_error_message()
# raise ValidationError(msg)
raise e
legacy_message = e.get_legacy_v2_api_error_message()
raise ValidationError(legacy_message) from None
# raise e
return True


Expand Down Expand Up @@ -133,7 +133,6 @@ def validate(json_to_validate, schema):
def build_error_message(errors):
fields = []
for e in errors:
breakpoint()
field = (
"{} {}".format(e.path[0] if e.path else "", e.schema["validationMessage"]).strip()
if "validationMessage" in e.schema
Expand Down
6 changes: 3 additions & 3 deletions tests/app/v2/notifications/test_notification_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ def test_post_sms_schema_with_personalisation_that_is_not_a_dict():
@pytest.mark.parametrize(
"invalid_phone_number, err_msg",
[
("08515111111", "This does not look like a UK mobile number – double check the mobile number you entered"),
("07515111*11", "Mobile numbers can only include: 0 1 2 3 4 5 6 7 8 9 ( ) + -"),
("notaphoneumber", "Mobile numbers can only include: 0 1 2 3 4 5 6 7 8 9 ( ) + -"),
("08515111111", "phone_number Not a UK mobile number"),
("07515111*11", "phone_number Must not contain letters or symbols"),
("notaphoneumber", "phone_number Must not contain letters or symbols"),
(7700900001, "phone_number 7700900001 is not of type string"),
(None, "phone_number None is not of type string"),
([], "phone_number [] is not of type string"),
Expand Down

0 comments on commit 62b250b

Please sign in to comment.