File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,10 +22,6 @@ def supplement_with(self, allocation):
2222 continue
2323 self [sku ] = quantity
2424
25- @property
26- def is_complete (self ):
27- return self .skus == self .order .skus
28-
2925 def apply (self ):
3026 for sku , source in self .items ():
3127 source [sku ] -= self .order [sku ]
@@ -37,18 +33,10 @@ class Order(dict):
3733 def skus (self ):
3834 return self .keys ()
3935
40- @property
41- def fully_allocated (self ):
42- return self .allocation .is_complete
43-
4436 def allocate (self , stock , shipments ):
4537 self .allocation = Allocation ({}, order = self )
4638 for source in [stock ] + sorted (shipments ):
4739 source_allocation = Allocation .for_ (self , source )
48- if source_allocation .is_complete :
49- self .allocation = source_allocation
50- self .allocation .apply ()
51- return
5240 self .allocation .supplement_with (source_allocation )
5341 self .allocation .apply ()
5442
Original file line number Diff line number Diff line change @@ -113,17 +113,6 @@ def test_can_allocate_to_both_preferring_stock():
113113 assert stock ['sku4' ] == 996
114114
115115
116- def test_mixed_allocation_are_avoided_if_possible ():
117- order = Order ({'sku1' : 10 , 'sku2' : 10 })
118- shipment = Shipment ({'sku1' : 1000 , 'sku2' : 1000 }, eta = tomorrow )
119- stock = Stock ({'sku1' : 1000 })
120-
121- order .allocate (stock , shipments = [shipment ])
122-
123- assert order .allocation ['sku1' ] == shipment
124- assert order .allocation ['sku2' ] == shipment
125-
126-
127116def test_allocated_to_earliest_suitable_shipment_in_list ():
128117 order = Order ({'sku1' : 10 , 'sku2' : 10 })
129118 shipment1 = Shipment ({'sku1' : 1000 , 'sku2' : 1000 }, eta = today )
You can’t perform that action at this time.
0 commit comments