Exemple #1
0
    def test_invoke_lambda_function(self):

        hook = AwsLambdaHook(aws_conn_id='aws_default',
                             function_name="test_function",
                             region_name="us-east-1")

        hook.get_conn().create_function(
            FunctionName='test_function',
            Runtime='python2.7',
            Role='test-iam-role',
            Handler='lambda_function.lambda_handler',
            Code={
                'ZipFile': self.lambda_function(),
            },
            Description='test lambda function',
            Timeout=3,
            MemorySize=128,
            Publish=True,
        )

        payload = {'hello': 'airflow'}
        response = hook.invoke_lambda(payload=json.dumps(payload))

        self.assertEqual(response["StatusCode"], 202)
Exemple #2
0
 def test_get_conn_returns_a_boto3_connection(self):
     hook = AwsLambdaHook(aws_conn_id='aws_default',
                          function_name="test_function",
                          region_name="us-east-1")
     self.assertIsNotNone(hook.get_conn())