feat: add report.no_time config option for automatic modes

Add YAML section `report.no_time` that controls `--no-time` behavior
in automatic modes (`--commit`, `--send`). CLI flag `--no-time`
always wins. Manual `--output` ignores the YAML setting.

- Config.get_report_no_time() reads the YAML value (defaults to false)
- cli._resolve_no_time() encapsulates CLI > YAML priority
- --init-config now generates the report section
- docs updated in README.md and docs/CONFIG.md

Closes #49
This commit is contained in:
Кокос Артем Николаевич
2026-07-10 14:38:07 +07:00
parent 5e1c366a60
commit 863ad50cc3
6 changed files with 377 additions and 4 deletions

View File

@@ -611,3 +611,43 @@ class TestGetEmailConfig:
Config._app = AppConfig.from_yaml(yaml_path)
assert Config.get_email_config() is None
class TestReportNoTime:
"""Tests for Config.get_report_no_time()."""
@mock.patch.dict(os.environ, {}, clear=True)
def test_get_report_no_time_from_yaml(self):
"""report.no_time: true загружается из YAML."""
with tempfile.TemporaryDirectory() as tmp:
yaml_path = Path(tmp) / "config.yml"
yaml_path.write_text("report:\n no_time: true\n")
Config._app = AppConfig.from_yaml(yaml_path)
assert Config.get_report_no_time() is True
@mock.patch.dict(os.environ, {}, clear=True)
def test_get_report_no_time_defaults_to_false(self):
"""Без YAML-конфига report.no_time по умолчанию False."""
Config._app = None
assert Config.get_report_no_time() is False
@mock.patch.dict(os.environ, {}, clear=True)
def test_get_report_no_time_from_yaml_false(self):
"""report.no_time: false явно загружается из YAML."""
with tempfile.TemporaryDirectory() as tmp:
yaml_path = Path(tmp) / "config.yml"
yaml_path.write_text("report:\n no_time: false\n")
Config._app = AppConfig.from_yaml(yaml_path)
assert Config.get_report_no_time() is False
@mock.patch.dict(os.environ, {}, clear=True)
def test_get_report_no_time_invalid_type_defaults_to_false(self):
"""report.no_time со строковым значением приводится к False."""
with tempfile.TemporaryDirectory() as tmp:
yaml_path = Path(tmp) / "config.yml"
yaml_path.write_text("report:\n no_time: 'invalid'\n")
Config._app = AppConfig.from_yaml(yaml_path)
assert Config.get_report_no_time() is False