Merge pull request #26043 from marination/subcontracted-rm-transfer-report-test

fix: Flaky test for Report Subcontracted Raw materials to be transferred
This commit is contained in:
Marica 2021-06-14 15:25:05 +05:30 committed by GitHub
commit 18833b5ea1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,42 +30,54 @@ class TestSubcontractedItemToBeTransferred(unittest.TestCase):
po.reload()
po_data = [row for row in data if row.get('purchase_order') == po.name]
# Alphabetically sort to be certain of order
po_data = sorted(po_data, key = lambda i: i['rm_item_code'])
self.assertEqual(len(po_data), 2)
self.assertIn(po_data[0]['rm_item_code'], ['_Test Item', '_Test Item Home Desktop 100'])
self.assertIn(po_data[0]['p_qty'], [9, 18])
self.assertIn(po_data[0]['transferred_qty'], [1, 2])
self.assertEqual(po_data[0]['purchase_order'], po.name)
self.assertEqual(data[1]['purchase_order'], po.name)
self.assertIn(data[1]['rm_item_code'], ['_Test Item', '_Test Item Home Desktop 100'])
self.assertIn(data[1]['p_qty'], [9, 18])
self.assertIn(data[1]['transferred_qty'], [1, 2])
self.assertEqual(po_data[0]['rm_item_code'], '_Test Item')
self.assertEqual(po_data[0]['p_qty'], 8)
self.assertEqual(po_data[0]['transferred_qty'], 2)
self.assertEqual(po_data[1]['rm_item_code'], '_Test Item Home Desktop 100')
self.assertEqual(po_data[1]['p_qty'], 19)
self.assertEqual(po_data[1]['transferred_qty'], 1)
se.cancel()
po.cancel()
def transfer_subcontracted_raw_materials(po):
# Order of supplied items fetched in PO is flaky
transfer_qty_map = {
'_Test Item': 2,
'_Test Item Home Desktop 100': 1
}
item_1 = po.supplied_items[0].rm_item_code
item_2 = po.supplied_items[1].rm_item_code
rm_item = [
{
'name': po.supplied_items[0].name,
'item_code': '_Test Item Home Desktop 100',
'rm_item_code': '_Test Item Home Desktop 100',
'item_name': '_Test Item Home Desktop 100',
'qty': 2,
'item_code': item_1,
'rm_item_code': item_1,
'item_name': item_1,
'qty': transfer_qty_map[item_1],
'warehouse': '_Test Warehouse - _TC',
'rate': 100,
'amount': 200,
'amount': 100 * transfer_qty_map[item_1],
'stock_uom': 'Nos'
},
{
'name': po.supplied_items[1].name,
'item_code': '_Test Item',
'rm_item_code': '_Test Item',
'item_name': '_Test Item',
'qty': 1,
'item_code': item_2,
'rm_item_code': item_2,
'item_name': item_2,
'qty': transfer_qty_map[item_2],
'warehouse': '_Test Warehouse - _TC',
'rate': 100,
'amount': 100,
'amount': 100 * transfer_qty_map[item_2],
'stock_uom': 'Nos'
}
]