Skip to content

Commit

Permalink
add test for handling invalid location in model
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Dec 1, 2024
1 parent 9177191 commit abcc0d9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_from_string(self) -> None:
)

model = fastkml.model.Model.from_string(doc)

assert model.altitude_mode == AltitudeMode.absolute
assert model.geometry == Point(
-123.115776547816,
Expand Down Expand Up @@ -95,6 +96,7 @@ def test_from_string_no_location(self) -> None:
)

model = fastkml.model.Model.from_string(doc)

assert model.altitude_mode == AltitudeMode.absolute
assert model.geometry is None
assert not model
Expand All @@ -120,10 +122,27 @@ def test_from_string_invalid_location(self) -> None:
)

model = fastkml.model.Model.from_string(doc)

assert model.altitude_mode == AltitudeMode.absolute
assert model.geometry is None
assert not model

def test_location_from_string_invalid_location(self) -> None:
doc = (
'<Location xmlns="http://www.opengis.net/kml/2.2">'
"<longitude></longitude>"
"<latitude>49.279804095564</latitude>"
"<altitude>21.614010375743</altitude>"
"</Location>"
)

location = fastkml.model.Location.from_string(doc)

assert location.altitude == 21.614010375743
assert location.latitude == 49.279804095564
assert location.geometry is None
assert not location


class TestModelLxml(TestModel, Lxml):
pass

0 comments on commit abcc0d9

Please sign in to comment.