def test_lambda_list_exposes_boto3_list_api(self, monkeypatch): task = LambdaList() client = MagicMock() boto3 = MagicMock(client=client) monkeypatch.setattr("prefect.utilities.aws.boto3", boto3) task.run() called_method = client.mock_calls[1] assert called_method[0] == "().list_functions" called_method.assert_called_once_with({"FunctionName": "test"})
def test_lambda_list_exposes_boto3_list_api(self, monkeypatch): task = LambdaList() client = MagicMock() boto3 = MagicMock(client=client) monkeypatch.setattr("prefect.utilities.aws.boto3", boto3) task.run() client().list_functions.assert_called_once_with( MasterRegion="ALL", FunctionVersion="ALL", MaxItems=50, )
def test_creds_are_pulled_from_secret(self, monkeypatch): task = LambdaList() client = MagicMock() boto3 = MagicMock(client=client) monkeypatch.setattr("prefect.tasks.aws.lambda_function.boto3", boto3) with set_temporary_config({"cloud.use_local_secrets": True}): with prefect.context(secrets=dict(AWS_CREDENTIALS={ "ACCESS_KEY": "42", "SECRET_ACCESS_KEY": "99" })): task.run() kwargs = client.call_args[1] assert kwargs == { "aws_access_key_id": "42", "aws_secret_access_key": "99" }
def test_initialization(self): task = LambdaList()
def test_initialization(self): task = LambdaList() assert task.aws_credentials_secret == "AWS_CREDENTIALS"