def test_inc_dec_block(self): block = [IPNetwork("10.11.12.0/24"), IPNetwork("2001:abcd:def0::/120"), IPNetwork("192.168.1.0")] handle = AllocationHandle("tst_id1") result = handle.increment_block(block[0], 20) assert_equal(result, 20) result = handle.decrement_block(block[0], 15) assert_equal(result, 5) assert_raises(AddressCountTooLow, handle.decrement_block, block[1], 1) result = handle.increment_block(block[1], 1) assert_equal(result, 1) result = handle.increment_block(block[2], 10) assert_equal(result, 10) result = handle.decrement_block(block[1], 1) assert_equal(result, 0) assert_false(str(block[1]) in handle.block) assert_raises(AddressCountTooLow, handle.decrement_block, block[2], 11) result = handle.decrement_block(block[2], 10) assert_equal(result, 0) assert_false(str(block[2]) in handle.block) result = handle.decrement_block(block[0], 5) assert_equal(result, 0) assert_false(str(block[0]) in handle.block)
def test_inc_dec_block(self): block = [ IPNetwork("10.11.12.0/24"), IPNetwork("2001:abcd:def0::/120"), IPNetwork("192.168.1.0") ] handle = AllocationHandle("tst_id1") result = handle.increment_block(block[0], 20) assert_equal(result, 20) result = handle.decrement_block(block[0], 15) assert_equal(result, 5) assert_raises(AddressCountTooLow, handle.decrement_block, block[1], 1) result = handle.increment_block(block[1], 1) assert_equal(result, 1) result = handle.increment_block(block[2], 10) assert_equal(result, 10) result = handle.decrement_block(block[1], 1) assert_equal(result, 0) assert_false(str(block[1]) in handle.block) assert_raises(AddressCountTooLow, handle.decrement_block, block[2], 11) result = handle.decrement_block(block[2], 10) assert_equal(result, 0) assert_false(str(block[2]) in handle.block) result = handle.decrement_block(block[0], 5) assert_equal(result, 0) assert_false(str(block[0]) in handle.block)