From 114274f900904070e941c4a544426b5d9d1267d2 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Fri, 31 Mar 2023 23:57:59 +0200 Subject: hide ugliness of tile url function We basically do the same hacky trick in two different places, so maybe we should put it into a separate function, test it, and if a better implementation arises, swap it. --- tests/unit/test_util.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/unit') diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py index b35f218..949acb5 100644 --- a/tests/unit/test_util.py +++ b/tests/unit/test_util.py @@ -82,3 +82,12 @@ def test_tour_metadata(gpx_file): @pytest.mark.parametrize('mps, kph', [(1, 3.6), (10, 36)]) def test_mps_to_kph(mps, kph): assert util.mps_to_kph(mps) == pytest.approx(kph, 0.1) + + +def test_tile_url(app_request): + route_url = util.tile_url(app_request, "tile-proxy", provider="bobby") + + assert "{x}" in route_url + assert "{y}" in route_url + assert "{z}" in route_url + assert "bobby" in route_url -- cgit v1.2.3 From 982d6c8cd5ba6ade04683e5699fc9fc170e4c109 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 1 Apr 2023 13:05:40 +0200 Subject: fix round_to_multiple for second-level accuracy It was ovious that this is broken when you try to round "0s" to second-level granularity, and you end up with "1s". The problem comes from the fact that we use the integer divison when checking whether we should round up or down, but then also use strict inequality. To fix this, we now also round down if the second_offset is equal to the halfway point (which in the case of second-level granularity is 0). --- tests/unit/test_util.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/unit') diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py index 949acb5..0ac5c33 100644 --- a/tests/unit/test_util.py +++ b/tests/unit/test_util.py @@ -29,6 +29,11 @@ def test_fix_iso_timestamp(timestamp, fixed): @pytest.mark.parametrize('delta, multiple, expected', [ + ( + timedelta(seconds=0), + timedelta(seconds=1), + timedelta(seconds=0), + ), ( timedelta(minutes=42), timedelta(minutes=15), -- cgit v1.2.3