Skip to content

Commit 6fc73b4

Browse files
committed
Refactor progress
1 parent b059f02 commit 6fc73b4

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

common/tests/test_allocation.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,20 @@ def test_from_enc_str_bad_no_fragments():
196196
pool, _blocks = create_test_pool_and_blocks([10])
197197
with pytest.raises(InvalidEncodedFragment):
198198
_allocation = Allocation.from_enc_str("", pool)
199+
200+
201+
def test_from_enc_str_bad_fragment():
202+
"""
203+
Attempt to create an Allocation from a bad APIAllocation: one of the fragments has an invalid
204+
block UUID.
205+
"""
206+
pool, blocks = create_test_pool_and_blocks([10])
207+
# Bad block UUID
208+
with pytest.raises(InvalidBlockUUIDError):
209+
_allocation = Allocation.from_enc_str(f"not-a-uuid:0:5", pool)
210+
# Bad start index
211+
with pytest.raises(InvalidPSRDIndex):
212+
_allocation = Allocation.from_enc_str(f"{blocks[0].uuid}:20:5", pool)
213+
# Bad size
214+
with pytest.raises(InvalidPSRDIndex):
215+
_allocation = Allocation.from_enc_str(f"{blocks[0].uuid}:3:99999", pool)

0 commit comments

Comments
 (0)