예제 #1
0
    def test_normal(self, capfd: CaptureFixture, name, msg, args, kwargs):
        MyLogger(name).warning(msg, *args, **kwargs)

        _, err = capfd.readouterr()
        actual = json.loads(err)

        assert actual["name"] == name
        assert actual["msg"] == msg
        assert actual["args"] == args
        assert actual["levelname"] == "WARNING"
        assert actual["additional_data"] == kwargs
from typing import Optional, Tuple

import boto3
from botocore.client import BaseClient
from slack import WebClient

from logger.decorator import lambda_auto_logging
from logger.my_logger import MyLogger

logger = MyLogger(__name__)


@lambda_auto_logging()
def handler(event, context):
    main(event)


def main(event: dict, ssm_client: BaseClient = boto3.client("ssm")):
    user_name, ts, amount, sack_times, user_times = parse_event(event)
    slack_config = get_slack_config(ssm_client)
    slack_client = get_slack_client(slack_config)
    option_update_message = create_update_message_option(
        user_name, ts, amount, sack_times, user_times, slack_config)
    update_message(option_update_message, slack_client)


def parse_event(event: dict) -> Tuple[str, str, int, int, int]:
    data = event["responsePayload"]
    return data["user_name"], data["ts"], data["amount"], data[
        "sack_times"], data["user_times"]
예제 #3
0
from logger.my_logger import MyLogger


logger = MyLogger()
logger.print_example_logs()