-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Javier Collado
committed
Nov 25, 2016
1 parent
84aa343
commit 40733fb
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |