From ce181db693b06d76e714e454e1a81bb234ed318e Mon Sep 17 00:00:00 2001 From: superchilled Date: Mon, 5 Oct 2026 11:21:51 +0100 Subject: [PATCH 1/4] Adding new unit test for SMS model max_length --- messages/tests/test_sms_models.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/messages/tests/test_sms_models.py b/messages/tests/test_sms_models.py index f5fd62fc..641cedd5 100644 --- a/messages/tests/test_sms_models.py +++ b/messages/tests/test_sms_models.py @@ -59,6 +59,21 @@ 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: From 2a96d306ef6a734e646c70a4859ebb2e5cdab987 Mon Sep 17 00:00:00 2001 From: superchilled Date: Mon, 5 Oct 2026 11:22:51 +0100 Subject: [PATCH 2/4] Updating max_length constraint of SMS model text field --- messages/src/vonage_messages/models/sms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 35ef8b5ba22ee0ec412fa3e9c3349b7545684215 Mon Sep 17 00:00:00 2001 From: superchilled Date: Mon, 5 Oct 2026 11:34:45 +0100 Subject: [PATCH 3/4] Updating error case unit test for max_length in SMS model --- messages/tests/test_sms_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/messages/tests/test_sms_models.py b/messages/tests/test_sms_models.py index 641cedd5..e8f1dc87 100644 --- a/messages/tests/test_sms_models.py +++ b/messages/tests/test_sms_models.py @@ -80,9 +80,9 @@ def test_create_sms_text_too_long(): 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(): From 7afde40a41267624dacfe86e8215d693cf4db1d4 Mon Sep 17 00:00:00 2001 From: superchilled Date: Mon, 5 Oct 2026 11:39:50 +0100 Subject: [PATCH 4/4] linting --- messages/tests/test_sms_models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/messages/tests/test_sms_models.py b/messages/tests/test_sms_models.py index e8f1dc87..1ae340ee 100644 --- a/messages/tests/test_sms_models.py +++ b/messages/tests/test_sms_models.py @@ -59,12 +59,13 @@ 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, - ) + to='1234567890', + from_='1234567890', + text='a' * 3200, + ) sms_dict = { 'to': '1234567890', 'from': '1234567890', @@ -75,6 +76,7 @@ def test_create_sms_text_long_but_within_max_length(): 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(