def test_logger_log(caplog):
    logger = custom_logging.get_logger(__name__)
    logger.error("This is an error")
    logger.warning("This is a warning")
    logger.info("This is an informational message")
    logger.debug("This is a debug message")
    assert "This is an error" in caplog.text
    assert "This is a warning" in caplog.text
    assert "This is an informational message" not in caplog.text
    assert "This is a debug message" not in caplog.text
Ejemplo n.º 2
0
#  Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance     #
#  with the License. A copy of the License is located at                                                              #
#                                                                                                                     #
#  http://www.apache.org/licenses/LICENSE-2.0                                                                         #
#                                                                                                                     #
#  or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES  #
#  OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions     #
#  and limitations under the License.                                                                                 #
# #####################################################################################################################

from shared_util import custom_logging

from util.quicksight_application import QuicksightApplication
from util.template import TemplatePermissionType

logger = custom_logging.get_logger(__name__)


class QuicksightApi:
    def __init__(self, resource_properties):
        self.quicksight_application = QuicksightApplication(
            resource_properties)
        self.global_state = self.quicksight_application.get_global_state()

    def create_all_resources(self):
        responses = []

        responses.append(self.create_data_source())
        responses.append(self.create_data_sets())
        responses.append(self.create_analysis())
        responses.append(self.create_dashboard())
#                                                                                                                    #
#  or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES #
#  OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions    #
#  and limitations under the License.                                                                                #
######################################################################################################################

import os
import tempfile

import botocore
from datetime import datetime, timezone
from shared_util.custom_logging import get_logger
from shared_util.service_helper import get_service_resource, get_service_client
from util.constants import TIMESTAMP_FORMAT

logger = get_logger(__name__)

local_folder_path = tempfile.gettempdir()

max_file_size = 10000000  # this number is in bytes that equals 10 MB


class FileSizeTooBigException(Exception):
    pass


def download_file(bucket_name: str, key_prefix: str):
    s3 = get_service_resource("s3")
    """ Download the file locally to the /tmp folder provided by lambda runtime """
    logger.debug(f"prefix is {key_prefix}")
    local_file_name = os.path.basename(key_prefix)  # get file name
def test_get_logger():
    logger = custom_logging.get_logger(__name__)
    assert logger.level == logging.WARNING