def test_get_cognito_user_info_by_user_name_error_connect_cognito(self):
        # create boto3 client error
        mock_common_utils.set_error_response("500", "ERROR")
        self.create_mock_boto3_client_error()

        # call function test
        with self.assertRaises(PmError) as exception:
            aws_common.get_cognito_user_info_by_user_name(trace_id, user_name)

        # check error
        cause_error = exception.exception.cause_error.response['Error']
        self.assertEqual(cause_error['Code'],
                         mock_common_utils.get_error_code())
        self.assertEqual(cause_error['Message'],
                         mock_common_utils.get_error_message())
    def test_get_cognitor_user_pool_error_connect_cognito(self):
        attributesToGet = "email"

        # create boto3 client error
        mock_common_utils.set_error_response("500", "ERROR")
        self.create_mock_boto3_client_error()

        # call function test
        with self.assertRaises(PmError) as exception:
            aws_common.get_cognito_user_pools(trace_id, filter,
                                              attributesToGet)

        # check error
        cause_error = exception.exception.cause_error.response['Error']
        self.assertEqual(cause_error['Code'],
                         mock_common_utils.get_error_code())
        self.assertEqual(cause_error['Message'],
                         mock_common_utils.get_error_message())
    def test_process_admin_create_user_pools_error_connect_cognito(self):
        error_code = mock_common_utils.get_error_code()
        error_message = mock_common_utils.get_error_message()
        # create boto3 client error
        mock_common_utils.set_error_response(error_code, error_message)
        self.create_mock_boto3_client_error()

        # call function test
        with self.assertRaises(PmError) as exception:
            aws_common.process_admin_create_user_pools(trace_id, user_name,
                                                       user_attributes,
                                                       temporary_password,
                                                       message_action)

        # check error
        cause_error = exception.exception.cause_error.response['Error']
        self.assertEqual(cause_error['Code'], error_code)
        self.assertEqual(cause_error['Message'], error_message)
    def test_update_cognito_user_attributes_error_connect_cognito(self):
        trace_id = copy.deepcopy(DataTestCognitoIdp.TRACE_ID)
        user_name = "test_user"
        user_attributes = copy.deepcopy(
            DataTestCognitoIdp.USER_ATTRIBUTES_UPDATE)

        # create boto3 client error
        mock_common_utils.set_error_response("500", "ERROR")
        self.create_mock_boto3_client_error()

        # call function test
        with self.assertRaises(PmError) as exception:
            aws_common.update_cognito_user_attributes(trace_id, user_name,
                                                      user_attributes)

        # check error
        cause_error = exception.exception.cause_error.response['Error']
        self.assertEqual(cause_error['Code'],
                         mock_common_utils.get_error_code())
        self.assertEqual(cause_error['Message'],
                         mock_common_utils.get_error_message())
    def test_send_email_error_client_connect_ses(self):
        trace_id = DataTestSes.TRACE_ID
        region_name = DataTestSes.REGIONS
        sender = DataTestSes.SENDER
        subject = DataTestSes.SUBJECT
        bcc = DataTestSes.BCC
        body = DataTestSes.BODY
        self.create_mock_boto3_client_error()
        mock_common_utils.set_error_response("500", "ERROR")
        with patch.object(PmLogAdapter, 'error',
                          return_value=None) as error_method:

            # call function test
            with self.assertRaises(PmError) as exception:
                aws_common.send_email(trace_id, region_name, sender, bcc,
                                      subject, body)

        # check result
        cause_error = exception.exception.cause_error.response['Error']
        self.assertEqual(cause_error['Code'],
                         mock_common_utils.get_error_code())
        self.assertEqual(cause_error['Message'],
                         mock_common_utils.get_error_message())
        error_method.assert_any_call("[%s] SESクライアント作成に失敗しました。", region_name)