fix: Remove every bit of randomness from this test
diff --git a/erpnext/controllers/tests/test_mapper.py b/erpnext/controllers/tests/test_mapper.py
index 5ebf8cf..66459fd 100644
--- a/erpnext/controllers/tests/test_mapper.py
+++ b/erpnext/controllers/tests/test_mapper.py
@@ -13,12 +13,12 @@
'''Test mapping of multiple source docs on a single target doc'''
make_test_records("Item")
- items = frappe.get_all("Item", fields = ["name", "item_code"], filters = {'is_sales_item': 1, 'has_variants': 0, 'disabled': 0})
- if items:
- # Make source docs (quotations) and a target doc (sales order)
- qtn1, item_list_1 = self.make_quotation(items, '_Test Customer')
- qtn2, item_list_2 = self.make_quotation(items, '_Test Customer')
- so, item_list_3 = self.make_sales_order()
+ items = ['_Test Item', '_Test Item 2', '_Test FG Item']
+
+ # Make source docs (quotations) and a target doc (sales order)
+ qtn1, item_list_1 = self.make_quotation(items, '_Test Customer')
+ qtn2, item_list_2 = self.make_quotation(items, '_Test Customer')
+ so, item_list_3 = self.make_sales_order()
# Map source docs to target with corresponding mapper method
method = "erpnext.selling.doctype.quotation.quotation.make_sales_order"
@@ -26,18 +26,12 @@
# Assert that all inserted items are present in updated sales order
src_items = item_list_1 + item_list_2 + item_list_3
- self.assertEqual(set([d.item_code for d in src_items]),
+ self.assertEqual(set([d for d in src_items]),
set([d.item_code for d in updated_so.items]))
- def get_random_items(self, items, limit):
- '''Get a number of random items from a list of given items'''
- random_items = []
- for i in range(0, limit):
- random_items.append(random.choice(items))
- return random_items
- def make_quotation(self, items, customer):
- item_list = self.get_random_items(items, 3)
+ def make_quotation(self, item_list, customer):
+
qtn = frappe.get_doc({
"doctype": "Quotation",
"quotation_to": "Customer",
@@ -47,7 +41,7 @@
"valid_till" : add_months(nowdate(), 1)
})
for item in item_list:
- qtn.append("items", {"qty": "2", "item_code": item.item_code})
+ qtn.append("items", {"qty": "2", "item_code": item})
qtn.submit()
return qtn, item_list
@@ -58,7 +52,7 @@
"base_rate": 100.0,
"description": "CPU",
"doctype": "Sales Order Item",
- "item_code": "_Test Item Home Desktop 100",
+ "item_code": "_Test Item",
"item_name": "CPU",
"parentfield": "items",
"qty": 10.0,
@@ -70,4 +64,4 @@
})
so = frappe.get_doc(frappe.get_test_records('Sales Order')[0])
so.insert(ignore_permissions=True)
- return so, [item]
+ return so, [item.item_code]
diff --git a/erpnext/selling/doctype/sales_order/test_records.json b/erpnext/selling/doctype/sales_order/test_records.json
index 6cbd6c2..8a090e6 100644
--- a/erpnext/selling/doctype/sales_order/test_records.json
+++ b/erpnext/selling/doctype/sales_order/test_records.json
@@ -1,39 +1,39 @@
[
{
"advance_paid": 0.0,
- "company": "_Test Company",
- "conversion_rate": 1.0,
- "currency": "INR",
- "customer": "_Test Customer",
- "customer_group": "_Test Customer Group",
- "customer_name": "_Test Customer",
- "doctype": "Sales Order",
- "base_grand_total": 1000.0,
- "grand_total": 1000.0,
- "naming_series": "_T-Sales Order-",
- "order_type": "Sales",
- "plc_conversion_rate": 1.0,
- "price_list_currency": "INR",
+ "company": "_Test Company",
+ "conversion_rate": 1.0,
+ "currency": "INR",
+ "customer": "_Test Customer",
+ "customer_group": "_Test Customer Group",
+ "customer_name": "_Test Customer",
+ "doctype": "Sales Order",
+ "base_grand_total": 1000.0,
+ "grand_total": 1000.0,
+ "naming_series": "_T-Sales Order-",
+ "order_type": "Sales",
+ "plc_conversion_rate": 1.0,
+ "price_list_currency": "INR",
"items": [
{
- "base_amount": 1000.0,
- "base_rate": 100.0,
- "description": "CPU",
- "doctype": "Sales Order Item",
- "item_code": "_Test Item Home Desktop 100",
- "item_name": "CPU",
- "delivery_date": "2013-02-23",
- "parentfield": "items",
- "qty": 10.0,
- "rate": 100.0,
+ "base_amount": 1000.0,
+ "base_rate": 100.0,
+ "description": "CPU",
+ "doctype": "Sales Order Item",
+ "item_code": "_Test Item",
+ "item_name": "_Test Item 1",
+ "delivery_date": "2013-02-23",
+ "parentfield": "items",
+ "qty": 10.0,
+ "rate": 100.0,
"warehouse": "_Test Warehouse - _TC",
"stock_uom": "_Test UOM",
"conversion_factor": 1.0,
"uom": "_Test UOM"
}
- ],
- "selling_price_list": "_Test Price List",
- "territory": "_Test Territory",
+ ],
+ "selling_price_list": "_Test Price List",
+ "territory": "_Test Territory",
"transaction_date": "2013-02-21"
}
]
\ No newline at end of file