From 25425901b1240d403773ee18e099f9843ba0023c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D0=BA=D0=BE=D1=81=20=D0=90=D1=80=D1=82=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B5=D0=B2=D0=B8?= =?UTF-8?q?=D1=87?= Date: Fri, 10 Jul 2026 12:37:46 +0700 Subject: [PATCH] fix: handle save_period_to_config errors, remove duplicate _MockIssue - cli.py: wrap save_period_to_config in try/except to avoid unhandled traceback on disk full / permission denial (I2) - test_cli.py: remove duplicate _MockIssue class definition (I3) --- redmine_reporter/cli.py | 9 ++++++++- tests/test_cli.py | 11 ----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/redmine_reporter/cli.py b/redmine_reporter/cli.py index b551da6..642f3f6 100644 --- a/redmine_reporter/cli.py +++ b/redmine_reporter/cli.py @@ -492,7 +492,14 @@ def main(argv: Optional[List[str]] = None) -> int: from_str = from_date to_str = to_date - save_period_to_config(args.config_path, from_str, to_str, precision, dynamic) + try: + save_period_to_config(args.config_path, from_str, to_str, precision, dynamic) + except Exception as e: + print( + f"❌ Не удалось сохранить период в конфиг: {e}", + file=sys.stderr, + ) + return 1 print( f"📌 Period committed [{from_str} -- {to_str}] → {args.config_path}", file=sys.stderr, diff --git a/tests/test_cli.py b/tests/test_cli.py index dd02230..b06f72c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -159,17 +159,6 @@ def test_cli_verbose_and_debug_flags_accepted(mock_fetch): assert code == 0 -class _MockIssue: - """Простой mock Redmine Issue для CLI-тестов.""" - - def __init__(self, issue_id=1, subject="Task", project="Project", status="New"): - self.id = issue_id - self.subject = subject - self.project = project - self.status = status - self.fixed_version = None - - @mock.patch.dict(os.environ, {}, clear=True) @mock.patch("redmine_reporter.cli.fetch_issues_with_spent_time") def test_cli_url_and_api_key_override_env(mock_fetch):