#43 — Имя файла и пути по умолчанию: - resolve_output_path() в yaml_config.py: резолвит --output с учётом output.dir, filename_template, default_format из YAML-конфига - Bare format (xlsx/odt/...) → путь по шаблону - Без расширения → автодописывается default_format (.xlsx) - Config.get_output_dir/filename/default_format() #47 — datetime precision и дедупликация: - period.last_used.from/to в YAML-конфиге и AppConfig - period.precision: date|datetime - _compute_dedup_cutoff() в cli.py: при precision=datetime вычисляет cutoff из period.last_used.to - _parse_datetime() + AND-логика дедупликации в client.py: запись исключается если created_on И updated_on < cutoff - Пропуск issues без часов после дедупликации Closes #43 Closes #47
This commit is contained in:
@@ -154,6 +154,9 @@ period:
|
||||
default_from: "2026-06-01"
|
||||
default_to: "2026-06-30"
|
||||
dynamic: true
|
||||
last_used:
|
||||
from: "2026-06-30T09:00:00"
|
||||
to: "2026-06-30T12:00:00"
|
||||
|
||||
output:
|
||||
dir: ~/reports
|
||||
@@ -196,6 +199,8 @@ class TestAppConfigFromYaml:
|
||||
assert cfg.period_default_from == "2026-06-01"
|
||||
assert cfg.period_default_to == "2026-06-30"
|
||||
assert cfg.period_dynamic is True
|
||||
assert cfg.period_last_used_from == "2026-06-30T09:00:00"
|
||||
assert cfg.period_last_used_to == "2026-06-30T12:00:00"
|
||||
assert cfg.output_dir == "~/reports"
|
||||
assert cfg.output_filename == "{author}_{from}_{to}.{ext}"
|
||||
assert cfg.output_default_format == "xlsx"
|
||||
@@ -387,3 +392,62 @@ class TestConfigYamlFallback:
|
||||
clear=True,
|
||||
):
|
||||
assert Config.get_default_date_range() == "2026-07-01--2026-07-15"
|
||||
|
||||
|
||||
class TestConfigPeriodPrecision:
|
||||
"""Tests for period.precision and period.last_used."""
|
||||
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_get_period_precision_defaults_to_date(self):
|
||||
"""Без YAML-конфига precision == 'date'."""
|
||||
Config._app = None
|
||||
assert Config.get_period_precision() == "date"
|
||||
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_get_period_precision_from_yaml(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
yaml_path = Path(tmp) / "config.yml"
|
||||
yaml_path.write_text("period:\n precision: datetime\n")
|
||||
|
||||
Config._app = AppConfig.from_yaml(yaml_path)
|
||||
assert Config.get_period_precision() == "datetime"
|
||||
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_get_last_used_from_yaml(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
yaml_path = Path(tmp) / "config.yml"
|
||||
yaml_path.write_text(
|
||||
"period:\n last_used:\n from: '2026-06-30T09:00:00'\n to: '2026-06-30T12:00:00'\n"
|
||||
)
|
||||
|
||||
Config._app = AppConfig.from_yaml(yaml_path)
|
||||
assert Config.get_last_used_from() == "2026-06-30T09:00:00"
|
||||
assert Config.get_last_used_to() == "2026-06-30T12:00:00"
|
||||
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_get_last_used_returns_empty_when_not_set(self):
|
||||
Config._app = AppConfig()
|
||||
assert Config.get_last_used_from() == ""
|
||||
assert Config.get_last_used_to() == ""
|
||||
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_yaml_loads_last_used_field(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
yaml_path = Path(tmp) / "config.yml"
|
||||
yaml_path.write_text(
|
||||
"period:\n last_used:\n from: '2026-07-01T08:00:00'\n to: '2026-07-01T18:00:00'\n"
|
||||
)
|
||||
|
||||
cfg = AppConfig.from_yaml(yaml_path)
|
||||
assert cfg.period_last_used_from == "2026-07-01T08:00:00"
|
||||
assert cfg.period_last_used_to == "2026-07-01T18:00:00"
|
||||
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_yaml_without_last_used_has_empty_fields(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
yaml_path = Path(tmp) / "config.yml"
|
||||
yaml_path.write_text("period:\n precision: date\n")
|
||||
|
||||
cfg = AppConfig.from_yaml(yaml_path)
|
||||
assert cfg.period_last_used_from == ""
|
||||
assert cfg.period_last_used_to == ""
|
||||
|
||||
Reference in New Issue
Block a user