Exemplo n.º 1
0
 def test_that_when_updating_function_code_without_code_raises_a_salt_invocation_error(self):
     """
     tests Creating a function without code
     """
     with patch.dict(boto_lambda.__salt__, {"boto_iam.get_account_id": MagicMock(return_value="1234")}):
         with self.assertRaisesRegexp(
             SaltInvocationError, "Either ZipFile must be specified, or S3Bucket and S3Key must be provided."
         ):
             result = boto_lambda.update_function_code(FunctionName="testfunction", **conn_parameters)
Exemplo n.º 2
0
 def test_that_when_updating_function_code_without_code_raises_a_salt_invocation_error(self):
     '''
     tests Creating a function without code
     '''
     with patch.dict(boto_lambda.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
         with self.assertRaisesRegexp(SaltInvocationError,
                                  'Either ZipFile must be specified, or S3Bucket and S3Key must be provided.'):
             result = boto_lambda.update_function_code(FunctionName='testfunction',
                                                 **conn_parameters)
Exemplo n.º 3
0
    def test_that_when_updating_function_code_from_zipfile_succeeds_the_update_function_method_returns_true(self):
        '''
        tests True function updated.
        '''
        with patch.dict(boto_lambda.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
            with TempZipFile() as zipfile:
                self.conn.update_function_code.return_value = function_ret
                result = boto_lambda.update_function_code(FunctionName=function_ret['FunctionName'], ZipFile=zipfile, **conn_parameters)

        self.assertTrue(result['updated'])
Exemplo n.º 4
0
 def test_that_when_updating_function_code_fails_the_update_function_method_returns_error(self):
     """
     tests False function not updated.
     """
     with patch.dict(boto_lambda.__salt__, {"boto_iam.get_account_id": MagicMock(return_value="1234")}):
         self.conn.update_function_code.side_effect = ClientError(error_content, "update_function_code")
         result = boto_lambda.update_function_code(
             FunctionName="testfunction", S3Bucket="bucket", S3Key="key", **conn_parameters
         )
     self.assertEqual(result.get("error", {}).get("message"), error_message.format("update_function_code"))
Exemplo n.º 5
0
    def test_that_when_updating_function_code_from_zipfile_succeeds_the_update_function_method_returns_true(self):
        '''
        tests True function updated.
        '''
        with patch.dict(boto_lambda.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
            with TempZipFile() as zipfile:
                self.conn.update_function_code.return_value = function_ret
                result = boto_lambda.update_function_code(FunctionName=function_ret['FunctionName'], ZipFile=zipfile, **conn_parameters)

        self.assertTrue(result['updated'])
Exemplo n.º 6
0
 def test_that_when_updating_function_code_fails_the_update_function_method_returns_error(self):
     '''
     tests False function not updated.
     '''
     with patch.dict(boto_lambda.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
         self.conn.update_function_code.side_effect = ClientError(error_content, 'update_function_code')
         result = boto_lambda.update_function_code(FunctionName='testfunction',
                                                 S3Bucket='bucket',
                                                 S3Key='key',
                                                 **conn_parameters)
     self.assertEqual(result.get('error', {}).get('message'), error_message.format('update_function_code'))
Exemplo n.º 7
0
    def test_that_when_updating_function_code_from_s3_succeeds_the_update_function_method_returns_true(self):
        """
        tests True function updated.
        """
        with patch.dict(boto_lambda.__salt__, {"boto_iam.get_account_id": MagicMock(return_value="1234")}):
            self.conn.update_function_code.return_value = function_ret
            result = boto_lambda.update_function_code(
                FunctionName="testfunction", S3Bucket="bucket", S3Key="key", **conn_parameters
            )

        self.assertTrue(result["updated"])
Exemplo n.º 8
0
 def test_that_when_updating_function_code_fails_the_update_function_method_returns_error(self):
     '''
     tests False function not updated.
     '''
     with patch.dict(boto_lambda.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
         self.conn.update_function_code.side_effect = ClientError(error_content, 'update_function_code')
         result = boto_lambda.update_function_code(FunctionName='testfunction',
                                                 S3Bucket='bucket',
                                                 S3Key='key',
                                                 **conn_parameters)
     self.assertEqual(result.get('error', {}).get('message'), error_message.format('update_function_code'))
Exemplo n.º 9
0
    def test_that_when_updating_function_code_from_s3_succeeds_the_update_function_method_returns_true(self):
        '''
        tests True function updated.
        '''
        with patch.dict(boto_lambda.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
            self.conn.update_function_code.return_value = function_ret
            result = boto_lambda.update_function_code(FunctionName='testfunction',
                                                    S3Bucket='bucket',
                                                    S3Key='key',
                                                    **conn_parameters)

        self.assertTrue(result['updated'])
Exemplo n.º 10
0
    def test_that_when_updating_function_code_from_s3_succeeds_the_update_function_method_returns_true(self):
        '''
        tests True function updated.
        '''
        with patch.dict(boto_lambda.__salt__, {'boto_iam.get_account_id': MagicMock(return_value='1234')}):
            self.conn.update_function_code.return_value = function_ret
            result = boto_lambda.update_function_code(FunctionName='testfunction',
                                                    S3Bucket='bucket',
                                                    S3Key='key',
                                                    **conn_parameters)

        self.assertTrue(result['updated'])
Exemplo n.º 11
0
 def test_that_when_updating_function_code_without_code_raises_a_salt_invocation_error(
     self, ):
     """
     tests Creating a function without code
     """
     with patch.dict(
             boto_lambda.__salt__,
         {"boto_iam.get_account_id": MagicMock(return_value="1234")},
     ):
         with self.assertRaisesRegex(
                 SaltInvocationError,
             ("Either ZipFile must be specified, or S3Bucket "
              "and S3Key must be provided."),
         ):
             result = boto_lambda.update_function_code(
                 FunctionName="testfunction", **conn_parameters)
Exemplo n.º 12
0
    def test_that_when_updating_function_code_from_s3_succeeds_the_update_function_method_returns_true(
        self,
    ):
        """
        tests True function updated.
        """
        with patch.dict(
            boto_lambda.__salt__,
            {"boto_iam.get_account_id": MagicMock(return_value="1234")},
        ):
            self.conn.update_function_code.return_value = function_ret
            result = boto_lambda.update_function_code(
                FunctionName="testfunction", S3Bucket="bucket", S3Key="key", **conn_parameters
            )

        assert result["updated"]
Exemplo n.º 13
0
    def test_that_when_updating_function_code_from_zipfile_succeeds_the_update_function_method_returns_true(
        self, ):
        """
        tests True function updated.
        """
        with patch.dict(
                boto_lambda.__salt__,
            {"boto_iam.get_account_id": MagicMock(return_value="1234")},
        ):
            with TempZipFile() as zipfile:
                self.conn.update_function_code.return_value = function_ret
                result = boto_lambda.update_function_code(
                    FunctionName=function_ret["FunctionName"],
                    ZipFile=zipfile,
                    **conn_parameters)

        self.assertTrue(result["updated"])
Exemplo n.º 14
0
 def test_that_when_updating_function_code_fails_the_update_function_method_returns_error(
     self,
 ):
     """
     tests False function not updated.
     """
     with patch.dict(
         boto_lambda.__salt__,
         {"boto_iam.get_account_id": MagicMock(return_value="1234")},
     ):
         self.conn.update_function_code.side_effect = ClientError(
             error_content, "update_function_code"
         )
         result = boto_lambda.update_function_code(
             FunctionName="testfunction", S3Bucket="bucket", S3Key="key", **conn_parameters
         )
     assert result.get("error", {}).get("message") == error_message.format(
         "update_function_code"
     )