Add get_function_configuration support for Lambda (#3562)
* Add get_function_configuration support for Lambda * remove unnesecary code from test and use _lambda_region when asserting * rename function and skip coping configuration * run black formatting
This commit is contained in:
parent
640df04840
commit
f749f583ee
2 changed files with 88 additions and 4 deletions
|
|
@ -514,6 +514,67 @@ def test_get_function():
|
|||
conn.get_function(FunctionName="junk", Qualifier="$LATEST")
|
||||
|
||||
|
||||
@mock_lambda
|
||||
@mock_s3
|
||||
@freeze_time("2015-01-01 00:00:00")
|
||||
def test_get_function_configuration():
|
||||
s3_conn = boto3.client("s3", _lambda_region)
|
||||
s3_conn.create_bucket(
|
||||
Bucket="test-bucket",
|
||||
CreateBucketConfiguration={"LocationConstraint": _lambda_region},
|
||||
)
|
||||
|
||||
zip_content = get_test_zip_file1()
|
||||
s3_conn.put_object(Bucket="test-bucket", Key="test.zip", Body=zip_content)
|
||||
conn = boto3.client("lambda", _lambda_region)
|
||||
|
||||
conn.create_function(
|
||||
FunctionName="testFunction",
|
||||
Runtime="python2.7",
|
||||
Role=get_role_name(),
|
||||
Handler="lambda_function.lambda_handler",
|
||||
Code={"S3Bucket": "test-bucket", "S3Key": "test.zip"},
|
||||
Description="test lambda function",
|
||||
Timeout=3,
|
||||
MemorySize=128,
|
||||
Publish=True,
|
||||
Environment={"Variables": {"test_variable": "test_value"}},
|
||||
)
|
||||
|
||||
result = conn.get_function_configuration(FunctionName="testFunction")
|
||||
|
||||
result["CodeSha256"].should.equal(hashlib.sha256(zip_content).hexdigest())
|
||||
result["CodeSize"].should.equal(len(zip_content))
|
||||
result["Description"].should.equal("test lambda function")
|
||||
result.should.contain("FunctionArn")
|
||||
result["FunctionName"].should.equal("testFunction")
|
||||
result["Handler"].should.equal("lambda_function.lambda_handler")
|
||||
result["MemorySize"].should.equal(128)
|
||||
result["Role"].should.equal(get_role_name())
|
||||
result["Runtime"].should.equal("python2.7")
|
||||
result["Timeout"].should.equal(3)
|
||||
result["Version"].should.equal("$LATEST")
|
||||
result.should.contain("VpcConfig")
|
||||
result.should.contain("Environment")
|
||||
result["Environment"].should.contain("Variables")
|
||||
result["Environment"]["Variables"].should.equal({"test_variable": "test_value"})
|
||||
|
||||
# Test get function with qualifier
|
||||
result = conn.get_function_configuration(
|
||||
FunctionName="testFunction", Qualifier="$LATEST"
|
||||
)
|
||||
result["Version"].should.equal("$LATEST")
|
||||
result["FunctionArn"].should.equal(
|
||||
"arn:aws:lambda:{}:{}:function:testFunction:$LATEST".format(
|
||||
_lambda_region, ACCOUNT_ID
|
||||
)
|
||||
)
|
||||
|
||||
# Test get function when can't find function name
|
||||
with pytest.raises(conn.exceptions.ResourceNotFoundException):
|
||||
conn.get_function_configuration(FunctionName="junk", Qualifier="$LATEST")
|
||||
|
||||
|
||||
@mock_lambda
|
||||
@mock_s3
|
||||
def test_get_function_by_arn():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue