-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API - fix readable duration - fix #62
+ add some tests on user utils
- Loading branch information
Showing
3 changed files
with
58 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from typing import Union | ||
from uuid import uuid4 | ||
|
||
import pytest | ||
|
||
from fittrackee.users.utils import ( | ||
display_readable_file_size, | ||
get_readable_duration, | ||
) | ||
|
||
|
||
class TestDisplayReadableFileSize: | ||
@pytest.mark.parametrize( | ||
'size, expected_readable_size', | ||
[ | ||
(0, '0 bytes'), | ||
(1, '1 byte'), | ||
(100, '100.0 bytes'), | ||
(1024, '1.0KB'), | ||
(286773663, '273.5MB'), | ||
], | ||
) | ||
def test_it_returns_readable_file_size( | ||
self, size: Union[float, int], expected_readable_size: str | ||
) -> None: | ||
readable_file_size = display_readable_file_size(size) | ||
|
||
assert readable_file_size == expected_readable_size | ||
|
||
|
||
class TestReadableDuration: | ||
@pytest.mark.parametrize( | ||
'locale, expected_duration', | ||
[ | ||
('en', '30 seconds'), | ||
('fr', '30 secondes'), | ||
(None, '30 seconds'), | ||
(uuid4().hex, '30 seconds'), | ||
], | ||
) | ||
def test_it_returns_duration_in_locale( | ||
self, locale: str, expected_duration: str | ||
) -> None: | ||
readable_duration = get_readable_duration(30, locale) | ||
|
||
assert readable_duration == expected_duration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters