Skip to content

Commit

Permalink
Ignore flake8 violation in docs, add test case for track
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Feb 6, 2024
1 parent d33a0af commit 55bf2c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 1 addition & 3 deletions fastkml/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ def __str__(self) -> str:
if isinstance(self.dt, datetime)
else self.dt.isoformat()
)
if self.resolution == DateTimeResolution.datetime:
return self.dt.isoformat()
raise ValueError
return self.dt.isoformat()

@classmethod
def parse(cls, datestr: str) -> Optional["KmlDateTime"]:
Expand Down
13 changes: 13 additions & 0 deletions tests/gx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import datetime

import pygeoif.geometry as geo
import pytest
from dateutil.tz import tzutc

from fastkml.enums import AltitudeMode
Expand Down Expand Up @@ -204,6 +205,18 @@ def test_track_from_track_items(self) -> None:
assert "angles>" in track.to_string()
assert ">0.0 0.0 0.0</" in track.to_string()

def test_track_from_track_items_and_geometry(self) -> None:
ls = geo.LineString(((1, 2), (2, 0)))
time1 = datetime.datetime(2023, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc)
angle = Angle()
track_items = [TrackItem(when=time1, coord=geo.Point(1, 2), angle=angle)]

with pytest.raises(ValueError):
Track(
track_items=track_items,
geometry=ls,
)

def test_track_from_track_items_no_coord(self) -> None:
time1 = datetime.datetime(2023, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc)
angle = Angle()
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ per-file-ignores =
fastkml/gx.py: LIT002
fastkml/views.py: LIT002
fastkml/registry.py: E704
docs/conf.py: E402
enable-extensions=G
literal_inline_quotes = double
literal_multiline_quotes = double

0 comments on commit 55bf2c5

Please sign in to comment.