File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,6 +49,20 @@ def uuid(self):
4949 """
5050 return self ._block_uuid
5151
52+ @property
53+ def size (self ):
54+ """
55+ The size of the block in bytes.
56+ """
57+ return self ._size
58+
59+ @property
60+ def data (self ):
61+ """
62+ The data of the block.
63+ """
64+ return self ._data
65+
5266 @property
5367 def nr_used_bytes (self ):
5468 """
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ def test_properties():
4444 data = _bytes_test_pattern (size )
4545 block = Block (uuid , data )
4646 assert block .uuid == uuid
47+ assert block .size == size
48+ assert block .data == data
4749 assert block .nr_unused_bytes == size
4850
4951
Original file line number Diff line number Diff line change 66from typing import List
77from common .pool import Pool
88from common .block import Block
9+ from common .utils import bytes_to_str
910
1011
1112def _bytes_test_pattern (size ):
@@ -52,3 +53,24 @@ def test_nr_unused_bytes():
5253 assert pool .nr_unused_bytes == 60
5354 _allocation = pool .allocate (10 , purpose = "test" )
5455 assert pool .nr_unused_bytes == 50
56+
57+
58+ def test_to_mgmt ():
59+ """
60+ Get the management status.
61+ """
62+ pool , blocks = _create_test_pool_and_block ([10 , 20 ])
63+ pool_mgmt = pool .to_mgmt ()
64+ assert pool_mgmt == {
65+ "blocks" : [
66+ {
67+ "uuid" : str (block .uuid ),
68+ "size" : block .size ,
69+ "data" : bytes_to_str (block .data , truncate = True ),
70+ "nr_used_bytes" : block .nr_used_bytes ,
71+ "nr_unused_bytes" : block .nr_unused_bytes ,
72+ }
73+ for block in blocks
74+ ],
75+ "owner" : str (pool .owner ),
76+ }
You can’t perform that action at this time.
0 commit comments