Skip to content

Commit

Permalink
Merge 38ce4d5 into 542c8c6
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Whitestone committed Jan 1, 2021
2 parents 542c8c6 + 38ce4d5 commit 8f3d03a
Show file tree
Hide file tree
Showing 10 changed files with 354 additions and 221 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@ README.test.md

.mypy_cache
.pytest_cache
pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"Version": "$LATEST",
"Environment": {
"Variables": {}
}
},
"PackageType": "Zip"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"Timeout": 30,
"LastModified": "2016-06-02T19:24:32.878+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "1",
Expand All @@ -32,7 +33,8 @@
"Timeout": 30,
"LastModified": "2016-06-02T19:23:48.902+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "2",
Expand All @@ -46,7 +48,8 @@
"Timeout": 30,
"LastModified": "2016-06-02T19:24:32.878+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"Timeout": 30,
"LastModified": "2016-08-25T03:31:23.343+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"Package": "Zip"
},
{
"Version": "4",
Expand All @@ -39,7 +40,8 @@
"Timeout": 30,
"LastModified": "2016-08-25T03:29:40.612+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"Package": "Zip"
},
{
"Version": "5",
Expand All @@ -53,7 +55,8 @@
"Timeout": 30,
"LastModified": "2016-08-25T03:31:18.572+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"Package": "Zip"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"Timeout": 30,
"LastModified": "2016-03-01T00:55:35.845+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "1",
Expand All @@ -32,7 +33,8 @@
"Timeout": 30,
"LastModified": "2016-02-29T14:39:31.557+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "2",
Expand All @@ -46,7 +48,8 @@
"Timeout": 30,
"LastModified": "2016-02-29T14:47:04.499+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "3",
Expand All @@ -60,7 +63,8 @@
"Timeout": 30,
"LastModified": "2016-02-29T14:58:08.443+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "4",
Expand All @@ -74,7 +78,8 @@
"Timeout": 30,
"LastModified": "2016-02-29T16:25:49.425+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "5",
Expand All @@ -88,7 +93,8 @@
"Timeout": 30,
"LastModified": "2016-02-29T16:34:47.988+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "6",
Expand All @@ -102,7 +108,8 @@
"Timeout": 30,
"LastModified": "2016-03-01T00:12:28.708+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "7",
Expand All @@ -116,7 +123,8 @@
"Timeout": 30,
"LastModified": "2016-03-01T00:24:01.446+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "8",
Expand All @@ -130,7 +138,8 @@
"Timeout": 30,
"LastModified": "2016-03-01T00:55:35.845+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"Timeout": 30,
"LastModified": "2016-03-01T00:55:35.845+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "1",
Expand All @@ -32,7 +33,8 @@
"Timeout": 30,
"LastModified": "2016-02-29T14:39:31.557+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "2",
Expand All @@ -46,7 +48,8 @@
"Timeout": 30,
"LastModified": "2016-02-29T14:47:04.499+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "3",
Expand All @@ -60,7 +63,8 @@
"Timeout": 30,
"LastModified": "2016-02-29T14:58:08.443+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "4",
Expand All @@ -74,7 +78,8 @@
"Timeout": 30,
"LastModified": "2016-02-29T16:25:49.425+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "5",
Expand All @@ -88,7 +93,8 @@
"Timeout": 30,
"LastModified": "2016-02-29T16:34:47.988+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "6",
Expand All @@ -102,7 +108,8 @@
"Timeout": 30,
"LastModified": "2016-03-01T00:12:28.708+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "7",
Expand All @@ -116,7 +123,8 @@
"Timeout": 30,
"LastModified": "2016-03-01T00:24:01.446+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
},
{
"Version": "8",
Expand All @@ -130,7 +138,8 @@
"Timeout": 30,
"LastModified": "2016-03-01T00:55:35.845+0000",
"Runtime": "python2.7",
"Description": "Zappa Deployment"
"Description": "Zappa Deployment",
"PackageType": "Zip"
}
]
}
Expand Down
15 changes: 10 additions & 5 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,20 @@ def test_update_aws_env_vars(self):

with mock.patch.object(z, "lambda_client") as mock_client:
# Simulate already having some AWS env vars remotely
mock_client.get_function_configuration.return_value = {"Environment": {"Variables": {"REMOTE_ONLY": "AAA", "CHANGED_REMOTE" : "BBB"}}}
mock_client.get_function_configuration.return_value = {
"PackageType": "Zip",
"Environment": {"Variables": {"REMOTE_ONLY": "AAA", "CHANGED_REMOTE" : "BBB"}}
}
z.update_lambda_configuration("test", "test", "test", aws_environment_variables={"CHANGED_REMOTE" : "ZZ", "LOCAL_ONLY" : "YY"})
end_result_should_be = {"REMOTE_ONLY": "AAA", "CHANGED_REMOTE" : "ZZ", "LOCAL_ONLY" : "YY"}
self.assertEqual(mock_client.update_function_configuration.call_args[1]["Environment"], { "Variables": end_result_should_be})

with mock.patch.object(z, "lambda_client") as mock_client:
# Simulate already having some AWS env vars remotely but none set in aws_environment_variables
mock_client.get_function_configuration.return_value = {
"Environment": {"Variables": {"REMOTE_ONLY_1": "AAA", "REMOTE_ONLY_2": "BBB"}}}
"PackageType": "Zip",
"Environment": {"Variables": {"REMOTE_ONLY_1": "AAA", "REMOTE_ONLY_2": "BBB"}}
}
z.update_lambda_configuration("test", "test", "test")
end_result_should_be = {"REMOTE_ONLY_1": "AAA", "REMOTE_ONLY_2": "BBB"}
self.assertEqual(mock_client.update_function_configuration.call_args[1]["Environment"],
Expand All @@ -386,11 +391,11 @@ def test_update_layers(self):
z.credentials_arn = object()

with mock.patch.object(z, "lambda_client") as mock_client:
mock_client.get_function_configuration.return_value = {}
mock_client.get_function_configuration.return_value = {"PackageType": "Zip"}
z.update_lambda_configuration("test", "test", "test", layers=["Layer1", "Layer2"])
self.assertEqual(mock_client.update_function_configuration.call_args[1]["Layers"], ["Layer1", "Layer2"])
with mock.patch.object(z, "lambda_client") as mock_client:
mock_client.get_function_configuration.return_value = {}
mock_client.get_function_configuration.return_value = {"PackageType": "Zip"}
z.update_lambda_configuration("test", "test", "test")
self.assertEqual(mock_client.update_function_configuration.call_args[1]["Layers"], [])

Expand All @@ -401,7 +406,7 @@ def test_update_empty_aws_env_hash(self):

with mock.patch.object(z, "lambda_client") as mock_client:
# Simulate having no AWS env vars remotely
mock_client.get_function_configuration.return_value = {}
mock_client.get_function_configuration.return_value = {"PackageType": "Zip"}
z.update_lambda_configuration("test", "test", "test", aws_environment_variables={"LOCAL_ONLY" : "LZ", "SHOW_AND_TELL" : "SHA"})
end_result_should_be = {"LOCAL_ONLY" : "LZ", "SHOW_AND_TELL" : "SHA"}
self.assertEqual(mock_client.update_function_configuration.call_args[1]["Environment"], { "Variables": end_result_should_be})
Expand Down

0 comments on commit 8f3d03a

Please sign in to comment.