Skip to content

Commit 4c19450

Browse files
committed
Refactor progress
1 parent ec1aa8b commit 4c19450

2 files changed

Lines changed: 18 additions & 22 deletions

File tree

common/tests/test_block.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def test_block_to_mgmt():
4949
uuid = uuid4()
5050
data = _bytes_test_pattern(size)
5151
block = Block(uuid, data)
52-
management_json = block.to_mgmt()
53-
assert management_json == {
52+
block_mgmt = block.to_mgmt()
53+
assert block_mgmt == {
5454
"uuid": str(uuid),
5555
"size": 20,
5656
"data": bytes_to_str(data, truncate=True),

common/tests/test_fragment.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
from uuid import uuid4
66
from common.block import Block
77
from common.fragment import Fragment
8+
from common.utils import bytes_to_str
9+
10+
11+
# pylint: disable=missing-function-docstring
812

913

1014
def _bytes_test_pattern(size):
@@ -19,9 +23,6 @@ def _create_test_block(size):
1923

2024

2125
def test_fragment_init():
22-
"""
23-
Test initialization of a Fragment.
24-
"""
2526
block = _create_test_block(100)
2627
_fragment = Fragment(
2728
block=block,
@@ -31,18 +32,7 @@ def test_fragment_init():
3132
)
3233

3334

34-
def test_fragment_properties():
35-
"""
36-
Test Fragment properties.
37-
"""
38-
pass
39-
40-
4135
def test_fragment_allocate_full():
42-
"""
43-
Test Fragment allocation: requested bytes are fully available.
44-
(This also covers all the @property methods.)
45-
"""
4636
block = _create_test_block(100)
4737
fragment = Fragment.allocate(block, 10)
4838
assert fragment.block == block
@@ -52,9 +42,6 @@ def test_fragment_allocate_full():
5242

5343

5444
def test_fragment_allocate_partial():
55-
"""
56-
Test Fragment allocation: requested bytes are partially available.
57-
"""
5845
block = _create_test_block(5)
5946
fragment = Fragment.allocate(block, 10)
6047
assert fragment.block == block
@@ -64,13 +51,22 @@ def test_fragment_allocate_partial():
6451

6552

6653
def test_fragment_allocate_none():
67-
"""
68-
Test Fragment allocation: requested bytes are not available.
69-
"""
7054
block = _create_test_block(5)
7155
fragment = Fragment.allocate(block, 5)
7256
assert fragment.block == block
7357
assert fragment.start == 0
7458
assert fragment.size == 5
7559
assert fragment.data == bytes.fromhex("0001020304")
7660
assert Fragment.allocate(block, 5) is None
61+
62+
63+
def test_fragment_to_mgmt():
64+
block = _create_test_block(5)
65+
fragment = Fragment.allocate(block, 5)
66+
fragment_mgmt = fragment.to_mgmt()
67+
assert fragment_mgmt == {
68+
"block_uuid": str(block.uuid),
69+
"start": 0,
70+
"size": 5,
71+
"data": bytes_to_str(bytes.fromhex("0001020304")),
72+
}

0 commit comments

Comments
 (0)