make --model-basedir and --model-overrides top-level CLI options

This commit is contained in:
kba 2025-10-29 18:24:17 +01:00
parent b6f82c72b9
commit a913bdf7dc
18 changed files with 132 additions and 170 deletions

View file

@ -1,15 +1,17 @@
from typing import List
from click import Command
import pytest
import logging
from click.testing import CliRunner, Result
from eynollah.cli import main as eynollah_cli
@pytest.fixture
def run_eynollah_ok_and_check_logs(
pytestconfig,
caplog,
model_dir,
eynollah_subcommands,
eynollah_log_filter,
):
"""
@ -18,14 +20,23 @@ def run_eynollah_ok_and_check_logs(
every fragment in `expected_logs`
"""
def _run_click_ok_logs(cli: Command, args: List[str], expected_logs: List[str]) -> Result:
args = ['-m', model_dir] + args
def _run_click_ok_logs(
subcommand: 'str',
args: List[str],
expected_logs: List[str],
) -> Result:
assert subcommand in eynollah_subcommands, f'subcommand {subcommand} must be one of {eynollah_subcommands}'
args = [
'-m', model_dir,
subcommand,
*args
]
if pytestconfig.getoption('verbose') > 0:
args.extend(['-l', 'DEBUG'])
caplog.set_level(logging.INFO)
runner = CliRunner()
with caplog.filtering(eynollah_log_filter):
result = runner.invoke(cli, args, catch_exceptions=False)
result = runner.invoke(eynollah_cli, args, catch_exceptions=False)
assert result.exit_code == 0, result.stdout
if expected_logs:
logmsgs = [logrec.message for logrec in caplog.records]