Applied black formatter

This commit is contained in:
Ian Yon 2019-11-04 12:22:03 -03:00
parent 577419798d
commit 9e2b47e82b
2 changed files with 32 additions and 20 deletions

View File

@ -825,7 +825,9 @@ class LambdaBackend(BaseBackend):
return self._lambdas.publish_function(function_name) return self._lambdas.publish_function(function_name)
def get_function(self, function_name_or_arn, qualifier=None): def get_function(self, function_name_or_arn, qualifier=None):
return self._lambdas.get_function_by_name_or_arn(function_name_or_arn, qualifier) return self._lambdas.get_function_by_name_or_arn(
function_name_or_arn, qualifier
)
def list_versions_by_function(self, function_name): def list_versions_by_function(self, function_name):
return self._lambdas.list_versions_by_function(function_name) return self._lambdas.list_versions_by_function(function_name)

View File

@ -388,7 +388,7 @@ def test_get_function():
Timeout=3, Timeout=3,
MemorySize=128, MemorySize=128,
Publish=True, Publish=True,
Environment={"Variables": {"test_variable": "test_value"}} Environment={"Variables": {"test_variable": "test_value"}},
) )
result = conn.get_function(FunctionName="testFunction") result = conn.get_function(FunctionName="testFunction")
@ -417,9 +417,11 @@ def test_get_function():
result["Configuration"]["Timeout"].should.equal(3) result["Configuration"]["Timeout"].should.equal(3)
result["Configuration"]["Version"].should.equal("$LATEST") result["Configuration"]["Version"].should.equal("$LATEST")
result["Configuration"].should.contain("VpcConfig") result["Configuration"].should.contain("VpcConfig")
result['Configuration'].should.contain('Environment') result["Configuration"].should.contain("Environment")
result['Configuration']['Environment'].should.contain('Variables') result["Configuration"]["Environment"].should.contain("Variables")
result['Configuration']['Environment']["Variables"].should.equal({"test_variable": "test_value"}) result["Configuration"]["Environment"]["Variables"].should.equal(
{"test_variable": "test_value"}
)
# Test get function with # Test get function with
result = conn.get_function(FunctionName="testFunction", Qualifier="$LATEST") result = conn.get_function(FunctionName="testFunction", Qualifier="$LATEST")
@ -432,26 +434,32 @@ def test_get_function():
with assert_raises(ClientError): with assert_raises(ClientError):
conn.get_function(FunctionName="junk", Qualifier="$LATEST") conn.get_function(FunctionName="junk", Qualifier="$LATEST")
@mock_lambda @mock_lambda
@mock_s3 @mock_s3
def test_get_function_by_arn(): def test_get_function_by_arn():
bucket_name = 'test-bucket' bucket_name = "test-bucket"
s3_conn = boto3.client('s3', 'us-east-1') s3_conn = boto3.client("s3", "us-east-1")
s3_conn.create_bucket(Bucket=bucket_name) s3_conn.create_bucket(Bucket=bucket_name)
zip_content = get_test_zip_file2() zip_content = get_test_zip_file2()
s3_conn.put_object(Bucket=bucket_name, Key='test.zip', Body=zip_content) s3_conn.put_object(Bucket=bucket_name, Key="test.zip", Body=zip_content)
conn = boto3.client('lambda', 'us-east-1') conn = boto3.client("lambda", "us-east-1")
fnc = conn.create_function(FunctionName='testFunction', fnc = conn.create_function(
Runtime='python2.7', Role='test-iam-role', FunctionName="testFunction",
Handler='lambda_function.lambda_handler', Runtime="python2.7",
Code={'S3Bucket': bucket_name, 'S3Key': 'test.zip'}, Role="test-iam-role",
Description='test lambda function', Handler="lambda_function.lambda_handler",
Timeout=3, MemorySize=128, Publish=True) Code={"S3Bucket": bucket_name, "S3Key": "test.zip"},
Description="test lambda function",
Timeout=3,
MemorySize=128,
Publish=True,
)
result = conn.get_function(FunctionName=fnc['FunctionArn']) result = conn.get_function(FunctionName=fnc["FunctionArn"])
result['Configuration']['FunctionName'].should.equal('testFunction') result["Configuration"]["FunctionName"].should.equal("testFunction")
@mock_lambda @mock_lambda
@ -1347,7 +1355,7 @@ def test_update_configuration():
Timeout=3, Timeout=3,
MemorySize=128, MemorySize=128,
Publish=True, Publish=True,
Environment={'Variables': {"test_old_environment": "test_old_value"}} Environment={"Variables": {"test_old_environment": "test_old_value"}},
) )
assert fxn["Description"] == "test lambda function" assert fxn["Description"] == "test lambda function"
@ -1362,7 +1370,7 @@ def test_update_configuration():
Handler="lambda_function.new_lambda_handler", Handler="lambda_function.new_lambda_handler",
Runtime="python3.6", Runtime="python3.6",
Timeout=7, Timeout=7,
Environment={"Variables": {"test_environment": "test_value"}} Environment={"Variables": {"test_environment": "test_value"}},
) )
assert updated_config["ResponseMetadata"]["HTTPStatusCode"] == 200 assert updated_config["ResponseMetadata"]["HTTPStatusCode"] == 200
@ -1371,7 +1379,9 @@ def test_update_configuration():
assert updated_config["MemorySize"] == 128 assert updated_config["MemorySize"] == 128
assert updated_config["Runtime"] == "python3.6" assert updated_config["Runtime"] == "python3.6"
assert updated_config["Timeout"] == 7 assert updated_config["Timeout"] == 7
assert updated_config["Environment"]["Variables"] == {"test_environment": "test_value"} assert updated_config["Environment"]["Variables"] == {
"test_environment": "test_value"
}
@mock_lambda @mock_lambda