Skip to content

Commit

Permalink
Add configure_logging test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Collado committed Nov 25, 2016
1 parent 84aa343 commit 40733fb
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-

"""CLI test cases."""

import logging

from unittest import TestCase

from rabbithole.cli import configure_logging


class TestConfigureLogging(TestCase):

"""Logging configuration test cases."""

def tearDown(self):
"""Delete root logger handlers."""
logging.getLogger().handlers = []

def test_root_level_set_to_debug(self):
"""Root logger level set to debug."""
configure_logging(logging.ERROR)
root_logger = logging.getLogger()
self.assertEqual(root_logger.level, logging.DEBUG)

def test_streamh_handler_level_set_to_argument(self):
"""Stream handler level set to argument value."""
expected_value = logging.ERROR
configure_logging(expected_value)
root_logger = logging.getLogger()
self.assertEqual(len(root_logger.handlers), 1)
handler = root_logger.handlers[0]
self.assertEqual(handler.level, expected_value)

def test_pika_level_set_warning(self):
"""Pika logger level is set to warning."""
configure_logging(logging.DEBUG)
pika_logger = logging.getLogger('pika')
self.assertEqual(pika_logger.level, logging.WARNING)

0 comments on commit 40733fb

Please sign in to comment.