mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-21 23:53:55 +02:00
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
This commit is contained in:
@ -1,15 +1,21 @@
|
||||
"""Smoke-test over the logger config."""
|
||||
from argparse import ArgumentParser
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from aki_prj23_transparenzregister.utils.logger_config import configer_logger
|
||||
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", "warning"])
|
||||
@pytest.mark.parametrize("level", ["info", "debug", "error"])
|
||||
def test_configer_logger(
|
||||
parser: bool,
|
||||
level: str,
|
||||
upper: bool,
|
||||
path: Path | str | None,
|
||||
@ -17,10 +23,32 @@ def test_configer_logger(
|
||||
"""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()
|
||||
configer_logger(level, path) # type: ignore
|
||||
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)
|
||||
|
Reference in New Issue
Block a user