| 1 |
import pytest |
| 2 |
|
| 3 |
from beets.util.units import human_bytes, human_seconds |
| 4 |
|
| 5 |
|
| 6 |
@pytest.mark.parametrize( |
| 7 |
"input_bytes,expected", |
| 8 |
[ |
| 9 |
(0, "0.0 B"), |
| 10 |
(30, "30.0 B"), |
| 11 |
(pow(2, 10), "1.0 KiB"), |
| 12 |
(pow(2, 20), "1.0 MiB"), |
| 13 |
(pow(2, 30), "1.0 GiB"), |
| 14 |
(pow(2, 40), "1.0 TiB"), |
| 15 |
(pow(2, 50), "1.0 PiB"), |
| 16 |
(pow(2, 60), "1.0 EiB"), |
| 17 |
(pow(2, 70), "1.0 ZiB"), |
| 18 |
(pow(2, 80), "1.0 YiB"), |
| 19 |
(pow(2, 90), "1.0 HiB"), |
| 20 |
(pow(2, 100), "big"), |
| 21 |
], |
| 22 |
) |
| 23 |
def test_human_bytes(input_bytes, expected): |
| 24 |
assert human_bytes(input_bytes) == expected |
| 25 |
|
| 26 |
|
| 27 |
@pytest.mark.parametrize( |
| 28 |
"input_seconds,expected", |
| 29 |
[ |
| 30 |
(0, "0.0 seconds"), |
| 31 |
(30, "30.0 seconds"), |
| 32 |
(60, "1.0 minutes"), |
| 33 |
(90, "1.5 minutes"), |
| 34 |
(125, "2.1 minutes"), |
| 35 |
(3600, "1.0 hours"), |
| 36 |
(86400, "1.0 days"), |
| 37 |
(604800, "1.0 weeks"), |
| 38 |
(31449600, "1.0 years"), |
| 39 |
(314496000, "1.0 decades"), |
| 40 |
], |
| 41 |
) |
| 42 |
def test_human_seconds(input_seconds, expected): |
| 43 |
assert human_seconds(input_seconds) == expected |