fix: sliding period window for datetime precision
After --commit with precision=datetime, last_used held from==to==now, so the next default period degenerated to a single second and showed no new time entries. Now --commit stores the real report window start and get_default_date_range() returns last_used.to..now for datetime+dynamic mode. Closes #70
This commit is contained in:
@@ -99,6 +99,25 @@ def test_get_default_date_range_fallback():
|
||||
assert result == f"{start.isoformat()}--{today.isoformat()}"
|
||||
|
||||
|
||||
@mock.patch.dict(os.environ, {}, clear=True)
|
||||
def test_get_default_date_range_datetime_dynamic_sliding_window():
|
||||
app = AppConfig(
|
||||
period_precision="datetime",
|
||||
period_dynamic=True,
|
||||
period_last_used_to="2026-09-10T15:00:00+00:00",
|
||||
)
|
||||
Config._app = app
|
||||
try:
|
||||
real_dt = __import__("datetime").datetime
|
||||
with mock.patch("redmine_reporter.config.datetime") as dt:
|
||||
dt.fromisoformat = real_dt.fromisoformat
|
||||
dt.now.return_value = real_dt(2026, 9, 15, 10, 0, 0)
|
||||
rng = Config.get_default_date_range()
|
||||
finally:
|
||||
Config._app = None
|
||||
assert rng == "2026-09-10T15:00:00--2026-09-15T10:00:00"
|
||||
|
||||
|
||||
# -- #56: дефолтный период — текущий месяц (детерминированные тесты) --
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user