(allocator: BlockAllocator)
| 14 | |
| 15 | |
| 16 | def test_basic_allocation(allocator: BlockAllocator): |
| 17 | allocator.sanity_checks() |
| 18 | |
| 19 | input_ids1 = [1] * 16 |
| 20 | input_ids2 = [2] * 9 |
| 21 | input_ids3 = [3] * 8 |
| 22 | |
| 23 | allocator.sanity_checks() |
| 24 | |
| 25 | kvs1, num_cached1 = allocator.allocate_with_prefix_match("seq1", input_ids1) |
| 26 | allocator.sanity_checks() |
| 27 | |
| 28 | assert num_cached1 == 0 |
| 29 | assert len(kvs1) == math.ceil(len(input_ids1) / PAGE_SIZE) |
| 30 | |
| 31 | kvs2, num_cached2 = allocator.allocate_with_prefix_match("seq2", input_ids2) |
| 32 | allocator.sanity_checks() |
| 33 | |
| 34 | assert num_cached2 == 0 |
| 35 | assert len(kvs2) == math.ceil(len(input_ids2) / PAGE_SIZE) |
| 36 | |
| 37 | with pytest.raises(NoSpaceException): |
| 38 | allocator.allocate_with_prefix_match("seq3", input_ids3) |
| 39 | |
| 40 | |
| 41 | def test_basic_caching(allocator: BlockAllocator): |
nothing calls this directly
no test coverage detected