Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit aa9383f

Browse files
committed
add more unit tests
1 parent ad0650f commit aa9383f

1 file changed

Lines changed: 65 additions & 1 deletion

File tree

tests/unit/aws/protocol/test_serializer.py

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,7 @@ def test_json_protocol_error_serialization_with_shaped_default_members_on_root()
765765

766766

767767
def test_json_protocol_error_serialization_empty_message():
768+
# if the exception message is not passed, an empty message will be passed as an empty string `""`
768769
exception = TransactionCanceledException()
769770

770771
response = _botocore_error_serializer_integration_test(
@@ -778,6 +779,45 @@ def test_json_protocol_error_serialization_empty_message():
778779
assert "message" not in response
779780

780781

782+
@pytest.mark.parametrize("empty_value", ("", None))
783+
def test_json_protocol_error_serialization_empty_non_required_members(empty_value):
784+
# if the exception message is not passed, an empty message will be passed as an empty string `""`
785+
exception = TransactionCanceledException()
786+
787+
response = _botocore_error_serializer_integration_test(
788+
"dynamodb",
789+
"ExecuteTransaction",
790+
exception,
791+
"TransactionCanceledException",
792+
400,
793+
"",
794+
)
795+
assert "message" not in response
796+
797+
798+
@pytest.mark.parametrize("empty_value", ("", None))
799+
def test_json_protocol_error_serialization_with_empty_non_required_members(empty_value):
800+
class _ResourceNotFoundException(ServiceException):
801+
code: str = "ResourceNotFoundException"
802+
sender_fault: bool = True
803+
status_code: int = 404
804+
ResourceType: str | None
805+
ResourceId: str | None
806+
807+
exception = _ResourceNotFoundException("Not Found", ResourceType="")
808+
809+
response = _botocore_error_serializer_integration_test(
810+
"arc-region-switch",
811+
"ApprovePlanExecutionStep",
812+
exception,
813+
"ResourceNotFoundException",
814+
404,
815+
"Not Found",
816+
protocol="json",
817+
)
818+
assert "ResourceType" not in response
819+
820+
781821
@pytest.mark.parametrize("empty_value", ("", None))
782822
def test_json_protocol_error_serialization_with_empty_required_members(empty_value):
783823
class _ResourceNotFoundException(ServiceException):
@@ -801,7 +841,7 @@ class _ResourceNotFoundException(ServiceException):
801841
if empty_value is not None:
802842
expected_exception_values["resourceId"] = ""
803843

804-
_botocore_error_serializer_integration_test(
844+
response = _botocore_error_serializer_integration_test(
805845
"verifiedpermissions",
806846
"IsAuthorizedWithToken",
807847
exception,
@@ -810,6 +850,7 @@ class _ResourceNotFoundException(ServiceException):
810850
"Exception message!",
811851
**expected_exception_values,
812852
)
853+
assert "" not in response
813854

814855

815856
def test_rest_json_protocol_error_serialization_with_additional_members():
@@ -996,6 +1037,29 @@ class AccessDeniedException(ServiceException):
9961037
)
9971038

9981039

1040+
@pytest.mark.parametrize("empty_value", ("", None))
1041+
def test_rpc_v2_cbor_protocol_error_serialization_with_empty_non_required_members(empty_value):
1042+
class _ResourceNotFoundException(ServiceException):
1043+
code: str = "ResourceNotFoundException"
1044+
sender_fault: bool = True
1045+
status_code: int = 404
1046+
ResourceType: str | None
1047+
ResourceId: str | None
1048+
1049+
exception = _ResourceNotFoundException("Not Found", ResourceType="")
1050+
1051+
response = _botocore_error_serializer_integration_test(
1052+
"arc-region-switch",
1053+
"ApprovePlanExecutionStep",
1054+
exception,
1055+
"ResourceNotFoundException",
1056+
404,
1057+
"Not Found",
1058+
protocol="smithy-rpc-v2-cbor",
1059+
)
1060+
assert "ResourceType" not in response
1061+
1062+
9991063
def test_json_protocol_content_type_1_0():
10001064
"""AppRunner defines the jsonVersion 1.0, therefore the Content-Type needs to be application/x-amz-json-1.0."""
10011065
service = load_service("apprunner")

0 commit comments

Comments
 (0)