aki_prj23_transparenzregister/tests/utils/logger_config_test.py
Philipp Horstenkamp d2d4a436f8
Add a cli interface to choose a configuration (#163)
- [x] add a cli to the webserver to take env variables into account 
- [x] add a cli to the data processing that takes enviromental variable
as a valid source into account
- [x] rework the cli for the reset sql command
- [x] rework the cli for the copying of sql data from one db to another
2023-10-02 20:31:42 +02:00

55 lines
1.6 KiB
Python

"""Smoke-test over the logger config."""
from argparse import ArgumentParser
from pathlib import Path
import pytest
from aki_prj23_transparenzregister.utils.logger_config import (
add_logger_options_to_argparse,
configer_logger,
)
@pytest.mark.parametrize("parser", [True, False])
@pytest.mark.parametrize("path", [None, "test-log.log", ""])
@pytest.mark.parametrize("upper", [True, False])
@pytest.mark.parametrize("level", ["info", "debug", "error"])
def test_configer_logger(
parser: bool,
level: str,
upper: bool,
path: Path | str | None,
) -> None:
"""Tests the configuration of the logger.
Args:
parser: If the arguments should be given via the parser or not.
level: The log-level to configure.
upper: If the upper variant of the level should be used.
path: The path where to save the log.
"""
if level.upper():
level = level.upper()
if parser:
args_parser = ArgumentParser()
add_logger_options_to_argparse(args_parser)
configer_logger(
namespace=args_parser.parse_args(
[
"--level",
level if level else "",
"--log-path",
str(path) if path else "",
]
)
)
else:
configer_logger(level=level, path=path) # type: ignore
def test_add_logger_options_to_argparse() -> None:
"""A test checking if the ArgumentParser is modified."""
args_parser = ArgumentParser()
add_logger_options_to_argparse(args_parser)