-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
777b95a
commit 85b8877
Showing
1 changed file
with
29 additions
and
0 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,29 @@ | ||
from ...units import bytes_per_seconds_fmt, items_per_seconds_fmt, formatter_for_unit | ||
|
||
|
||
def test_items_per_seconds_fmt(): | ||
assert items_per_seconds_fmt(None, "i/s") is None | ||
assert items_per_seconds_fmt(0, "i/s") == "0 i/s" | ||
assert items_per_seconds_fmt(1, "i/s") == "1 i/s" | ||
assert items_per_seconds_fmt(1000, "i/s") == "1.000K i/s" | ||
assert items_per_seconds_fmt(1000000, "i/s") == "1.000M i/s" | ||
assert items_per_seconds_fmt(1000000000, "i/s") == "1.000G i/s" | ||
|
||
|
||
def test_bytes_per_seconds_fmt(): | ||
assert bytes_per_seconds_fmt(None, "B/s") is None | ||
assert bytes_per_seconds_fmt(0, "B/s") == "0 B/s" | ||
assert bytes_per_seconds_fmt(1, "B/s") == "1 B/s" | ||
assert bytes_per_seconds_fmt(1024, "B/s") == "1.000 KiB/s" | ||
assert bytes_per_seconds_fmt(1048576, "B/s") == "1.000 MiB/s" | ||
assert bytes_per_seconds_fmt(1073741824, "B/s") == "1.000 GiB/s" | ||
assert bytes_per_seconds_fmt(1099511627776, "B/s") == "1.000 TiB/s" | ||
|
||
|
||
def test_formatter_for_unit(): | ||
assert formatter_for_unit("B/s")(None, "B/s") is None | ||
assert formatter_for_unit("i/s")(None, "i/s") is None | ||
assert formatter_for_unit("s")(None, "s") is None | ||
assert formatter_for_unit("B/s")(1024, "B/s") == "1.000 KiB/s" | ||
assert formatter_for_unit("i/s")(1024, "i/s") == "1.024K i/s" | ||
assert formatter_for_unit("s")(1024, "s") == "1024.000 s" |