diff --git a/messages/src/vonage_messages/models/sms.py b/messages/src/vonage_messages/models/sms.py index de8af589..b6b8f879 100644 --- a/messages/src/vonage_messages/models/sms.py +++ b/messages/src/vonage_messages/models/sms.py @@ -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 diff --git a/messages/tests/test_sms_models.py b/messages/tests/test_sms_models.py index f5fd62fc..1ae340ee 100644 --- a/messages/tests/test_sms_models.py +++ b/messages/tests/test_sms_models.py @@ -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():