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_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, [])