Merge pull request #2569 from gruebel/fix-sns-publish-number-type
Fix sns.publish with number type and 0 value
This commit is contained in:
commit
e70ad8fd12
@ -77,7 +77,7 @@ class SNSResponse(BaseResponse):
|
||||
transform_value = value["StringValue"]
|
||||
elif "BinaryValue" in value:
|
||||
transform_value = value["BinaryValue"]
|
||||
if not transform_value:
|
||||
if transform_value == "":
|
||||
raise InvalidParameterValue(
|
||||
"The message attribute '{0}' must contain non-empty "
|
||||
"message attribute value for message attribute "
|
||||
|
@ -173,6 +173,27 @@ def test_publish_to_sqs_msg_attr_byte_value():
|
||||
)
|
||||
|
||||
|
||||
@mock_sqs
|
||||
@mock_sns
|
||||
def test_publish_to_sqs_msg_attr_number_type():
|
||||
sns = boto3.resource("sns", region_name="us-east-1")
|
||||
topic = sns.create_topic(Name="test-topic")
|
||||
sqs = boto3.resource("sqs", region_name="us-east-1")
|
||||
queue = sqs.create_queue(QueueName="test-queue")
|
||||
topic.subscribe(Protocol="sqs", Endpoint=queue.attributes["QueueArn"])
|
||||
|
||||
topic.publish(
|
||||
Message="test message",
|
||||
MessageAttributes={"retries": {"DataType": "Number", "StringValue": "0"}},
|
||||
)
|
||||
|
||||
message = json.loads(queue.receive_messages()[0].body)
|
||||
message["Message"].should.equal("test message")
|
||||
message["MessageAttributes"].should.equal(
|
||||
{"retries": {"Type": "Number", "Value": 0}}
|
||||
)
|
||||
|
||||
|
||||
@mock_sns
|
||||
def test_publish_sms():
|
||||
client = boto3.client("sns", region_name="us-east-1")
|
||||
|
Loading…
Reference in New Issue
Block a user