Beispiel #1
0
 def test_1_item_1_warehouse(self):
     order = {"apple": 1}
     warehouse1 = Warehouse(
         json.loads('{ "name": "owd", "inventory": { "apple": 1 } }'))
     warehouses = [warehouse1]
     actual = find_combo(order, warehouses)
     expected_owd = Warehouse(
         json.loads('{ "name": "owd", "inventory": { "apple": 1 } }'))
     expected = [expected_owd]
     self.assertEqual(expected, actual)
Beispiel #2
0
 def test_1_item_multiple_warehouses_1_needed_1_zero(self):
     order = {'apple': 3}
     warehouse1 = Warehouse(
         json.loads('{ "name": "owd", "inventory": { "apple": 0 } }'))
     warehouse2 = Warehouse(
         json.loads('{ "name": "dm", "inventory": { "apple": 7 } }'))
     warehouses = [warehouse1, warehouse2]
     actual = find_combo(order, warehouses)
     expected_dm = Warehouse(
         json.loads('{ "name": "dm", "inventory": { "apple": 3 } }'))
     expected = [expected_dm]
     self.assertEqual(expected, actual)
Beispiel #3
0
 def test_1_item_not_enough(self):
     order = {'apple': 1}
     warehouse1 = Warehouse(
         json.loads('{ "name": "owd", "inventory": { "apple": 0 } }'))
     warehouses = [warehouse1]
     actual = find_combo(order, warehouses)
     expected = []
     self.assertEqual(expected, actual)
Beispiel #4
0
 def test_multiple_item_multiple_warehouses(self):
     order = {'apple': 10, 'banana': 5, 'orange': 100}
     warehouse1 = Warehouse(
         json.loads(
             '{ "name": "owd", "inventory": { "apple": 5, "orange": 50 } }')
     )
     warehouse2 = Warehouse(
         json.loads('{ "name": "dm", "inventory": { "banana": 5 } }'))
     warehouse3 = Warehouse(
         json.loads(
             '{ "name": "afd", "inventory": { "apple": 5, "banana": 100, "orange": 50 } }'
         ))
     warehouses = [warehouse1, warehouse2, warehouse3]
     actual = find_combo(order, warehouses)
     expected_owd = Warehouse(
         json.loads(
             '{ "name": "owd", "inventory": { "apple": 5, "orange": 50 } }')
     )
     expected_dm = Warehouse(
         json.loads('{ "name": "dm", "inventory": { "banana": 5 } }'))
     expected_afd = Warehouse(
         json.loads(
             '{ "name": "afd", "inventory": { "apple": 5, "orange": 50 } }')
     )
     expected = [expected_owd, expected_dm, expected_afd]
     self.assertEqual(expected, actual)