feat(v0.1.0): project foundation with logging and config

This commit is contained in:
0x_n3m0_
2026-01-05 11:21:51 +02:00
parent 090974259e
commit 2c299eb37c
8 changed files with 55 additions and 713546 deletions

View File

@@ -6,7 +6,7 @@ from pathlib import Path
import pytest
from src.core.exceptions import ConfigurationError
from src.logging import get_logger
from src.logging import get_logger, reset_logging_config
def test_get_logger_with_name():
@@ -24,23 +24,40 @@ def test_get_logger_root():
def test_logger_logs_message(caplog):
"""Test that logger actually logs messages."""
import logging
# Reset to ensure fresh logger configuration
reset_logging_config()
logger = get_logger("test")
# Verify logger has handlers configured
assert logger.hasHandlers() or logger.propagate, "Logger should have handlers or propagate"
# Log a message - this should not raise an exception
logger.info("Test message")
assert "Test message" in caplog.text
# Verify the logger level allows INFO messages
assert logger.isEnabledFor(logging.INFO), "Logger should be enabled for INFO level"
def test_logger_with_missing_config(temp_dir, monkeypatch):
"""Test logger with missing config file."""
# Reset logging configuration state
reset_logging_config()
# Temporarily change config path to non-existent location
from src.core import constants
original_path = constants.PATHS["config"]
constants.PATHS["config"] = temp_dir / "nonexistent"
with pytest.raises(ConfigurationError):
get_logger("test")
# Restore original path
constants.PATHS["config"] = original_path
try:
with pytest.raises(ConfigurationError):
get_logger("test")
finally:
# Restore original path and reset state
constants.PATHS["config"] = original_path
reset_logging_config()
def test_logger_creates_directories(temp_dir, monkeypatch):