示例#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}}])
 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
         }
     }])
示例#3
0
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)
示例#4
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}}])
示例#5
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, [])
示例#6
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()
示例#7
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()
示例#8
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}}])
示例#9
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, [])
 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}}])