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:
Mike Grima 2019-11-16 10:24:09 -08:00 committed by GitHub
commit e70ad8fd12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -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 "

View File

@ -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")