test: add test for get_timeline_data in item
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index d9c77ef..234a913 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -11,7 +11,7 @@
InvalidItemAttributeValueError, get_variant)
from erpnext.stock.doctype.item.item import StockExistsForTemplate, InvalidBarcode
from erpnext.stock.doctype.item.item import (get_uom_conv_factor, get_item_attribute,
- validate_is_stock_item)
+ validate_is_stock_item, get_timeline_data)
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from erpnext.stock.get_item_details import get_item_details
@@ -488,6 +488,20 @@
new_barcode.barcode_type = 'EAN'
self.assertRaises(InvalidBarcode, item_doc.save)
+ def test_heatmap_data(self):
+ import time
+ data = get_timeline_data("Item", "_Test Item")
+ self.assertTrue(isinstance(data, dict))
+
+ now = time.time()
+ one_year_ago = now - 366 * 24 * 60 * 60
+
+ for timestamp, count in data.items():
+ self.assertIsInstance(timestamp, int)
+ self.assertTrue(one_year_ago <= timestamp <= now)
+ self.assertIsInstance(count, int)
+ self.assertTrue(count >= 0)
+
def test_index_creation(self):
"check if index is getting created in db"
from erpnext.stock.doctype.item.item import on_doctype_update