test: basic item and wh capacity dashboard tests

This commit is contained in:
Ankush Menat 2022-03-25 00:01:23 +05:30 committed by Ankush Menat
parent 10d5fb8cd1
commit 788d492757
3 changed files with 25 additions and 7 deletions

View File

@ -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),

View File

@ -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):

View File

@ -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")