Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion messages/src/vonage_messages/models/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Sms(BaseMessage):
"""

from_: Union[PhoneNumber, str] = Field(..., serialization_alias='from')
text: str = Field(..., max_length=1000)
text: str = Field(..., max_length=3200)
ttl: Optional[int] = Field(None, ge=20, le=604800)
trusted_recipient: Optional[bool] = None
sms: Optional[SmsOptions] = None
Expand Down
21 changes: 19 additions & 2 deletions messages/tests/test_sms_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,31 @@ def test_create_sms_all_fields():
assert sms_model.model_dump(by_alias=True) == sms_dict


def test_create_sms_text_long_but_within_max_length():
sms_model = Sms(
to='1234567890',
from_='1234567890',
text='a' * 3200,
)
sms_dict = {
'to': '1234567890',
'from': '1234567890',
'text': 'a' * 3200,
'channel': 'sms',
'message_type': 'text',
}

assert sms_model.model_dump(by_alias=True, exclude_none=True) == sms_dict


def test_create_sms_text_too_long():
with pytest.raises(ValidationError) as err:
Sms(
to='1234567890',
from_='1234567890',
text='a' * 1001,
text='a' * 3201,
)
assert 'String should have at most 1000 characters' in str(err.value)
assert 'String should have at most 3200 characters' in str(err.value)


def test_create_sms_with_invalid_encoding_type():
Expand Down
Loading