Merge branch 'master' into feature/2546

This commit is contained in:
Bert Blommers 2019-11-22 06:22:54 +00:00
commit 5f6e8fd6fe
18 changed files with 62 additions and 57 deletions

View file

@ -563,7 +563,7 @@ def test_create_stage():
api_id = response["id"]
create_method_integration(client, api_id)
response = client.create_deployment(restApiId=api_id, stageName=stage_name,)
response = client.create_deployment(restApiId=api_id, stageName=stage_name)
deployment_id = response["id"]
response = client.get_deployment(restApiId=api_id, deploymentId=deployment_id)

View file

@ -1003,10 +1003,10 @@ def test_list_versions_by_function_for_nonexistent_function():
@mock_lambda
@mock_sqs
def test_create_event_source_mapping():
sqs = boto3.resource("sqs")
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName="test-sqs-queue1")
conn = boto3.client("lambda")
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
@ -1032,11 +1032,11 @@ def test_create_event_source_mapping():
@mock_lambda
@mock_sqs
def test_invoke_function_from_sqs():
logs_conn = boto3.client("logs")
sqs = boto3.resource("sqs")
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")
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
@ -1056,7 +1056,7 @@ def test_invoke_function_from_sqs():
assert response["EventSourceArn"] == queue.attributes["QueueArn"]
assert response["State"] == "Enabled"
sqs_client = boto3.client("sqs")
sqs_client = boto3.client("sqs", region_name="us-east-1")
sqs_client.send_message(QueueUrl=queue.url, MessageBody="test")
start = time.time()
while (time.time() - start) < 30:
@ -1083,8 +1083,8 @@ def test_invoke_function_from_sqs():
@mock_lambda
@mock_dynamodb2
def test_invoke_function_from_dynamodb():
logs_conn = boto3.client("logs")
dynamodb = boto3.client("dynamodb")
logs_conn = boto3.client("logs", region_name="us-east-1")
dynamodb = boto3.client("dynamodb", region_name="us-east-1")
table_name = "table_with_stream"
table = dynamodb.create_table(
TableName=table_name,
@ -1096,7 +1096,7 @@ def test_invoke_function_from_dynamodb():
},
)
conn = boto3.client("lambda")
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
@ -1143,11 +1143,11 @@ def test_invoke_function_from_dynamodb():
@mock_lambda
@mock_sqs
def test_invoke_function_from_sqs_exception():
logs_conn = boto3.client("logs")
sqs = boto3.resource("sqs")
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")
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
@ -1203,10 +1203,10 @@ def test_invoke_function_from_sqs_exception():
@mock_lambda
@mock_sqs
def test_list_event_source_mappings():
sqs = boto3.resource("sqs")
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName="test-sqs-queue1")
conn = boto3.client("lambda")
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
@ -1235,10 +1235,10 @@ def test_list_event_source_mappings():
@mock_lambda
@mock_sqs
def test_get_event_source_mapping():
sqs = boto3.resource("sqs")
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName="test-sqs-queue1")
conn = boto3.client("lambda")
conn = boto3.client("lambda", region_name="us-east-1")
func = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
@ -1265,10 +1265,10 @@ def test_get_event_source_mapping():
@mock_lambda
@mock_sqs
def test_update_event_source_mapping():
sqs = boto3.resource("sqs")
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName="test-sqs-queue1")
conn = boto3.client("lambda")
conn = boto3.client("lambda", region_name="us-east-1")
func1 = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",
@ -1309,10 +1309,10 @@ def test_update_event_source_mapping():
@mock_lambda
@mock_sqs
def test_delete_event_source_mapping():
sqs = boto3.resource("sqs")
sqs = boto3.resource("sqs", region_name="us-east-1")
queue = sqs.create_queue(QueueName="test-sqs-queue1")
conn = boto3.client("lambda")
conn = boto3.client("lambda", region_name="us-east-1")
func1 = conn.create_function(
FunctionName="testFunction",
Runtime="python2.7",

View file

@ -3119,8 +3119,8 @@ def test_sorted_query_with_numerical_sort_key():
# https://github.com/spulec/moto/issues/1874
@mock_dynamodb2
def test_item_size_is_under_400KB():
dynamodb = boto3.resource("dynamodb")
client = boto3.client("dynamodb")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
client = boto3.client("dynamodb", region_name="us-east-1")
dynamodb.create_table(
TableName="moto-test",
@ -3172,7 +3172,7 @@ def assert_failure_due_to_item_size(func, **kwargs):
@mock_dynamodb2
# https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Query.html#DDB-Query-request-KeyConditionExpression
def test_hash_key_cannot_use_begins_with_operations():
dynamodb = boto3.resource("dynamodb")
dynamodb = boto3.resource("dynamodb", region_name="us-east-1")
table = dynamodb.create_table(
TableName="test-table",
KeySchema=[{"AttributeName": "key", "KeyType": "HASH"}],
@ -3201,7 +3201,7 @@ def test_hash_key_cannot_use_begins_with_operations():
@mock_dynamodb2
def test_update_supports_complex_expression_attribute_values():
client = boto3.client("dynamodb")
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
AttributeDefinitions=[{"AttributeName": "SHA256", "AttributeType": "S"}],
@ -3237,7 +3237,7 @@ def test_update_supports_complex_expression_attribute_values():
@mock_dynamodb2
def test_update_supports_list_append():
client = boto3.client("dynamodb")
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
AttributeDefinitions=[{"AttributeName": "SHA256", "AttributeType": "S"}],
@ -3272,7 +3272,7 @@ def test_update_supports_list_append():
@mock_dynamodb2
def test_update_catches_invalid_list_append_operation():
client = boto3.client("dynamodb")
client = boto3.client("dynamodb", region_name="us-east-1")
client.create_table(
AttributeDefinitions=[{"AttributeName": "SHA256", "AttributeType": "S"}],
@ -3335,7 +3335,7 @@ def test_update_item_if_original_value_is_none():
table.update_item(
Key={"job_id": "a"},
UpdateExpression="SET job_name = :output",
ExpressionAttributeValues={":output": "updated",},
ExpressionAttributeValues={":output": "updated"},
)
table.scan()["Items"][0]["job_name"].should.equal("updated")
@ -3354,7 +3354,7 @@ def test_update_nested_item_if_original_value_is_none():
table.update_item(
Key={"job_id": "a"},
UpdateExpression="SET job_details.job_name = :output",
ExpressionAttributeValues={":output": "updated",},
ExpressionAttributeValues={":output": "updated"},
)
table.scan()["Items"][0]["job_details"]["job_name"].should.equal("updated")

View file

@ -213,7 +213,7 @@ class TestEdges:
resp = conn.update_table(
TableName="test-streams",
StreamSpecification={"StreamViewType": "KEYS_ONLY"},
StreamSpecification={"StreamViewType": "KEYS_ONLY", "StreamEnabled": True},
)
assert "StreamSpecification" in resp["TableDescription"]
assert resp["TableDescription"]["StreamSpecification"] == {
@ -226,7 +226,10 @@ class TestEdges:
with assert_raises(conn.exceptions.ResourceInUseException):
resp = conn.update_table(
TableName="test-streams",
StreamSpecification={"StreamViewType": "OLD_IMAGES"},
StreamSpecification={
"StreamViewType": "OLD_IMAGES",
"StreamEnabled": True,
},
)
def test_stream_with_range_key(self):
@ -243,7 +246,7 @@ class TestEdges:
{"AttributeName": "color", "AttributeType": "S"},
],
ProvisionedThroughput={"ReadCapacityUnits": 1, "WriteCapacityUnits": 1},
StreamSpecification={"StreamViewType": "NEW_IMAGES"},
StreamSpecification={"StreamViewType": "NEW_IMAGES", "StreamEnabled": True},
)
stream_arn = resp["TableDescription"]["LatestStreamArn"]

View file

@ -1924,7 +1924,9 @@ def test_attributes():
)
attrs = resp["attributes"]
NUM_CUSTOM_ATTRIBUTES = 4 # 2 specific to individual machines and 1 global, going to both machines (2 + 1*2)
NUM_CUSTOM_ATTRIBUTES = (
4
) # 2 specific to individual machines and 1 global, going to both machines (2 + 1*2)
NUM_DEFAULT_ATTRIBUTES = 4
len(attrs).should.equal(
NUM_CUSTOM_ATTRIBUTES + (NUM_DEFAULT_ATTRIBUTES * len(instances))

View file

@ -2526,9 +2526,7 @@ def test_get_account_summary():
)
client.create_instance_profile(InstanceProfileName="test-profile")
client.create_open_id_connect_provider(
Url="https://example.com", ThumbprintList=[],
)
client.create_open_id_connect_provider(Url="https://example.com", ThumbprintList=[])
response_policy = client.create_policy(
PolicyName="test-policy", PolicyDocument=MOCK_POLICY
)

View file

@ -524,7 +524,7 @@ def _get_account_id():
global account_id
if account_id:
return account_id
sts = boto3.client("sts")
sts = boto3.client("sts", region_name=region)
identity = sts.get_caller_identity()
account_id = identity["Account"]
return account_id