mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-02-04 08:33:45 +00:00
Fix test cases
This commit is contained in:
@@ -123,11 +123,9 @@ def readable_to_bytes(size_str: str) -> int:
|
||||
# If the string is purely numeric, assume it's in bytes
|
||||
return int(size_str)
|
||||
if not match:
|
||||
raise ValueError("Invalid size format. Expected format like '10MB', '1024GB', or '512'.")
|
||||
raise ValueError("Invalid size format for size_str. Expected format like '10MB', '1024GB', or '512'.")
|
||||
unit = ''.join(filter(str.isalpha, size_str)).strip()
|
||||
number = ''.join(c for c in size_str if c.isdigit() or c == '.').strip()
|
||||
if unit not in SIZE_UNITS:
|
||||
raise ValueError("Invalid input for size_str. Example: 1024GB")
|
||||
return int(float(number) * SIZE_UNITS[unit])
|
||||
|
||||
|
||||
|
||||
@@ -66,13 +66,13 @@ class TestReadableToBytes:
|
||||
assert readable_to_bytes(" 1 MB") == 1024**2
|
||||
|
||||
def test_invalid_unit(self):
|
||||
with pytest.raises(ValueError, match="Invalid input for size_str"):
|
||||
with pytest.raises(ValueError, match="Invalid size format for size_str"):
|
||||
readable_to_bytes("100X")
|
||||
readable_to_bytes("A100")
|
||||
readable_to_bytes("100$$$$$")
|
||||
|
||||
def test_invalid_number(self):
|
||||
with pytest.raises(ValueError, match="Invalid input for size_str"):
|
||||
with pytest.raises(ValueError, match="Invalid size format for size_str"):
|
||||
readable_to_bytes("ABC KB")
|
||||
|
||||
def test_missing_unit(self):
|
||||
|
||||
Reference in New Issue
Block a user