Пример #1
0
 def test_no_allocations(self):
     order = {'apple': 1}
     warehouses = [{'name': 'owd', 'inventory': {'apple': 0}}]
     inv_alloc = InventoryAllocator(order, warehouses)
     actual = inv_alloc.find_cheapest_shipment_option()
     expected = []
     self.assertEqual(actual, expected,
                      'SOMETHING IS WRONG IN: no allocations')
Пример #2
0
 def test_split_case(self):
     order = {'apple': 10}
     warehouses = [{
         'name': 'owd',
         'inventory': {
             'apple': 5
         }
     }, {
         'name': 'dm',
         'inventory': {
             'apple': 5
         }
     }]
     inv_alloc = InventoryAllocator(order, warehouses)
     actual = inv_alloc.find_cheapest_shipment_option()
     expected = [{'owd': {'apple': 5}}, {'dm': {'apple': 5}}]
     self.assertEqual(actual, expected, 'SOMETHING IS WRONG IN: split case')
Пример #3
0
 def test_sufficient_second_wh(self):
     order = {'apple': 10}
     warehouses = [{
         'name': 'owd',
         'inventory': {
             'apple': 0
         }
     }, {
         'name': 'dm',
         'inventory': {
             'apple': 51337
         }
     }]
     inv_alloc = InventoryAllocator(order, warehouses)
     actual = inv_alloc.find_cheapest_shipment_option()
     expected = [{'dm': {'apple': 10}}]
     self.assertEqual(actual, expected,
                      'SOMETHING IS WRONG IN: sufficient second wh')
Пример #4
0
 def test_all_insufficient(self):
     order = {'apple': 10}
     warehouses = [{
         'name': 'owd',
         'inventory': {
             'apple': 4
         }
     }, {
         'name': 'dm',
         'inventory': {
             'apple': 4
         }
     }]
     inv_alloc = InventoryAllocator(order, warehouses)
     actual = inv_alloc.find_cheapest_shipment_option()
     expected = []
     self.assertEqual(actual, expected,
                      'SOMETHING IS WRONG IN: all sufficient')