Пример #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)]))
Пример #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)]))
Пример #3
0
 def test_no_allocation (self):
     amounts = distribute_amount([], 1)
Пример #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)]))
Пример #5
0
 def test_none (self):
     amounts = distribute_amount([], 0)
     assert_equal(amounts, {})