From 788d4927570afc6725758399ae3c4589a26f9dc7 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Fri, 25 Mar 2022 00:01:23 +0530 Subject: [PATCH] test: basic item and wh capacity dashboard tests --- erpnext/stock/dashboard/item_dashboard.py | 11 ++++------- erpnext/stock/doctype/item/test_item.py | 6 ++++++ .../doctype/putaway_rule/test_putaway_rule.py | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/erpnext/stock/dashboard/item_dashboard.py b/erpnext/stock/dashboard/item_dashboard.py index 57d78a21e1..75aa1d36c7 100644 --- a/erpnext/stock/dashboard/item_dashboard.py +++ b/erpnext/stock/dashboard/item_dashboard.py @@ -40,18 +40,15 @@ def get_data(item_code=None, warehouse=None, item_group=None, filters=filters, order_by=sort_by + ' ' + sort_order, limit_start=start, - limit_page_length='21') + limit_page_length=21) precision = cint(frappe.db.get_single_value("System Settings", "float_precision")) for item in items: item.update({ - 'item_name': frappe.get_cached_value( - "Item", item.item_code, 'item_name'), - 'disable_quick_entry': frappe.get_cached_value( - "Item", item.item_code, 'has_batch_no') - or frappe.get_cached_value( - "Item", item.item_code, 'has_serial_no'), + 'item_name': frappe.get_cached_value("Item", item.item_code, 'item_name'), + 'disable_quick_entry': frappe.get_cached_value( "Item", item.item_code, 'has_batch_no') + or frappe.get_cached_value( "Item", item.item_code, 'has_serial_no'), 'projected_qty': flt(item.projected_qty, precision), 'reserved_qty': flt(item.reserved_qty, precision), 'reserved_qty_for_production': flt(item.reserved_qty_for_production, precision), diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py index 112420ff7b..05e6e76e21 100644 --- a/erpnext/stock/doctype/item/test_item.py +++ b/erpnext/stock/doctype/item/test_item.py @@ -685,6 +685,12 @@ class TestItem(FrappeTestCase): # standalone return make_purchase_receipt(is_return=True, qty=-1, **typical_args) + def test_item_dashboard(self): + from erpnext.stock.dashboard.item_dashboard import get_data + + self.assertTrue(get_data(item_code="_Test Item")) + self.assertTrue(get_data(warehouse="_Test Warehouse - _TC")) + self.assertTrue(get_data(item_group="All Item Groups")) def set_item_variant_settings(fields): diff --git a/erpnext/stock/doctype/putaway_rule/test_putaway_rule.py b/erpnext/stock/doctype/putaway_rule/test_putaway_rule.py index 4e8d71fe5e..0ec812c655 100644 --- a/erpnext/stock/doctype/putaway_rule/test_putaway_rule.py +++ b/erpnext/stock/doctype/putaway_rule/test_putaway_rule.py @@ -396,6 +396,21 @@ class TestPutawayRule(FrappeTestCase): rule_1.delete() rule_2.delete() + def test_warehouse_capacity_dashbord(self): + from erpnext.stock.dashboard.warehouse_capacity_dashboard import get_data + + item = "_Rice" + rule = create_putaway_rule(item_code=item, warehouse=self.warehouse_1, capacity=500, + uom="Kg") + + capacities = get_data(warehouse=self.warehouse_1) + for capacity in capacities: + if capacity.item_code == item and capacity.warehouse == self.warehouse_1: + self.assertEqual(capacity.stock_capacity, 500) + + get_data(warehouse=self.warehouse_1) + rule.delete() + def create_putaway_rule(**args): args = frappe._dict(args) putaway = frappe.new_doc("Putaway Rule")