mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-17 16:38:41 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user