修复:统一超长批次标识错误
This commit is contained in:
@@ -16,7 +16,10 @@ def parse_optional_positive_batch_id(raw: str | None) -> int | None:
|
|||||||
return None
|
return None
|
||||||
if not isinstance(raw, str) or not raw or not raw.isascii() or not raw.isdigit():
|
if not isinstance(raw, str) or not raw or not raw.isascii() or not raw.isdigit():
|
||||||
raise ServiceWarning('', '测试批次标识必须为正整数')
|
raise ServiceWarning('', '测试批次标识必须为正整数')
|
||||||
batch_id = int(raw)
|
try:
|
||||||
|
batch_id = int(raw)
|
||||||
|
except ValueError:
|
||||||
|
raise ServiceWarning('', '测试批次标识必须为正整数') from None
|
||||||
if batch_id <= 0:
|
if batch_id <= 0:
|
||||||
raise ServiceWarning('', '测试批次标识必须为正整数')
|
raise ServiceWarning('', '测试批次标识必须为正整数')
|
||||||
return batch_id
|
return batch_id
|
||||||
|
|||||||
@@ -87,6 +87,10 @@ class TestBatchHeaderTest(unittest.TestCase):
|
|||||||
with self.subTest(raw=raw), self.assertRaisesRegex(ServiceWarning, '测试批次标识必须为正整数'):
|
with self.subTest(raw=raw), self.assertRaisesRegex(ServiceWarning, '测试批次标识必须为正整数'):
|
||||||
parse_optional_positive_batch_id(raw)
|
parse_optional_positive_batch_id(raw)
|
||||||
|
|
||||||
|
def test_overlong_ascii_decimal_is_mapped_to_service_warning(self) -> None:
|
||||||
|
with self.assertRaisesRegex(ServiceWarning, '测试批次标识必须为正整数'):
|
||||||
|
parse_optional_positive_batch_id('9' * 5000)
|
||||||
|
|
||||||
|
|
||||||
class TestBatchAccessTest(unittest.IsolatedAsyncioTestCase):
|
class TestBatchAccessTest(unittest.IsolatedAsyncioTestCase):
|
||||||
async def asyncSetUp(self) -> None:
|
async def asyncSetUp(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user