Skip to content

Commit

Permalink
Adding more tests for config
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvieira committed Apr 20, 2020
1 parent 0985503 commit 3e86f3a
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/test_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import logging
from pythonjsonlogger import jsonlogger

from asynctest import TestCase
from barterdude.conf import getLogger


class TestConf(TestCase):

def setUp(self):
self.log_name = "barterdude"
self.log_level = logging.INFO

async def test_should_get_log_with_default_configs(self):
logger = getLogger()
self.assertEqual(
type(logger.handlers[0]),
logging.StreamHandler
)
self.assertEqual(logger.name, self.log_name)
self.assertEqual(logger.level, self.log_level)
self.assertEqual(
type(logger.handlers[0].formatter),
jsonlogger.JsonFormatter
)

async def test_should_get_log_with_custom_configs(self):
logger = getLogger("test_log", logging.DEBUG)
self.assertEqual(
type(logger.handlers[0]),
logging.StreamHandler
)
self.assertEqual(logger.name, "test_log")
self.assertEqual(logger.level, logging.DEBUG)
self.assertEqual(
type(logger.handlers[0].formatter),
jsonlogger.JsonFormatter
)

async def test_should_get_log_with_custom_configs_even_called_after(self):
logger_first = getLogger()
logger = getLogger("test_log", logging.DEBUG)
self.assertEqual(
type(logger.handlers[0]),
logging.StreamHandler
)
self.assertEqual(logger_first.name, self.log_name)
self.assertEqual(logger_first.level, self.log_level)
self.assertEqual(logger.name, "test_log")
self.assertEqual(logger.level, logging.DEBUG)
self.assertEqual(
type(logger.handlers[0].formatter),
jsonlogger.JsonFormatter
)

0 comments on commit 3e86f3a

Please sign in to comment.