def test_OneOrder_ValidShipment_OneProviding_MultipleWarehouses(self): order = {'apple': 1} inventory_distribution = [{'name': 'owd', 'inventory': {'apple': 1}}, {'name': 'dm', 'inventory': {'apple': 3}} ] inventoryAlloc = InventoryAllocation(order, inventory_distribution) shipment = inventoryAlloc.shipment_validation() self.assertEqual(shipment, [{'owd': {'apple': 1}}])
def test_MultipleOrders_ValidShipment_MultipleProviding_MultipleWarehouses( self): order = {'apple': 1, 'orange': 2} inventory_distribution = [{ 'name': 'dm', 'inventory': { 'apple': 1, 'orange': 1 } }, { 'name': 'owd', 'inventory': { 'orange': 1 } }] shipment = InventoryAllocation.find_shipment(order, inventory_distribution) self.assertEqual(shipment, [{ 'dm': { 'apple': 1, 'orange': 1 } }, { 'owd': { 'orange': 1 } }])
class TestWarehouseFulFillment(unittest.TestCase): inv_allo = InventoryAllocation() def test_one(self): """ Only first warehouse needed """ warehouse_fulfillment_result = self.inv_allo.get_warehouse_fulfillment( order_one, model_warehouses) self.assertEqual(warehouse_fulfillment_result, warehouse_fulfillment_one) def test_two(self): """ First and second warehouse needed """ warehouse_fulfillment_result = self.inv_allo.get_warehouse_fulfillment( order_two, model_warehouses) self.assertEqual(warehouse_fulfillment_result, warehouse_fulfillment_two) def test_three(self): """ First, second, and fourth warehouse needed """ warehouse_fulfillment_result = self.inv_allo.get_warehouse_fulfillment( order_three, model_warehouses) self.assertEqual(warehouse_fulfillment_result, warehouse_fulfillment_three) def test_four(self): """ Only second warehouse needed """ warehouse_fulfillment_result = self.inv_allo.get_warehouse_fulfillment( order_four, model_warehouses) self.assertEqual(warehouse_fulfillment_result, warehouse_fulfillment_four) def test_five(self): """ Second and fourth warehouse needed """ warehouse_fulfillment_result = self.inv_allo.get_warehouse_fulfillment( order_five, model_warehouses) self.assertEqual(warehouse_fulfillment_result, warehouse_fulfillment_five) def test_six(self): """ Second and fourth warehouse needed """ warehouse_fulfillment_result = self.inv_allo.get_warehouse_fulfillment( order_six, model_warehouses) self.assertEqual(warehouse_fulfillment_result, warehouse_fulfillment_six)
def test_MultipleOrders_ValidShipment_OneProviding_OneWarehouse(self): order = {'apple': 1, 'orange': 2} inventory_distribution = [{'name': 'owd', 'inventory': {'apple': 1, 'orange': 2}}] inventoryAlloc = InventoryAllocation(order, inventory_distribution) shipment = inventoryAlloc.shipment_validation() self.assertEqual(shipment, [{'owd': {'apple': 1, 'orange': 2}}])
def test_OneOrder_InvalidShipment__OneProviding_OneWarehouse(self): order = {'apple': 1} inventory_distribution = [{'name': 'owd', 'inventory': {'apple': 0}}] inventoryAlloc = InventoryAllocation(order, inventory_distribution) shipment = inventoryAlloc.shipment_validation() self.assertEqual(shipment, [])
def test_NameInDistributionIsNonString_TypeError(self): order = {'apple': 1} inventory_distribution = [{'name': 1, 'inventory': {'apple': 1}}] inventoryAlloc = InventoryAllocation(order, inventory_distribution) with self.assertRaises(TypeError): inventoryAlloc.shipment_validation()
def test_InventoryAmountIsString_TypeError(self): order = {'apple': 1} inventory_distribution = [{'name': 'owd', 'inventory': {'apple': '1'}}] inventoryAlloc = InventoryAllocation(order, inventory_distribution) with self.assertRaises(TypeError): inventoryAlloc.shipment_validation()
def test_surplusInventory(self): order = {'apple': 1} inventory_distribution = [{'name': 'owd', 'inventory': {'apple': 10}}] inventoryAlloc = InventoryAllocation(order, inventory_distribution) shipment = inventoryAlloc.shipment_validation() self.assertEqual(shipment, [{'owd': {'apple': 1}}])
def test_OrderIsNotPresent(self): order = {'apple': 1, 'orange': 2} inventory_distribution = [{'name': 'owd', 'inventory': {'Banana': 1}}] inventoryAlloc = InventoryAllocation(order, inventory_distribution) shipment = inventoryAlloc.shipment_validation() self.assertEqual(shipment, [])
def test_NameInDistributionIsNonString_TypeError(self): order = {'apple': 1} inventory_distribution = [{'name': 1, 'inventory': {'apple': 1}}] with self.assertRaises(TypeError): InventoryAllocation.find_shipment(order, inventory_distribution)
def test_InventoryAmountIsString_TypeError(self): order = {'apple': 1} inventory_distribution = [{'name': 'owd', 'inventory': {'apple': '1'}}] with self.assertRaises(TypeError): InventoryAllocation.find_shipment(order, inventory_distribution)
def test_surplusInventory(self): order = {'apple': 1} inventory_distribution = [{'name': 'owd', 'inventory': {'apple': 10}}] shipment = InventoryAllocation.find_shipment(order, inventory_distribution) self.assertEqual(shipment, [{'owd': {'apple': 1}}])
def test_OneOrder_ValidShipment_OneProviding_OneWarehouse(self): order = {'apple': 1} inventory_distribution = [{'name': 'owd', 'inventory': {'apple': 1}}] shipment = InventoryAllocation.find_shipment(order, inventory_distribution) self.assertEqual(shipment, [{'owd': {'apple': 1}}])