brotherton-erpnext/erpnext/tests/test_point_of_sale.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
1.8 KiB
Python
Raw Normal View History

2022-02-01 07:44:28 +00:00
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
2022-02-09 06:36:59 +00:00
import unittest
import frappe
2022-02-01 07:44:28 +00:00
from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile
from erpnext.selling.page.point_of_sale.point_of_sale import get_items
from erpnext.stock.doctype.item.test_item import make_item
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
2022-02-09 06:36:59 +00:00
class TestPointOfSale(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
frappe.db.savepoint("before_test_point_of_sale")
@classmethod
def tearDownClass(cls) -> None:
frappe.db.rollback(save_point="before_test_point_of_sale")
2022-02-01 07:44:28 +00:00
def test_item_search(self):
"""
Test Stock and Service Item Search.
"""
2022-03-01 09:26:24 +00:00
pos_profile = make_pos_profile(name="Test POS Profile for Search")
2022-02-01 09:14:12 +00:00
item1 = make_item("Test Search Stock Item", {"is_stock_item": 1})
2022-02-01 07:44:28 +00:00
make_stock_entry(
2022-02-01 09:14:12 +00:00
item_code="Test Search Stock Item",
qty=10,
to_warehouse="_Test Warehouse - _TC",
rate=500,
2022-02-01 07:44:28 +00:00
)
result = get_items(
start=0,
page_length=20,
price_list=None,
item_group=item1.item_group,
pos_profile=pos_profile.name,
2022-02-01 09:14:12 +00:00
search_term="Test Search Stock Item",
2022-02-01 07:44:28 +00:00
)
filtered_items = result.get("items")
self.assertEqual(len(filtered_items), 1)
2022-02-01 09:14:12 +00:00
self.assertEqual(filtered_items[0]["item_code"], item1.item_code)
2022-02-01 07:44:28 +00:00
self.assertEqual(filtered_items[0]["actual_qty"], 10)
2022-02-01 09:14:12 +00:00
item2 = make_item("Test Search Service Item", {"is_stock_item": 0})
2022-02-01 07:44:28 +00:00
result = get_items(
start=0,
page_length=20,
price_list=None,
item_group=item2.item_group,
pos_profile=pos_profile.name,
2022-02-01 09:14:12 +00:00
search_term="Test Search Service Item",
2022-02-01 07:44:28 +00:00
)
filtered_items = result.get("items")
self.assertEqual(len(filtered_items), 1)
2022-02-01 09:14:12 +00:00
self.assertEqual(filtered_items[0]["item_code"], item2.item_code)