From 3cd2a3611700050f9dd49788e145ad58b67b5dc3 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sun, 21 Jun 2026 15:59:04 +0530 Subject: [PATCH] test(stock): tolerate timezone slack in test_heatmap_data on Postgres get_timeline_data uses UnixTimestamp(posting_date); on Postgres that is the date's midnight epoch in the DB session timezone, which can sit up to a day ahead of the Python time.time() instant when the app timezone is ahead of UTC. The strict '<= now' upper bound is therefore flaky on Postgres. Allow a day of slack on the upper bound; MariaDB's UNIX_TIMESTAMP stays <= now so its pass/fail is unchanged. --- erpnext/stock/doctype/item/test_item.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index 6bb368fb123..16d8f0f469c 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -770,10 +770,14 @@ class TestItem(ERPNextTestSuite): now = time.time() one_year_ago = now - 366 * 24 * 60 * 60 + # posting_date is a calendar date; its midnight unix timestamp (taken in the database + # session timezone) can sit up to a day ahead of the precise current instant when the app + # timezone is ahead of UTC, so allow a day of slack on the upper bound. + one_day = 24 * 60 * 60 for timestamp, count in data.items(): self.assertIsInstance(timestamp, int) - self.assertTrue(one_year_ago <= timestamp <= now) + self.assertTrue(one_year_ago <= timestamp <= now + one_day) self.assertIsInstance(count, int) self.assertGreaterEqual(count, 0)