-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Chris Johnson <[email protected]>
- Loading branch information
1 parent
8851571
commit 4686327
Showing
5 changed files
with
107 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,14 @@ | |
import pytest | ||
from pydantic import ValidationError | ||
|
||
from app.legacy.v2.notifications.route_schema import V2PostEmailRequestModel, V2PostSmsRequestModel | ||
from app.constants import IdentifierType | ||
from app.legacy.v2.notifications.route_schema import ( | ||
V2PostEmailRequestModel, | ||
V2PostSmsRequestModel, | ||
) | ||
|
||
VALID_PHONE_NUMBER = '+17045555555' | ||
INVALID_PHONE_NUMBER = '+5555555555' | ||
|
||
###################################################################### | ||
# Test POST e-mail schemas | ||
|
@@ -19,7 +26,7 @@ | |
'data', | ||
[ | ||
{'email_address': '[email protected]'}, | ||
{'recipient_identifier': {'id_type': 'ICN', 'id_value': 'test'}}, | ||
{'recipient_identifier': {'id_type': IdentifierType.ICN, 'id_value': 'test'}}, | ||
], | ||
ids=( | ||
'e-mail address', | ||
|
@@ -61,16 +68,21 @@ def test_v2_post_email_request_model_invalid(data: dict[str, str | dict[str, str | |
@pytest.mark.parametrize( | ||
'data', | ||
[ | ||
{'phone_number': '+17045555555'}, | ||
{'recipient_identifier': {'id_type': 'ICN', 'id_value': 'test'}}, | ||
{'phone_number': VALID_PHONE_NUMBER}, | ||
{'recipient_identifier': {'id_type': IdentifierType.ICN, 'id_value': 'test'}}, | ||
{ | ||
'phone_number': VALID_PHONE_NUMBER, | ||
'recipient_identifier': {'id_type': IdentifierType.ICN, 'id_value': 'test'}, | ||
}, | ||
], | ||
ids=( | ||
'phone number', | ||
'recipient ID', | ||
'phone number and recipient ID', | ||
), | ||
) | ||
def test_v2_post_sms_request_model_valid(data: dict[str, str | dict[str, str]]) -> None: | ||
"""Valid data with an e-mail address should not raise ValidationError.""" | ||
"""Valid required data should not raise ValidationError.""" | ||
data['sms_sender_id'] = str(uuid4()) | ||
data['template_id'] = str(uuid4()) | ||
assert isinstance(V2PostSmsRequestModel.model_validate(data), V2PostSmsRequestModel) | ||
|
@@ -80,12 +92,10 @@ def test_v2_post_sms_request_model_valid(data: dict[str, str | dict[str, str]]) | |
'data', | ||
[ | ||
{}, | ||
{'phone_number': '+17045555555', 'recipient_identifier': {'id_type': 'ICN', 'id_value': 'test'}}, | ||
{'phone_number': '+5555555555'}, | ||
{'phone_number': INVALID_PHONE_NUMBER}, | ||
], | ||
ids=( | ||
'neither phone number nor recipient ID', | ||
'phone number and recipient ID', | ||
'invalid us phone number', | ||
), | ||
) | ||
|