aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-05-25 21:22:42 +0200
committerDaniel Schadt <kingdread@gmx.de>2023-05-25 21:22:42 +0200
commitfb3eabd184cd5b75653d7cb1e0fe3a1ac4b748e3 (patch)
tree7183f06bf835bc63a98b5c247fa8d783a9bbcec8 /tests/unit
parente1aa29d92094aafe5109c9fb42e9146bc25ce380 (diff)
parent8160c375f448f4e6e32518d632e3bc0d139f0130 (diff)
downloadfietsboek-fb3eabd184cd5b75653d7cb1e0fe3a1ac4b748e3.tar.gz
fietsboek-fb3eabd184cd5b75653d7cb1e0fe3a1ac4b748e3.tar.bz2
fietsboek-fb3eabd184cd5b75653d7cb1e0fe3a1ac4b748e3.zip
Merge branch 'fietsctl-commands'
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test_util.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py
index 1a56911..6dc8e7d 100644
--- a/tests/unit/test_util.py
+++ b/tests/unit/test_util.py
@@ -88,6 +88,22 @@ def test_tour_metadata(gpx_file):
def test_mps_to_kph(mps, kph):
assert util.mps_to_kph(mps) == pytest.approx(kph, 0.1)
+@pytest.mark.parametrize('num_bytes, expected', [
+ (1, '1 B'),
+ (1023, '1023 B'),
+ (1024, '1.0 KiB'),
+ (1536, '1.5 KiB'),
+ (1024 ** 2, '1.0 MiB'),
+ (1024 ** 3, '1.0 GiB'),
+ (0, '0 B'),
+ # Negative sizes in itself are a bit weird, but they make sense as the
+ # difference between two size values, so they should still work.
+ (-1, '-1 B'),
+ (-1024, '-1.0 KiB'),
+])
+def test_human_size(num_bytes, expected):
+ assert util.human_size(num_bytes) == expected
+
def test_tile_url(app_request):
route_url = util.tile_url(app_request, "tile-proxy", provider="bobby")