Skip to content

Commit 16bb8e5

Browse files
committed
Consistent exception naming
1 parent 1989556 commit 16bb8e5

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

common/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def __init__(self):
314314
)
315315

316316

317-
class InvalidEncodedFragment(DSKEException):
317+
class InvalidEncodedFragmentError(DSKEException):
318318
"""
319319
Exception raised when trying to parse an encoded fragment string that is invalid.
320320
"""
@@ -327,7 +327,7 @@ def __init__(self, encoded_fragment: str):
327327
)
328328

329329

330-
class InvalidEncodedSignature(DSKEException):
330+
class InvalidEncodedSignatureError(DSKEException):
331331
"""
332332
Exception raised when trying to parse an encoded signature string that is invalid.
333333
"""

common/fragment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from uuid import UUID
66
import pydantic
7-
from common.exceptions import InvalidBlockUUIDError, InvalidEncodedFragment
7+
from common.exceptions import InvalidBlockUUIDError, InvalidEncodedFragmentError
88
from . import utils
99

1010

@@ -135,7 +135,7 @@ def from_enc_str(
135135
"""
136136
parts = enc_str.split(":")
137137
if len(parts) != 3:
138-
raise InvalidEncodedFragment(encoded_fragment=enc_str)
138+
raise InvalidEncodedFragmentError(encoded_fragment=enc_str)
139139
block_uuid_str, start_byte_str, size_str = parts
140140
try:
141141
block_uuid = UUID(block_uuid_str)
@@ -145,10 +145,10 @@ def from_enc_str(
145145
try:
146146
start = int(start_byte_str)
147147
except ValueError as exc:
148-
raise InvalidEncodedFragment(encoded_fragment=enc_str) from exc
148+
raise InvalidEncodedFragmentError(encoded_fragment=enc_str) from exc
149149
try:
150150
size = int(size_str)
151151
except ValueError as exc:
152-
raise InvalidEncodedFragment(encoded_fragment=enc_str) from exc
152+
raise InvalidEncodedFragmentError(encoded_fragment=enc_str) from exc
153153
data = block.take_data(start, size)
154154
return Fragment(block=block, start=start, size=size, data=data)

common/tests/test_allocation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from common.allocation import Allocation, APIAllocation
77
from common.exceptions import (
88
InvalidBlockUUIDError,
9-
InvalidEncodedFragment,
9+
InvalidEncodedFragmentError,
1010
InvalidPSRDIndex,
1111
)
1212
from common.fragment import APIFragment, Fragment
@@ -194,7 +194,7 @@ def test_from_enc_str_bad_no_fragments():
194194
Attempt to create an Allocation from a bad encoded string (no fragments).
195195
"""
196196
pool, _blocks = create_test_pool_and_blocks([10])
197-
with pytest.raises(InvalidEncodedFragment):
197+
with pytest.raises(InvalidEncodedFragmentError):
198198
_allocation = Allocation.from_enc_str("", pool)
199199

200200

common/tests/test_fragment.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from uuid import uuid4
66
import pytest
7-
from common.exceptions import InvalidBlockUUIDError, InvalidEncodedFragment
7+
from common.exceptions import InvalidBlockUUIDError, InvalidEncodedFragmentError
88
from common.fragment import APIFragment, Fragment
99
from common.utils import bytes_to_str
1010
from .unit_test_common import create_test_block, create_test_pool_and_blocks
@@ -151,16 +151,16 @@ def test_from_enc_str_bad_str():
151151
# pylint: disable=protected-access
152152
(pool, blocks) = create_test_pool_and_blocks([10])
153153
# No colons
154-
with pytest.raises(InvalidEncodedFragment):
154+
with pytest.raises(InvalidEncodedFragmentError):
155155
_fragment = Fragment.from_enc_str("not-an-encoded-str", pool)
156156
# Only one colon
157-
with pytest.raises(InvalidEncodedFragment):
157+
with pytest.raises(InvalidEncodedFragmentError):
158158
_fragment = Fragment.from_enc_str(f"{blocks[0].uuid}:only-one-colon", pool)
159159
# Start is not a number
160-
with pytest.raises(InvalidEncodedFragment):
160+
with pytest.raises(InvalidEncodedFragmentError):
161161
_fragment = Fragment.from_enc_str(f"{blocks[0].uuid}:not-a-number:5", pool)
162162
# Size is not a number
163-
with pytest.raises(InvalidEncodedFragment):
163+
with pytest.raises(InvalidEncodedFragmentError):
164164
_fragment = Fragment.from_enc_str(f"{blocks[0].uuid}:0:not-a-number", pool)
165165

166166

0 commit comments

Comments
 (0)