Skip to content

Commit

Permalink
Added logger tests
Browse files Browse the repository at this point in the history
  • Loading branch information
barshaul committed Oct 5, 2023
1 parent 873636d commit 443da99
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
5 changes: 2 additions & 3 deletions python/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
from pybushka.redis_client import RedisClient, RedisClusterClient, TRedisClient
from tests.utils.cluster import RedisCluster

default_host = "localhost"
default_port = 6379
DEFAULT_TEST_LOG_LEVEL = logLevel.WARN

Logger.set_logger_config(logLevel.WARN)
Logger.set_logger_config(DEFAULT_TEST_LOG_LEVEL)


def pytest_addoption(parser):
Expand Down
16 changes: 16 additions & 0 deletions python/python/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pybushka.logger import Level, Logger
from tests.conftest import DEFAULT_TEST_LOG_LEVEL


class TestLogger:
def test_init_logger(self):
# The logger is already configured in the conftest file, so calling init again shouldn't modify the log level
Logger.init(Level.DEBUG)
assert Logger.logger_level != Level.DEBUG.value

def test_set_logger_config(self):
Logger.set_logger_config(Level.INFO)
assert Logger.logger_level == Level.INFO.value
# Revert to the tests default log level
Logger.set_logger_config(DEFAULT_TEST_LOG_LEVEL)
assert Logger.logger_level == DEFAULT_TEST_LOG_LEVEL.value

0 comments on commit 443da99

Please sign in to comment.