mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
refactor(test): move custom doctype data setup to bootstrap
(cherry picked from commit 934740205a)
This commit is contained in:
@@ -22,9 +22,6 @@ from erpnext.tests.utils import ERPNextTestSuite
|
|||||||
|
|
||||||
|
|
||||||
class TestInventoryDimension(ERPNextTestSuite):
|
class TestInventoryDimension(ERPNextTestSuite):
|
||||||
def setUp(self):
|
|
||||||
prepare_test_data()
|
|
||||||
|
|
||||||
def test_validate_inventory_dimension(self):
|
def test_validate_inventory_dimension(self):
|
||||||
# Can not be child doc
|
# Can not be child doc
|
||||||
inv_dim1 = create_inventory_dimension(
|
inv_dim1 = create_inventory_dimension(
|
||||||
@@ -77,6 +74,7 @@ class TestInventoryDimension(ERPNextTestSuite):
|
|||||||
self.assertFalse(custom_field)
|
self.assertFalse(custom_field)
|
||||||
|
|
||||||
def test_inventory_dimension(self):
|
def test_inventory_dimension(self):
|
||||||
|
create_warehouse("Shelf Warehouse")
|
||||||
warehouse = "Shelf Warehouse - _TC"
|
warehouse = "Shelf Warehouse - _TC"
|
||||||
item_code = "_Test Item"
|
item_code = "_Test Item"
|
||||||
|
|
||||||
@@ -556,28 +554,6 @@ def get_voucher_sl_entries(voucher_no, fields):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def prepare_test_data():
|
|
||||||
for shelf in ["Shelf 1", "Shelf 2"]:
|
|
||||||
if not frappe.db.exists("Shelf", shelf):
|
|
||||||
frappe.get_doc({"doctype": "Shelf", "shelf_name": shelf}).insert(ignore_permissions=True)
|
|
||||||
|
|
||||||
create_warehouse("Shelf Warehouse")
|
|
||||||
|
|
||||||
for rack in ["Rack 1", "Rack 2"]:
|
|
||||||
if not frappe.db.exists("Rack", rack):
|
|
||||||
frappe.get_doc({"doctype": "Rack", "rack_name": rack}).insert(ignore_permissions=True)
|
|
||||||
|
|
||||||
create_warehouse("Rack Warehouse")
|
|
||||||
|
|
||||||
for site in ["Site 1", "Site 2"]:
|
|
||||||
if not frappe.db.exists("Inv Site", site):
|
|
||||||
frappe.get_doc({"doctype": "Inv Site", "site_name": site}).insert(ignore_permissions=True)
|
|
||||||
|
|
||||||
for store in ["Store 1", "Store 2"]:
|
|
||||||
if not frappe.db.exists("Store", store):
|
|
||||||
frappe.get_doc({"doctype": "Store", "store_name": store}).insert(ignore_permissions=True)
|
|
||||||
|
|
||||||
|
|
||||||
def create_inventory_dimension(**args):
|
def create_inventory_dimension(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
|
|||||||
@@ -254,6 +254,12 @@ class BootStrapTestData:
|
|||||||
# custom doctype
|
# custom doctype
|
||||||
self.make_custom_doctype()
|
self.make_custom_doctype()
|
||||||
|
|
||||||
|
# data on custom doctype
|
||||||
|
self.make_shelf()
|
||||||
|
self.make_rack()
|
||||||
|
self.make_inv_site()
|
||||||
|
self.make_store()
|
||||||
|
|
||||||
# custom field
|
# custom field
|
||||||
self.make_custom_field()
|
self.make_custom_field()
|
||||||
|
|
||||||
@@ -2846,6 +2852,58 @@ class BootStrapTestData:
|
|||||||
|
|
||||||
create_custom_fields(pan_field, update=1)
|
create_custom_fields(pan_field, update=1)
|
||||||
|
|
||||||
|
def make_shelf(self):
|
||||||
|
records = [
|
||||||
|
{
|
||||||
|
"doctype": "Shelf",
|
||||||
|
"shelf_name": "Shelf 1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Shelf",
|
||||||
|
"shelf_name": "Shelf 2",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
self.make_records(["shelf_name"], records)
|
||||||
|
|
||||||
|
def make_rack(self):
|
||||||
|
records = [
|
||||||
|
{
|
||||||
|
"doctype": "Rack",
|
||||||
|
"rack_name": "Rack 1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Rack",
|
||||||
|
"rack_name": "Rack 2",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
self.make_records(["rack_name"], records)
|
||||||
|
|
||||||
|
def make_inv_site(self):
|
||||||
|
records = [
|
||||||
|
{
|
||||||
|
"doctype": "Inv Site",
|
||||||
|
"site_name": "Site 1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Inv Site",
|
||||||
|
"site_name": "Site 2",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
self.make_records(["site_name"], records)
|
||||||
|
|
||||||
|
def make_store(self):
|
||||||
|
records = [
|
||||||
|
{
|
||||||
|
"doctype": "Store",
|
||||||
|
"store_name": "Store 1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "Store",
|
||||||
|
"store_name": "Store 2",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
self.make_records(["store_name"], records)
|
||||||
|
|
||||||
|
|
||||||
BootStrapTestData()
|
BootStrapTestData()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user