# Path: gitmostwanted/services/log.py
# def instance(app):
#     """:rtype: logging.Logger"""
#     if app.testing:
#         app.logger.disabled = True
#         return app.logger
# 
#     if app.debug:
#         app.logger.setLevel(logging.DEBUG)
#         return app.logger
# 
#     handler = logging.handlers\
#         .TimedRotatingFileHandler(app.config['DEBUG_FILE'], when='d', backupCount=7)
#     handler.setLevel(logging.INFO)
#     handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
# 
#     app.logger.setLevel(logging.INFO)
#     app.logger.addHandler(handler)
# 
#     return app.logger


from gitmostwanted.services.log import instance
from unittest import TestCase, mock


class ServicesLogTestCase(TestCase):
    def test_use_logger_normally(self):
        app = mock.MagicMock(debug=False, testing=False, logger=mock.MagicMock())
        with mock.patch('logging.handlers.TimedRotatingFileHandler'):

# Path: gitmostwanted/services/log.py
# def instance(app):
#     """:rtype: logging.Logger"""
#     if app.testing:
#         app.logger.disabled = True
#         return app.logger
# 
#     if app.debug:
#         app.logger.setLevel(logging.DEBUG)
#         return app.logger
# 
#     handler = logging.handlers\
#         .TimedRotatingFileHandler(app.config['DEBUG_FILE'], when='d', backupCount=7)
#     handler.setLevel(logging.INFO)
#     handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
# 
#     app.logger.setLevel(logging.INFO)
#     app.logger.addHandler(handler)
# 
#     return app.logger


# Path: tests/unit/services/test_log.py
from gitmostwanted.services.log import instance
from unittest import TestCase, mock



class ServicesLogTestCase(TestCase):
    def test_use_logger_normally(self):
        app = mock.MagicMock(debug=False, testing=False, logger=mock.MagicMock())
        with mock.patch('logging.handlers.TimedRotatingFileHandler'):

            instance(app)