Beispiel #1
0
 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}}])
Beispiel #2
0
 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}}])
Beispiel #3
0
 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, [])
Beispiel #4
0
 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()
Beispiel #5
0
 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()
Beispiel #6
0
 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}}])
Beispiel #7
0
 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, [])