aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-04-01 13:05:40 +0200
committerDaniel Schadt <kingdread@gmx.de>2023-04-01 13:05:40 +0200
commit982d6c8cd5ba6ade04683e5699fc9fc170e4c109 (patch)
tree5387fc190042e57fd319aa4cb03907013c1e0c09 /tests
parented0200a14a6bc54c25b2a82fd2fc9ed62f04ac94 (diff)
downloadfietsboek-982d6c8cd5ba6ade04683e5699fc9fc170e4c109.tar.gz
fietsboek-982d6c8cd5ba6ade04683e5699fc9fc170e4c109.tar.bz2
fietsboek-982d6c8cd5ba6ade04683e5699fc9fc170e4c109.zip
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).
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_util.py5
1 files changed, 5 insertions, 0 deletions
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
@@ -30,6 +30,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),
timedelta(minutes=45),