# Path: bottery/log.py
# DEFAULT_LOGGING = {
#     'version': 1,
#     'disable_existing_loggers': False,
#     'handlers': {
#         'console': {
#             'class': 'logging.StreamHandler',
#             'level': 'DEBUG',
#             'formatter': 'bottery.server',
#         }
#     },
#     'formatters': {
#         'bottery.server': {
#             'class': 'bottery.log.ColoredFormatter',
#             'format': '%(asctime)s %(message)s',
#             'datefmt': '%H:%M:%S',
#         }
#     },
#     'loggers': {
#         'bottery': {
#             'handlers': ['console'],
#             'level': 'INFO',
#             'propagate': False,
#         },
#     },
# }
# 
# class ColoredFormatter(logging.Formatter):
#     def format(self, record):
#         options = DEFAULT_COLORS.get(record.levelno, {})
# 
#         if options:
#             record.msg = click.style(record.msg, **options)
# 
#         return super().format(record)
# 
# class Spinner:
#     def __init__(self, message):
#         self.halo = Halo(text=message, spinner='dot', color='green')
# 
#     def __enter__(self):
#         self.halo.__enter__()
# 
#     def __exit__(self, exc_type, exc_val, exc_tb):
#         self.halo.__exit__(exc_tb, exc_val, exc_tb)


import logging
import pytest
from unittest import mock
from testfixtures import LogCapture
from bottery.log import DEFAULT_LOGGING, ColoredFormatter, Spinner
        logger.error('ERROR')
        logger.critical('CRITICAL')
        records = [record for record in logs.records]

    # Create a list of all records formated with ColoredFormatter
    colored_formatter = ColoredFormatter()
    formatted_records = [colored_formatter.format(record)
                         for record in records]

    expected_records = [
        'DEBUG',
        'INFO',
        '\x1b[33mWARN\x1b[0m',
        '\x1b[31mERROR\x1b[0m',
        '\x1b[30m\x1b[41mCRITICAL\x1b[0m'
    ]

    assert formatted_records == expected_records


@mock.patch('bottery.log.Halo')
def test_spinner_instance(mocked_halo):
    Spinner('message')
    mocked_halo.assert_called_once_with(text='message', spinner='dot',
                                        color='green')


@pytest.mark.parametrize('attr', ['__enter__', '__exit__'])
@mock.patch('bottery.log.Halo')
def test_spinner_context(mocked_halo, attr):

# Path: bottery/log.py
# DEFAULT_LOGGING = {
#     'version': 1,
#     'disable_existing_loggers': False,
#     'handlers': {
#         'console': {
#             'class': 'logging.StreamHandler',
#             'level': 'DEBUG',
#             'formatter': 'bottery.server',
#         }
#     },
#     'formatters': {
#         'bottery.server': {
#             'class': 'bottery.log.ColoredFormatter',
#             'format': '%(asctime)s %(message)s',
#             'datefmt': '%H:%M:%S',
#         }
#     },
#     'loggers': {
#         'bottery': {
#             'handlers': ['console'],
#             'level': 'INFO',
#             'propagate': False,
#         },
#     },
# }
# 
# class ColoredFormatter(logging.Formatter):
#     def format(self, record):
#         options = DEFAULT_COLORS.get(record.levelno, {})
# 
#         if options:
#             record.msg = click.style(record.msg, **options)
# 
#         return super().format(record)
# 
# class Spinner:
#     def __init__(self, message):
#         self.halo = Halo(text=message, spinner='dot', color='green')
# 
#     def __enter__(self):
#         self.halo.__enter__()
# 
#     def __exit__(self, exc_type, exc_val, exc_tb):
#         self.halo.__exit__(exc_tb, exc_val, exc_tb)


# Path: tests/test_log.py
import logging
import pytest
from unittest import mock
from testfixtures import LogCapture
from bottery.log import DEFAULT_LOGGING, ColoredFormatter, Spinner

        logger.error('ERROR')
        logger.critical('CRITICAL')
        records = [record for record in logs.records]

    # Create a list of all records formated with ColoredFormatter
    colored_formatter = ColoredFormatter()
    formatted_records = [colored_formatter.format(record)
                         for record in records]

    expected_records = [
        'DEBUG',
        'INFO',
        '\x1b[33mWARN\x1b[0m',
        '\x1b[31mERROR\x1b[0m',
        '\x1b[30m\x1b[41mCRITICAL\x1b[0m'
    ]

    assert formatted_records == expected_records


@mock.patch('bottery.log.Halo')
def test_spinner_instance(mocked_halo):
    Spinner('message')
    mocked_halo.assert_called_once_with(text='message', spinner='dot',
                                        color='green')


@pytest.mark.parametrize('attr', ['__enter__', '__exit__'])
@mock.patch('bottery.log.Halo')
def test_spinner_context(mocked_halo, attr):

    spinner = Spinner('message')