Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save edisongustavo/30c7f7dfaadfb2a36bdd0f3d9597d420 to your computer and use it in GitHub Desktop.
Save edisongustavo/30c7f7dfaadfb2a36bdd0f3d9597d420 to your computer and use it in GitHub Desktop.
Moto failures after adding idna version
====================================================================================================================================================================== FAILURES ======================================================================================================================================================================
___________________________________________________________________________________________________________________________________________________________ test_http_proxying_integration ___________________________________________________________________________________________________________________________________________________________
@mock_apigateway
def test_http_proxying_integration():
responses_mock.add(
responses_mock.GET, "http://httpbin.org/robots.txt", body="a fake response"
)
region_name = "us-west-2"
client = boto3.client("apigateway", region_name=region_name)
response = client.create_rest_api(name="my_api", description="this is my api")
api_id = response["id"]
resources = client.get_resources(restApiId=api_id)
root_id = [resource for resource in resources["items"] if resource["path"] == "/"][
0
]["id"]
client.put_method(
restApiId=api_id, resourceId=root_id, httpMethod="GET", authorizationType="none"
)
client.put_method_response(
restApiId=api_id, resourceId=root_id, httpMethod="GET", statusCode="200"
)
response = client.put_integration(
restApiId=api_id,
resourceId=root_id,
httpMethod="GET",
type="HTTP",
uri="http://httpbin.org/robots.txt",
integrationHttpMethod="POST",
)
stage_name = "staging"
client.create_deployment(restApiId=api_id, stageName=stage_name)
deploy_url = "https://{api_id}.execute-api.{region_name}.amazonaws.com/{stage_name}".format(
api_id=api_id, region_name=region_name, stage_name=stage_name
)
if not settings.TEST_SERVER_MODE:
> requests.get(deploy_url).content.should.equal(b"a fake response")
tests/test_apigateway/test_apigateway.py:1829:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/api.py:72: in get
return request('get', url, params=params, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/api.py:58: in request
return session.request(method=method, url=url, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/sessions.py:522: in request
resp = self.send(prep, **send_kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/sessions.py:642: in send
r = adapter.send(request, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/responses-0.13.3-py3.7.egg/responses/__init__.py:765: in unbound_on_send
return self._on_request(adapter, request, *a, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/responses-0.13.3-py3.7.egg/responses/__init__.py:748: in _on_request
response = adapter.build_response(request, match.get_response(request))
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/responses-0.13.3-py3.7.egg/responses/__init__.py:445: in get_response
result = self.callback(request)
moto/apigateway/models.py:686: in resource_callback
status_code, response = resource.get_response(request)
moto/apigateway/models.py:275: in get_response
response = requests_func(uri)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/api.py:72: in get
return request('get', url, params=params, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/api.py:58: in request
return session.request(method=method, url=url, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/sessions.py:522: in request
resp = self.send(prep, **send_kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/sessions.py:642: in send
r = adapter.send(request, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/responses-0.13.3-py3.7.egg/responses/__init__.py:765: in unbound_on_send
return self._on_request(adapter, request, *a, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/responses-0.13.3-py3.7.egg/responses/__init__.py:748: in _on_request
response = adapter.build_response(request, match.get_response(request))
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/adapters.py:281: in build_response
extract_cookies_to_jar(response.cookies, req, resp)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/cookies.py:133: in extract_cookies_to_jar
jar.extract_cookies(res, req)
../../miniconda3/envs/moto-py3/lib/python3.7/http/cookiejar.py:1679: in extract_cookies
for cookie in self.make_cookies(response, request):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <RequestsCookieJar[]>, response = <requests.cookies.MockResponse object at 0x7fa05409efd0>, request = <requests.cookies.MockRequest object at 0x7fa05409e8d0>
def make_cookies(self, response, request):
"""Return sequence of Cookie objects extracted from response object."""
# get cookie-attributes for RFC 2965 and Netscape protocols
headers = response.info()
> rfc2965_hdrs = headers.get_all("Set-Cookie2", [])
E AttributeError: 'HTTPHeaderDict' object has no attribute 'get_all'
../../miniconda3/envs/moto-py3/lib/python3.7/http/cookiejar.py:1597: AttributeError
_____________________________________________________________________________________________________________________________________________________ test_invoke_requestresponse_function[None] _____________________________________________________________________________________________________________________________________________________
invocation_type = None
@pytest.mark.network
@pytest.mark.parametrize("invocation_type", [None, "RequestResponse"])
@mock_lambda
def test_invoke_requestresponse_function(invocation_type):
conn = boto3.client("lambda", _lambda_region)
conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
Role=get_role_name(),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": get_test_zip_file1()},
Description="test lambda function",
Timeout=3,
MemorySize=128,
Publish=True,
)
# Only add invocation-type keyword-argument when provided, otherwise the request
# fails to be validated
kw = {}
if invocation_type:
kw["InvocationType"] = invocation_type
in_data = {"msg": "So long and thanks for all the fish"}
success_result = conn.invoke(
FunctionName="testFunction", Payload=json.dumps(in_data), LogType="Tail", **kw
)
if "FunctionError" in success_result:
> assert False, success_result["Payload"].read().decode("utf-8")
E AssertionError: error running docker: 500 Server Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=docker.io%2Flibrary%2Falpine: Internal Server Error ("toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit")
E assert False
tests/test_awslambda/test_lambda.py:134: AssertionError
_______________________________________________________________________________________________________________________________________________ test_invoke_requestresponse_function[RequestResponse] ________________________________________________________________________________________________________________________________________________
invocation_type = 'RequestResponse'
@pytest.mark.network
@pytest.mark.parametrize("invocation_type", [None, "RequestResponse"])
@mock_lambda
def test_invoke_requestresponse_function(invocation_type):
conn = boto3.client("lambda", _lambda_region)
conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
Role=get_role_name(),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": get_test_zip_file1()},
Description="test lambda function",
Timeout=3,
MemorySize=128,
Publish=True,
)
# Only add invocation-type keyword-argument when provided, otherwise the request
# fails to be validated
kw = {}
if invocation_type:
kw["InvocationType"] = invocation_type
in_data = {"msg": "So long and thanks for all the fish"}
success_result = conn.invoke(
FunctionName="testFunction", Payload=json.dumps(in_data), LogType="Tail", **kw
)
if "FunctionError" in success_result:
> assert False, success_result["Payload"].read().decode("utf-8")
E AssertionError: error running docker: 500 Server Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=docker.io%2Flibrary%2Falpine: Internal Server Error ("toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit")
E assert False
tests/test_awslambda/test_lambda.py:134: AssertionError
___________________________________________________________________________________________________________________________________________________ test_invoke_requestresponse_function_with_arn ____________________________________________________________________________________________________________________________________________________
@pytest.mark.network
@mock_lambda
def test_invoke_requestresponse_function_with_arn():
from moto.awslambda.models import ACCOUNT_ID
conn = boto3.client("lambda", "us-west-2")
conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
Role=get_role_name(),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": get_test_zip_file1()},
Description="test lambda function",
Timeout=3,
MemorySize=128,
Publish=True,
)
in_data = {"msg": "So long and thanks for all the fish"}
success_result = conn.invoke(
FunctionName="arn:aws:lambda:us-west-2:{}:function:testFunction".format(
ACCOUNT_ID
),
InvocationType="RequestResponse",
Payload=json.dumps(in_data),
)
success_result["StatusCode"].should.equal(200)
payload = success_result["Payload"].read().decode("utf-8")
> json.loads(payload).should.equal(in_data)
tests/test_awslambda/test_lambda.py:185:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../miniconda3/envs/moto-py3/lib/python3.7/json/__init__.py:348: in loads
return _default_decoder.decode(s)
../../miniconda3/envs/moto-py3/lib/python3.7/json/decoder.py:337: in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <json.decoder.JSONDecoder object at 0x7fa058e77ed0>, s = 'error running docker: 500 Server Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=docker.io...l rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit")', idx = 0
def raw_decode(self, s, idx=0):
"""Decode a JSON document from ``s`` (a ``str`` beginning with
a JSON document) and return a 2-tuple of the Python
representation and the index in ``s`` where the document ended.
This can be used to decode a JSON document from a string that may
have extraneous data at the end.
"""
try:
obj, end = self.scan_once(s, idx)
except StopIteration as err:
> raise JSONDecodeError("Expecting value", s, err.value) from None
E json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
../../miniconda3/envs/moto-py3/lib/python3.7/json/decoder.py:355: JSONDecodeError
_____________________________________________________________________________________________________________________________________________________________ test_invoke_event_function _____________________________________________________________________________________________________________________________________________________________
@pytest.mark.network
@mock_lambda
def test_invoke_event_function():
conn = boto3.client("lambda", _lambda_region)
conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
Role=get_role_name(),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": get_test_zip_file1()},
Description="test lambda function",
Timeout=3,
MemorySize=128,
Publish=True,
)
conn.invoke.when.called_with(
FunctionName="notAFunction", InvocationType="Event", Payload="{}"
).should.throw(botocore.client.ClientError)
in_data = {"msg": "So long and thanks for all the fish"}
success_result = conn.invoke(
FunctionName="testFunction", InvocationType="Event", Payload=json.dumps(in_data)
)
success_result["StatusCode"].should.equal(202)
> json.loads(success_result["Payload"].read().decode("utf-8")).should.equal(in_data)
tests/test_awslambda/test_lambda.py:213:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../miniconda3/envs/moto-py3/lib/python3.7/json/__init__.py:348: in loads
return _default_decoder.decode(s)
../../miniconda3/envs/moto-py3/lib/python3.7/json/decoder.py:337: in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <json.decoder.JSONDecoder object at 0x7fa058e77ed0>, s = 'error running docker: 500 Server Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=docker.io...l rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit")', idx = 0
def raw_decode(self, s, idx=0):
"""Decode a JSON document from ``s`` (a ``str`` beginning with
a JSON document) and return a 2-tuple of the Python
representation and the index in ``s`` where the document ended.
This can be used to decode a JSON document from a string that may
have extraneous data at the end.
"""
try:
obj, end = self.scan_once(s, idx)
except StopIteration as err:
> raise JSONDecodeError("Expecting value", s, err.value) from None
E json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
../../miniconda3/envs/moto-py3/lib/python3.7/json/decoder.py:355: JSONDecodeError
___________________________________________________________________________________________________________________________________________________________ test_invoke_function_from_sns ____________________________________________________________________________________________________________________________________________________________
@pytest.mark.network
@mock_logs
@mock_sns
@mock_ec2
@mock_lambda
def test_invoke_function_from_sns():
logs_conn = boto3.client("logs", region_name=_lambda_region)
sns_conn = boto3.client("sns", region_name=_lambda_region)
sns_conn.create_topic(Name="some-topic")
topics_json = sns_conn.list_topics()
topics = topics_json["Topics"]
topic_arn = topics[0]["TopicArn"]
conn = boto3.client("lambda", _lambda_region)
result = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
Role=get_role_name(),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": get_test_zip_file3()},
Description="test lambda function",
Timeout=3,
MemorySize=128,
Publish=True,
)
sns_conn.subscribe(
TopicArn=topic_arn, Protocol="lambda", Endpoint=result["FunctionArn"]
)
result = sns_conn.publish(TopicArn=topic_arn, Message=json.dumps({}))
start = time.time()
while (time.time() - start) < 30:
result = logs_conn.describe_log_streams(logGroupName="/aws/lambda/testFunction")
log_streams = result.get("logStreams")
if not log_streams:
time.sleep(1)
continue
assert len(log_streams) == 1
result = logs_conn.get_log_events(
logGroupName="/aws/lambda/testFunction",
logStreamName=log_streams[0]["logStreamName"],
)
for event in result.get("events"):
if event["message"] == "get_test_zip_file3 success":
return
time.sleep(1)
> assert False, "Test Failed"
E AssertionError: Test Failed
E assert False
tests/test_awslambda/test_lambda.py:330: AssertionError
___________________________________________________________________________________________________________________________________________________________ test_invoke_function_from_sqs ____________________________________________________________________________________________________________________________________________________________
@pytest.mark.network
@mock_logs
@mock_lambda
@mock_sqs
def test_invoke_function_from_sqs():
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName="test-sqs-queue1")
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
Role=get_role_name(),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": get_test_zip_file3()},
Description="test lambda function",
Timeout=3,
MemorySize=128,
Publish=True,
)
response = conn.create_event_source_mapping(
EventSourceArn=queue.attributes["QueueArn"], FunctionName=func["FunctionArn"]
)
assert response["EventSourceArn"] == queue.attributes["QueueArn"]
assert response["State"] == "Enabled"
sqs_client = boto3.client("sqs", region_name="us-east-1")
sqs_client.send_message(QueueUrl=queue.url, MessageBody="test")
expected_msg = "get_test_zip_file3 success"
log_group = "/aws/lambda/testFunction"
msg_showed_up, all_logs = wait_for_log_msg(expected_msg, log_group)
> assert msg_showed_up, (
expected_msg
+ " was not found after sending an SQS message. All logs: "
+ all_logs
)
E TypeError: can only concatenate str (not "list") to str
tests/test_awslambda/test_lambda.py:1239: TypeError
_______________________________________________________________________________________________________________________________________________________ test_invoke_function_from_dynamodb_put _______________________________________________________________________________________________________________________________________________________
@pytest.mark.network
@mock_logs
@mock_lambda
@mock_dynamodb2
def test_invoke_function_from_dynamodb_put():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
table_name = "table_with_stream"
table = dynamodb.create_table(
TableName=table_name,
KeySchema=[{"AttributeName": "id", "KeyType": "HASH"}],
AttributeDefinitions=[{"AttributeName": "id", "AttributeType": "S"}],
StreamSpecification={
"StreamEnabled": True,
"StreamViewType": "NEW_AND_OLD_IMAGES",
},
)
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
Role=get_role_name(),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": get_test_zip_file3()},
Description="test lambda function executed after a DynamoDB table is updated",
Timeout=3,
MemorySize=128,
Publish=True,
)
response = conn.create_event_source_mapping(
EventSourceArn=table["TableDescription"]["LatestStreamArn"],
FunctionName=func["FunctionArn"],
)
assert response["EventSourceArn"] == table["TableDescription"]["LatestStreamArn"]
assert response["State"] == "Enabled"
dynamodb.put_item(TableName=table_name, Item={"id": {"S": "item 1"}})
expected_msg = "get_test_zip_file3 success"
log_group = "/aws/lambda/testFunction"
msg_showed_up, all_logs = wait_for_log_msg(expected_msg, log_group)
> assert msg_showed_up, (
expected_msg + " was not found after a DDB insert. All logs: " + all_logs
)
E TypeError: can only concatenate str (not "list") to str
tests/test_awslambda/test_lambda.py:1290: TypeError
_____________________________________________________________________________________________________________________________________________________ test_invoke_function_from_dynamodb_update ______________________________________________________________________________________________________________________________________________________
@pytest.mark.network
@mock_logs
@mock_lambda
@mock_dynamodb2
def test_invoke_function_from_dynamodb_update():
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
table_name = "table_with_stream"
table = dynamodb.create_table(
TableName=table_name,
KeySchema=[{"AttributeName": "id", "KeyType": "HASH"}],
AttributeDefinitions=[{"AttributeName": "id", "AttributeType": "S"}],
StreamSpecification={
"StreamEnabled": True,
"StreamViewType": "NEW_AND_OLD_IMAGES",
},
)
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
Role=get_role_name(),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": get_test_zip_file3()},
Description="test lambda function executed after a DynamoDB table is updated",
Timeout=3,
MemorySize=128,
Publish=True,
)
conn.create_event_source_mapping(
EventSourceArn=table["TableDescription"]["LatestStreamArn"],
FunctionName=func["FunctionArn"],
)
dynamodb.put_item(TableName=table_name, Item={"id": {"S": "item 1"}})
log_group = "/aws/lambda/testFunction"
expected_msg = "get_test_zip_file3 success"
msg_showed_up, all_logs = wait_for_log_msg(expected_msg, log_group)
> assert "Nr_of_records(1)" in all_logs, "Only one item should be inserted"
E AssertionError: Only one item should be inserted
E assert 'Nr_of_records(1)' in []
tests/test_awslambda/test_lambda.py:1334: AssertionError
______________________________________________________________________________________________________________________________________________________ test_invoke_function_from_sqs_exception _______________________________________________________________________________________________________________________________________________________
@pytest.mark.network
@mock_logs
@mock_lambda
@mock_sqs
def test_invoke_function_from_sqs_exception():
logs_conn = boto3.client("logs", region_name="us-east-1")
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName="test-sqs-queue1")
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
Role=get_role_name(),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": get_test_zip_file4()},
Description="test lambda function",
Timeout=3,
MemorySize=128,
Publish=True,
)
response = conn.create_event_source_mapping(
EventSourceArn=queue.attributes["QueueArn"], FunctionName=func["FunctionArn"]
)
assert response["EventSourceArn"] == queue.attributes["QueueArn"]
assert response["State"] == "Enabled"
entries = []
for i in range(3):
body = {"uuid": str(uuid.uuid4()), "test": "test_{}".format(i)}
entry = {"Id": str(i), "MessageBody": json.dumps(body)}
entries.append(entry)
queue.send_messages(Entries=entries)
start = time.time()
while (time.time() - start) < 30:
result = logs_conn.describe_log_streams(logGroupName="/aws/lambda/testFunction")
log_streams = result.get("logStreams")
if not log_streams:
time.sleep(1)
continue
assert len(log_streams) >= 1
result = logs_conn.get_log_events(
logGroupName="/aws/lambda/testFunction",
logStreamName=log_streams[0]["logStreamName"],
)
for event in result.get("events"):
if "I failed!" in event["message"]:
messages = queue.receive_messages(MaxNumberOfMessages=10)
# Verify messages are still visible and unprocessed
assert len(messages) == 3
return
time.sleep(1)
> assert False, "Test Failed"
E AssertionError: Test Failed
E assert False
tests/test_awslambda/test_lambda.py:1436: AssertionError
__________________________________________________________________________________________________________________________________________________________________ test_submit_job ___________________________________________________________________________________________________________________________________________________________________
@mock_logs
@mock_ec2
@mock_ecs
@mock_iam
@mock_batch
@pytest.mark.network
def test_submit_job():
ec2_client, iam_client, ecs_client, logs_client, batch_client = _get_clients()
vpc_id, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
compute_name = "test_compute_env"
resp = batch_client.create_compute_environment(
computeEnvironmentName=compute_name,
type="UNMANAGED",
state="ENABLED",
serviceRole=iam_arn,
)
arn = resp["computeEnvironmentArn"]
resp = batch_client.create_job_queue(
jobQueueName="test_job_queue",
state="ENABLED",
priority=123,
computeEnvironmentOrder=[{"order": 123, "computeEnvironment": arn}],
)
queue_arn = resp["jobQueueArn"]
resp = batch_client.register_job_definition(
jobDefinitionName="sayhellotomylittlefriend",
type="container",
containerProperties={
"image": "busybox:latest",
"vcpus": 1,
"memory": 128,
"command": ["echo", "hello"],
},
)
job_def_arn = resp["jobDefinitionArn"]
resp = batch_client.submit_job(
jobName="test1", jobQueue=queue_arn, jobDefinition=job_def_arn
)
job_id = resp["jobId"]
> _wait_for_job_status(batch_client, job_id, "SUCCEEDED")
tests/test_batch/test_batch.py:728:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
client = <botocore.client.Batch object at 0x7fa04ff97d10>, job_id = '089b0873-5a18-4fdf-bc65-c58356907afb', status = 'SUCCEEDED', seconds_to_wait = 30
def _wait_for_job_status(client, job_id, status, seconds_to_wait=30):
wait_time = datetime.datetime.now() + datetime.timedelta(seconds=seconds_to_wait)
last_job_status = None
while datetime.datetime.now() < wait_time:
resp = client.describe_jobs(jobs=[job_id])
last_job_status = resp["jobs"][0]["status"]
if last_job_status == status:
break
else:
raise RuntimeError(
"Time out waiting for job status {status}!\n Last status: {last_status}".format(
> status=status, last_status=last_job_status
)
)
E RuntimeError: Time out waiting for job status SUCCEEDED!
E Last status: FAILED
tests/test_batch/test_batch.py:886: RuntimeError
----------------------------------------------------------------------------------------------------------------------------------------------------------------- Captured log call ------------------------------------------------------------------------------------------------------------------------------------------------------------------
ERROR moto.batch.models:models.py:515 Failed to run AWS Batch container MOTO-BATCH-16eb22a0-51d5-46ba-86c2-91c917d012e5. Error 500 Server Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=docker.io%2Flibrary%2Fbusybox: Internal Server Error ("toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit")
ERROR moto.batch.models:models.py:515 Failed to run AWS Batch container MOTO-BATCH-089b0873-5a18-4fdf-bc65-c58356907afb. Error 500 Server Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=docker.io%2Flibrary%2Fbusybox: Internal Server Error ("toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit")
___________________________________________________________________________________________________________________________________________________________________ test_list_jobs ___________________________________________________________________________________________________________________________________________________________________
@mock_logs
@mock_ec2
@mock_ecs
@mock_iam
@mock_batch
@pytest.mark.network
def test_list_jobs():
ec2_client, iam_client, ecs_client, logs_client, batch_client = _get_clients()
vpc_id, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
compute_name = "test_compute_env"
resp = batch_client.create_compute_environment(
computeEnvironmentName=compute_name,
type="UNMANAGED",
state="ENABLED",
serviceRole=iam_arn,
)
arn = resp["computeEnvironmentArn"]
resp = batch_client.create_job_queue(
jobQueueName="test_job_queue",
state="ENABLED",
priority=123,
computeEnvironmentOrder=[{"order": 123, "computeEnvironment": arn}],
)
queue_arn = resp["jobQueueArn"]
resp = batch_client.register_job_definition(
jobDefinitionName="sleep5",
type="container",
containerProperties={
"image": "busybox:latest",
"vcpus": 1,
"memory": 128,
"command": ["sleep", "5"],
},
)
job_def_arn = resp["jobDefinitionArn"]
resp = batch_client.submit_job(
jobName="test1", jobQueue=queue_arn, jobDefinition=job_def_arn
)
job_id1 = resp["jobId"]
resp = batch_client.submit_job(
jobName="test2", jobQueue=queue_arn, jobDefinition=job_def_arn
)
job_id2 = resp["jobId"]
resp_finished_jobs = batch_client.list_jobs(
jobQueue=queue_arn, jobStatus="SUCCEEDED"
)
# Wait only as long as it takes to run the jobs
for job_id in [job_id1, job_id2]:
> _wait_for_job_status(batch_client, job_id, "SUCCEEDED")
tests/test_batch/test_batch.py:796:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
client = <botocore.client.Batch object at 0x7fa04e726050>, job_id = '12b1849a-7b15-4f4b-b28d-54335c9b3cbd', status = 'SUCCEEDED', seconds_to_wait = 30
def _wait_for_job_status(client, job_id, status, seconds_to_wait=30):
wait_time = datetime.datetime.now() + datetime.timedelta(seconds=seconds_to_wait)
last_job_status = None
while datetime.datetime.now() < wait_time:
resp = client.describe_jobs(jobs=[job_id])
last_job_status = resp["jobs"][0]["status"]
if last_job_status == status:
break
else:
raise RuntimeError(
"Time out waiting for job status {status}!\n Last status: {last_status}".format(
> status=status, last_status=last_job_status
)
)
E RuntimeError: Time out waiting for job status SUCCEEDED!
E Last status: FAILED
tests/test_batch/test_batch.py:886: RuntimeError
----------------------------------------------------------------------------------------------------------------------------------------------------------------- Captured log call ------------------------------------------------------------------------------------------------------------------------------------------------------------------
ERROR moto.batch.models:models.py:515 Failed to run AWS Batch container MOTO-BATCH-12b1849a-7b15-4f4b-b28d-54335c9b3cbd. Error 500 Server Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=docker.io%2Flibrary%2Fbusybox: Internal Server Error ("toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit")
ERROR moto.batch.models:models.py:515 Failed to run AWS Batch container MOTO-BATCH-5d4e977c-1f79-47e0-9e7e-c8b709e46b17. Error 500 Server Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=docker.io%2Flibrary%2Fbusybox: Internal Server Error ("toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit")
_________________________________________________________________________________________________________________________________________________________________ test_terminate_job _________________________________________________________________________________________________________________________________________________________________
@mock_logs
@mock_ec2
@mock_ecs
@mock_iam
@mock_batch
def test_terminate_job():
ec2_client, iam_client, ecs_client, logs_client, batch_client = _get_clients()
vpc_id, subnet_id, sg_id, iam_arn = _setup(ec2_client, iam_client)
compute_name = "test_compute_env"
resp = batch_client.create_compute_environment(
computeEnvironmentName=compute_name,
type="UNMANAGED",
state="ENABLED",
serviceRole=iam_arn,
)
arn = resp["computeEnvironmentArn"]
resp = batch_client.create_job_queue(
jobQueueName="test_job_queue",
state="ENABLED",
priority=123,
computeEnvironmentOrder=[{"order": 123, "computeEnvironment": arn}],
)
queue_arn = resp["jobQueueArn"]
resp = batch_client.register_job_definition(
jobDefinitionName="echo-sleep-echo",
type="container",
containerProperties={
"image": "busybox:latest",
"vcpus": 1,
"memory": 128,
"command": ["sh", "-c", "echo start && sleep 30 && echo stop"],
},
)
job_def_arn = resp["jobDefinitionArn"]
resp = batch_client.submit_job(
jobName="test1", jobQueue=queue_arn, jobDefinition=job_def_arn
)
job_id = resp["jobId"]
> _wait_for_job_status(batch_client, job_id, "RUNNING")
tests/test_batch/test_batch.py:849:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
client = <botocore.client.Batch object at 0x7fa048b5a090>, job_id = 'a99877c0-9519-4cc3-b7b8-30bd932434a5', status = 'RUNNING', seconds_to_wait = 30
def _wait_for_job_status(client, job_id, status, seconds_to_wait=30):
wait_time = datetime.datetime.now() + datetime.timedelta(seconds=seconds_to_wait)
last_job_status = None
while datetime.datetime.now() < wait_time:
resp = client.describe_jobs(jobs=[job_id])
last_job_status = resp["jobs"][0]["status"]
if last_job_status == status:
break
else:
raise RuntimeError(
"Time out waiting for job status {status}!\n Last status: {last_status}".format(
> status=status, last_status=last_job_status
)
)
E RuntimeError: Time out waiting for job status RUNNING!
E Last status: FAILED
tests/test_batch/test_batch.py:886: RuntimeError
----------------------------------------------------------------------------------------------------------------------------------------------------------------- Captured log call ------------------------------------------------------------------------------------------------------------------------------------------------------------------
ERROR moto.batch.models:models.py:515 Failed to run AWS Batch container MOTO-BATCH-a99877c0-9519-4cc3-b7b8-30bd932434a5. Error 500 Server Error for http+docker://localhost/v1.41/images/create?tag=latest&fromImage=docker.io%2Flibrary%2Fbusybox: Internal Server Error ("toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit")
______________________________________________________________________________________________________________________________________________________ test_put_subscription_filter_with_lambda ______________________________________________________________________________________________________________________________________________________
@mock_lambda
@mock_logs
@pytest.mark.network
def test_put_subscription_filter_with_lambda():
# given
region_name = "us-east-1"
client_lambda = boto3.client("lambda", region_name)
client_logs = boto3.client("logs", region_name)
log_group_name = "/test"
log_stream_name = "stream"
client_logs.create_log_group(logGroupName=log_group_name)
client_logs.create_log_stream(
logGroupName=log_group_name, logStreamName=log_stream_name
)
function_arn = client_lambda.create_function(
FunctionName="test",
Runtime="python3.8",
Role=_get_role_name(region_name),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": _get_test_zip_file()},
Description="test lambda function",
Timeout=3,
MemorySize=128,
Publish=True,
)["FunctionArn"]
# when
client_logs.put_subscription_filter(
logGroupName=log_group_name,
filterName="test",
filterPattern="",
destinationArn=function_arn,
)
# then
response = client_logs.describe_subscription_filters(logGroupName=log_group_name)
response["subscriptionFilters"].should.have.length_of(1)
filter = response["subscriptionFilters"][0]
filter["creationTime"].should.be.a(int)
filter["destinationArn"] = "arn:aws:lambda:us-east-1:123456789012:function:test"
filter["distribution"] = "ByLogStream"
filter["logGroupName"] = "/test"
filter["filterName"] = "test"
filter["filterPattern"] = ""
# when
client_logs.put_log_events(
logGroupName=log_group_name,
logStreamName=log_stream_name,
logEvents=[
{"timestamp": 0, "message": "test"},
{"timestamp": 0, "message": "test 2"},
],
)
# then
msg_showed_up, received_message = _wait_for_log_msg(
client_logs, "/aws/lambda/test", "awslogs"
)
> assert msg_showed_up, "CloudWatch log event was not found. All logs: {}".format(
received_message
)
E AssertionError: CloudWatch log event was not found. All logs: []
E assert False
tests/test_logs/test_integration.py:156: AssertionError
_____________________________________________________________________________________________________________________________________________________ test_s3_server_post_without_content_length _____________________________________________________________________________________________________________________________________________________
self = <sure.AssertionBuilder object at 0x7fa0305739d0>, args = (411,), kw = {}
@wraps(func)
def wrapper(self, *args, **kw):
try:
> value = func(self, *args, **kw)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/sure/__init__.py:385:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sure.AssertionBuilder object at 0x7fa0305739d0>, what = 411, epsilon = None
@assertionmethod
def equal(self, what, epsilon=None):
"""compares given object ``X`` with an expected ``Y`` object.
It primarily assures that the compared objects are absolute equal ``==``.
:param what: the expected value
:param epsilon: a delta to leverage upper-bound floating point permissiveness
"""
try:
comparison = DeepComparison(self.obj, what, epsilon).compare()
error = False
except AssertionError as e:
error = e
comparison = None
if isinstance(comparison, DeepExplanation):
error = comparison.get_assertion(self.obj, what)
if self.negative:
if error:
return True
msg = '%s should differ from %s, but is the same thing'
raise AssertionError(msg % (safe_repr(self.obj), safe_repr(what)))
else:
if not error:
return True
> raise error
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/sure/__init__.py:673:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sure.AssertionBuilder object at 0x7fa0305739d0>, what = 411, epsilon = None
@assertionmethod
def equal(self, what, epsilon=None):
"""compares given object ``X`` with an expected ``Y`` object.
It primarily assures that the compared objects are absolute equal ``==``.
:param what: the expected value
:param epsilon: a delta to leverage upper-bound floating point permissiveness
"""
try:
> comparison = DeepComparison(self.obj, what, epsilon).compare()
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/sure/__init__.py:654:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sure.core.DeepComparison object at 0x7fa039ffdb10>
def compare(self):
X, Y = self.operands
if isinstance(X, _CallList):
X = list(X)
if isinstance(Y, _CallList):
X = list(Y)
c = self.get_context()
if self.is_complex(X) and type(X) is type(Y):
return self.compare_complex_stuff(X, Y)
def safe_format_repr(string):
"Escape '{' and '}' in string for use with str.format()"
if not isinstance(string, (string_types, binary_type)):
return string
orig_str_type = type(string)
if isinstance(string, binary_type):
safe_repr = string.replace(b'{', b'{{').replace(b'}', b'}}')
else:
safe_repr = string.replace('{', '{{').replace('}', '}}')
# NOTE: str.replace() automatically converted the 'string' to 'unicode' in Python 2
return orig_str_type(safe_repr)
# get safe representation for X and Y
safe_X, safe_Y = safe_format_repr(X), safe_format_repr(Y)
# maintaining backwards compatability between error messages
kwargs = {}
if self.is_simple(X) and self.is_simple(Y):
kwargs['msg_format'] = 'X{{0}} is {0!r} whereas Y{{1}} is {1!r}'.format(safe_X, safe_Y)
elif type(X) is not type(Y):
kwargs['msg_format'] = 'X{{0}} is a {0} and Y{{1}} is a {1} instead'.format(
type(X).__name__, type(Y).__name__)
exp = self.compare_generic(X, Y, **kwargs)
if isinstance(exp, DeepExplanation):
original_X, original_Y = c.parent.operands
> raise exp.as_assertion(original_X, original_Y)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/sure/core.py:254:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = 'X is 200 whereas Y is 411', X = 200, Y = 411
def as_assertion(self, X, Y):
> raise self.get_assertion(X, Y)
E AssertionError: given
E X = 200
E and
E Y = 411
E X is 200 whereas Y is 411
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/sure/core.py:57: AssertionError
During handling of the above exception, another exception occurred:
def test_s3_server_post_without_content_length():
test_client = authenticated_client()
res = test_client.put(
"/", "http://tester.localhost:5000/", environ_overrides={"CONTENT_LENGTH": ""}
)
> res.status_code.should.equal(411)
tests/test_s3/test_server.py:134:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sure.AssertionBuilder object at 0x7fa0305739d0>, args = (411,), kw = {}
@wraps(func)
def wrapper(self, *args, **kw):
try:
value = func(self, *args, **kw)
except AssertionError as e:
> raise AssertionError(e)
E AssertionError: given
E X = 200
E and
E Y = 411
E X is 200 whereas Y is 411
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/sure/__init__.py:387: AssertionError
________________________________________________________________________________________________________________________________________________________________ test_publish_to_http ________________________________________________________________________________________________________________________________________________________________
@freeze_time("2013-01-01")
@mock_sns
def test_publish_to_http():
def callback(request):
request.headers["Content-Type"].should.equal("text/plain; charset=UTF-8")
json.loads.when.called_with(request.body.decode()).should_not.throw(Exception)
return 200, {}, ""
responses_mock.add_callback(
method="POST", url="http://example.com/foobar", callback=callback
)
conn = boto3.client("sns", region_name="us-east-1")
conn.create_topic(Name="some-topic")
response = conn.list_topics()
topic_arn = response["Topics"][0]["TopicArn"]
conn.subscribe(
TopicArn=topic_arn, Protocol="http", Endpoint="http://example.com/foobar"
)
response = conn.publish(
> TopicArn=topic_arn, Message="my message", Subject="my subject"
)
tests/test_sns/test_publishing_boto3.py:349:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/client.py:357: in _api_call
return self._make_api_call(operation_name, kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/client.py:663: in _make_api_call
operation_model, request_dict, request_context)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/client.py:682: in _make_request
return self._endpoint.make_request(operation_model, request_dict)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/endpoint.py:102: in make_request
return self._send_request(request_dict, operation_model)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/endpoint.py:137: in _send_request
success_response, exception):
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/endpoint.py:256: in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/hooks.py:356: in emit
return self._emitter.emit(aliased_event_name, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/hooks.py:228: in emit
return self._emit(event_name, kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/hooks.py:211: in _emit
response = handler(**kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/retryhandler.py:183: in __call__
if self._checker(attempts, response, caught_exception):
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/retryhandler.py:251: in __call__
caught_exception)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/retryhandler.py:269: in _should_retry
return self._checker(attempt_number, response, caught_exception)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/retryhandler.py:317: in __call__
caught_exception)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/retryhandler.py:223: in __call__
attempt_number, caught_exception)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/retryhandler.py:359: in _check_caught_exception
raise caught_exception
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/endpoint.py:197: in _do_get_response
responses = self._event_emitter.emit(event_name, request=request)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/hooks.py:356: in emit
return self._emitter.emit(aliased_event_name, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/hooks.py:228: in emit
return self._emit(event_name, kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/botocore-1.20.67-py3.7.egg/botocore/hooks.py:211: in _emit
response = handler(**kwargs)
moto/core/models.py:369: in __call__
request, request.url, request.headers
moto/core/responses.py:204: in dispatch
return cls()._dispatch(*args, **kwargs)
moto/core/responses.py:314: in _dispatch
return self.call_action()
moto/core/responses.py:404: in call_action
response = method()
moto/sns/responses.py:353: in publish
message_attributes=message_attributes,
moto/sns/models.py:555: in publish
message, subject=subject, message_attributes=message_attributes
moto/sns/models.py:69: in publish
message_attributes=message_attributes,
moto/sns/models.py:197: in publish
headers={"Content-Type": "text/plain; charset=UTF-8"},
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/api.py:112: in post
return request('post', url, data=data, json=json, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/api.py:58: in request
return session.request(method=method, url=url, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/sessions.py:522: in request
resp = self.send(prep, **send_kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/sessions.py:642: in send
r = adapter.send(request, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/responses-0.13.3-py3.7.egg/responses/__init__.py:765: in unbound_on_send
return self._on_request(adapter, request, *a, **kwargs)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/responses-0.13.3-py3.7.egg/responses/__init__.py:748: in _on_request
response = adapter.build_response(request, match.get_response(request))
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/adapters.py:281: in build_response
extract_cookies_to_jar(response.cookies, req, resp)
../../miniconda3/envs/moto-py3/lib/python3.7/site-packages/requests/cookies.py:133: in extract_cookies_to_jar
jar.extract_cookies(res, req)
../../miniconda3/envs/moto-py3/lib/python3.7/http/cookiejar.py:1679: in extract_cookies
for cookie in self.make_cookies(response, request):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <RequestsCookieJar[]>, response = <requests.cookies.MockResponse object at 0x7fa019b89450>, request = <requests.cookies.MockRequest object at 0x7fa019b89310>
def make_cookies(self, response, request):
"""Return sequence of Cookie objects extracted from response object."""
# get cookie-attributes for RFC 2965 and Netscape protocols
headers = response.info()
> rfc2965_hdrs = headers.get_all("Set-Cookie2", [])
E AttributeError: 'HTTPHeaderDict' object has no attribute 'get_all'
../../miniconda3/envs/moto-py3/lib/python3.7/http/cookiejar.py:1597: AttributeError
______________________________________________________________________________________________________________________________________________________ test_invoke_function_from_sqs_exception _______________________________________________________________________________________________________________________________________________________
@mock_logs
@mock_lambda
@mock_sqs
def test_invoke_function_from_sqs_exception():
logs_conn = boto3.client("logs", region_name="us-east-1")
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName="test-sqs-queue1")
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
Role=get_role_name(),
Handler="lambda_function.lambda_handler",
Code={"ZipFile": get_test_zip_file1()},
Description="test lambda function",
Timeout=3,
MemorySize=128,
Publish=True,
)
response = conn.create_event_source_mapping(
EventSourceArn=queue.attributes["QueueArn"], FunctionName=func["FunctionArn"]
)
assert response["EventSourceArn"] == queue.attributes["QueueArn"]
assert response["State"] == "Enabled"
entries = [
{
"Id": "1",
"MessageBody": json.dumps({"uuid": str(uuid.uuid4()), "test": "test"}),
}
]
queue.send_messages(Entries=entries)
start = time.time()
while (time.time() - start) < 30:
result = logs_conn.describe_log_streams(logGroupName="/aws/lambda/testFunction")
log_streams = result.get("logStreams")
if not log_streams:
time.sleep(1)
continue
assert len(log_streams) >= 1
result = logs_conn.get_log_events(
logGroupName="/aws/lambda/testFunction",
logStreamName=log_streams[0]["logStreamName"],
)
for event in result.get("events"):
if "custom log event" in event["message"]:
return
time.sleep(1)
> assert False, "Test Failed"
E AssertionError: Test Failed
E assert False
tests/test_sqs/test_sqs.py:2571: AssertionError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment