Skip to content

Commit b51cdcc

Browse files
committed
Refactor progress
1 parent f27862b commit b51cdcc

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

common/tests/test_allocation.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from common.allocation import Allocation
6-
from common.fragment import Fragment
6+
from common.fragment import APIFragment, Fragment
77
from common.utils import bytes_to_str
88
from .unit_test_common import create_test_block, create_test_pool_and_blocks
99

@@ -67,3 +67,16 @@ def test_to_mgmt():
6767
},
6868
],
6969
}
70+
71+
72+
def test_to_api():
73+
"""
74+
Create an APIAllocation for an Allocation.
75+
"""
76+
pool, blocks = create_test_pool_and_blocks([5, 10])
77+
allocation = pool.allocate(8, purpose="test")
78+
api_allocation = allocation.to_api()
79+
assert api_allocation.fragments == [
80+
APIFragment(block_uuid=str(blocks[0].uuid), start=0, size=5),
81+
APIFragment(block_uuid=str(blocks[1].uuid), start=0, size=3),
82+
]

0 commit comments

Comments
 (0)