Exemple #1
0
 def test_overflow_into_skipped_allocation (self):
     allocation_1 = Mock([])
     allocation_1.amount_available = Mock([], return_value=0)
     allocation_2 = Mock([])
     allocation_2.amount_available = Mock([], return_value=1)
     amounts = distribute_amount([allocation_1, allocation_2], 2)
     assert_equal(set(amounts.items()), set([(allocation_1, 1), (allocation_2, 1)]))
Exemple #2
0
 def test_two_overflowing_allocations (self):
     allocation_1 = Mock([])
     allocation_1.amount_available = Mock([], return_value=1)
     allocation_2 = Mock([])
     allocation_2.amount_available = Mock([], return_value=1)
     amounts = distribute_amount([allocation_1, allocation_2], 3)
     assert_equal(set(amounts.items()), set([(allocation_1, 2), (allocation_2, 1)]))
Exemple #3
0
 def test_no_allocation (self):
     amounts = distribute_amount([], 1)
Exemple #4
0
 def test_one_overflowing_allocation (self):
     allocation = Mock([])
     allocation.amount_available = Mock([], return_value=1)
     amounts = distribute_amount([allocation], 2)
     assert_equal(set(amounts.items()), set([(allocation, 2)]))
Exemple #5
0
 def test_none (self):
     amounts = distribute_amount([], 0)
     assert_equal(amounts, {})