Skip to content

Commit

Permalink
Add set logger test
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusbv committed Aug 4, 2023
1 parent 9da2f16 commit afcc177
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tests/unit/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"""
from pathlib import Path
from tempfile import NamedTemporaryFile
from unittest.mock import patch
from unittest.mock import patch, mock_open

from csp_billing_adapter.config import Config
from csp_billing_adapter.adapter import get_plugin_manager
Expand Down Expand Up @@ -313,3 +313,14 @@ def test_local_csp_usage_logging_not_set(caplog):
"file not set: [Errno 2] No such file or directory: " \
"'foo/bar/csp-config.json'"
assert debug_message in caplog.text


def test_local_csp_usage_logging_set(caplog):
caplog.set_level('DEBUG')
with open('tests/data/good/csp_config.json', 'r', encoding='utf-8') as f:
content = f.read()
with patch('builtins.open', mock_open(read_data=content)):
_set_logger_file()
debug_message = "DEBUG CSPBillingAdapter:plugin.py:51 Logger " \
"file set"
assert debug_message in caplog.text

0 comments on commit afcc177

Please sign in to comment.