From 742f73107538901013eea4241c879f19e72d4e5f Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Sun, 3 Nov 2024 12:07:13 +0000 Subject: [PATCH] add tests for track precision and invalid 'when' handling in gx.Track --- tests/gx_test.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/gx_test.py b/tests/gx_test.py index 462003fe..33c6f8bc 100644 --- a/tests/gx_test.py +++ b/tests/gx_test.py @@ -175,6 +175,35 @@ def test_track_from_track_items(self) -> None: assert "angles>" in track.to_string() assert ">0.0 0.0 0.0 None: + track = Track( + id="x", + target_id="y", + altitude_mode=None, + track_items=[ + TrackItem( + when=KmlDateTime( + dt=datetime.datetime(2010, 5, 28, 2, 2, 9, tzinfo=tzutc()), + ), + coord=geo.Point(-122.207881, 37.371915, 156.0), + angle=Angle(heading=45.54676, tilt=66.2342, roll=77.0), + ), + TrackItem( + when=KmlDateTime( + dt=datetime.datetime(2010, 5, 28, 2, 2, 35, tzinfo=tzutc()), + ), + coord=geo.Point(-122.205712, 37.373288, 152.0), + angle=Angle(heading=1.0, tilt=2.0, roll=3.0), + ), + ], + ) + + xml = track.to_string(precision=2) + assert "angles>45.55 66.23 77.001.00 2.00 3.00-122.21 37.37 156.00-122.21 37.37 152.00 None: doc = """ None: assert track.to_string() == expected_track.to_string() + def test_track_from_str_invalid_when(self) -> None: + doc = """ + + 2010-02-32T02:02:09Z + 45.54676 66.2342 77.0 + -122.207881 37.371915 156.000000 + + """ + + track = Track.from_string(doc, strict=False) + + assert track.track_items == [] + class TestMultiTrack(StdLibrary): """Test gx.MultiTrack."""