def test_send_message_no_body(make_stubber, make_queue): """Test that sending a message with no body raises an exception.""" sqs_stubber = make_stubber(message_wrapper.sqs.meta.client) queue = make_queue(sqs_stubber, message_wrapper.sqs) sqs_stubber.stub_send_message(queue.url, '', {}, '', error_code='MissingParameter') with pytest.raises(ClientError) as exc_info: message_wrapper.send_message(queue, '') assert exc_info.value.response['Error']['Code'] == 'MissingParameter'
def test_send_message_no_body(sqs_stubber, queue_stub): """Test that sending a message with no body raises an exception.""" sqs_stubber.add_client_error('send_message', expected_params={ 'QueueUrl': queue_stub.url, 'MessageBody': '', 'MessageAttributes': {} }, service_error_code='MissingParameter') with pytest.raises(ClientError): message_wrapper.send_message(queue_stub, '')
def test_send_message(sqs_stubber, queue_stub, body, attributes): """Test that sending a message returns a message ID.""" sqs_stubber.add_response('send_message', expected_params={ 'QueueUrl': queue_stub.url, 'MessageBody': body, 'MessageAttributes': attributes }, service_response={'MessageId': '1234-5678'}) response = message_wrapper.send_message(queue_stub, body, attributes) assert response['MessageId']
def test_send_message(make_stubber, make_queue, body, attributes): """Test that sending a message returns a message ID.""" sqs_stubber = make_stubber(message_wrapper.sqs.meta.client) queue = make_queue(sqs_stubber, message_wrapper.sqs) message_id = '1234-5678' sqs_stubber.stub_send_message(queue.url, body, attributes, message_id) response = message_wrapper.send_message(queue, body, attributes) if sqs_stubber.use_stubs: assert response['MessageId'] == message_id else: assert response['MessageId']