diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/assets/MyTourbook_1.gpx.gz | bin | 0 -> 419294 bytes | |||
-rw-r--r-- | tests/assets/Teasi_1.gpx.gz | bin | 0 -> 808566 bytes | |||
-rw-r--r-- | tests/unit/test_util.py | 19 |
3 files changed, 19 insertions, 0 deletions
diff --git a/tests/assets/MyTourbook_1.gpx.gz b/tests/assets/MyTourbook_1.gpx.gz Binary files differnew file mode 100644 index 0000000..5751ef0 --- /dev/null +++ b/tests/assets/MyTourbook_1.gpx.gz diff --git a/tests/assets/Teasi_1.gpx.gz b/tests/assets/Teasi_1.gpx.gz Binary files differnew file mode 100644 index 0000000..d438bb4 --- /dev/null +++ b/tests/assets/Teasi_1.gpx.gz diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py index c595e4e..8f45611 100644 --- a/tests/unit/test_util.py +++ b/tests/unit/test_util.py @@ -1,6 +1,9 @@ +import gzip from datetime import timedelta +from pathlib import Path import pytest +import gpxpy from markupsafe import Markup from fietsboek import util @@ -52,6 +55,22 @@ def test_round_timedelta_to_multiple(delta, multiple, expected): assert util.round_timedelta_to_multiple(delta, multiple) == expected +@pytest.mark.parametrize('gpx_file, offset', [ + ("Teasi_1.gpx.gz", timedelta(hours=2)), + ("MyTourbook_1.gpx.gz", timedelta(hours=2)), +]) +def test_guess_gpx_timezone(gpx_file, offset): + asset_dir = Path(__file__).parent.parent / 'assets' + test_file = asset_dir / gpx_file + with gzip.open(test_file, 'rb') as fobj: + parsed_gpx = gpxpy.parse(fobj) + timezone = util.guess_gpx_timezone(parsed_gpx) + # Here we hope (and assume) that utcoffset is ignored. This is true for + # datetime.timezone objects, but may not be for other datetime.tzinfo + # instances. + assert timezone.utcoffset(None) == offset + + @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) |