Skip to content

Commit

Permalink
Fix namespaces gx.py and views.py, unskip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Dec 2, 2023
1 parent 426354a commit d30f680
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion fastkml/gx.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,16 @@ def _get_kwargs(
element=element,
strict=strict,
)
name_spaces = kwargs["name_spaces"]
assert name_spaces is not None
kwargs["interpolate"] = cls._get_interpolate(
ns=ns,
name_spaces=name_spaces,
element=element,
strict=strict,
)
kwargs["tracks"] = cls._get_track_kwargs_from_element(
ns=kwargs["name_spaces"].get("gx", ""),
ns=name_spaces["gx"],
name_spaces=name_spaces,
element=element,
strict=strict,
Expand Down
4 changes: 3 additions & 1 deletion fastkml/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ def _get_kwargs(
element=element,
strict=strict,
)
name_spaces = kwargs["name_spaces"]
assert name_spaces is not None
longitude = element.find(f"{ns}longitude")
if longitude is not None:
kwargs["longitude"] = float(longitude.text)
Expand All @@ -256,7 +258,7 @@ def _get_kwargs(
kwargs["tilt"] = float(tilt.text)
altitude_mode = element.find(f"{ns}altitudeMode")
if altitude_mode is None:
altitude_mode = element.find(f"{kwargs['name_spaces']['gx']}altitudeMode")
altitude_mode = element.find(f"{name_spaces['gx']}altitudeMode")
if altitude_mode is not None:
kwargs["altitude_mode"] = AltitudeMode(altitude_mode.text)
timespan = element.find(f"{ns}TimeSpan")
Expand Down
8 changes: 3 additions & 5 deletions tests/times_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,27 +236,25 @@ def test_feature_timestamp(self) -> None:
f._times = None
assert "TimeStamp>" not in str(f.to_string())

@pytest.mark.skip(reason="not yet implemented")
def test_feature_timespan(self) -> None:
now = datetime.datetime.now()
y2k = datetime.datetime(2000, 1, 1)
f = kml.Document()
f.begin = KmlDateTime(y2k)
f.end = KmlDateTime(now)
f._times = kml.TimeSpan(begin=KmlDateTime(y2k), end=KmlDateTime(now))
assert f.begin == KmlDateTime(y2k)
assert f.end == KmlDateTime(now)
assert now.isoformat() in str(f.to_string())
assert "2000-01-01" in str(f.to_string())
assert "TimeSpan>" in str(f.to_string())
assert "begin>" in str(f.to_string())
assert "end>" in str(f.to_string())
f.end = None
f._times = kml.TimeSpan(begin=KmlDateTime(y2k))
assert now.isoformat() not in str(f.to_string())
assert "2000-01-01" in str(f.to_string())
assert "TimeSpan>" in str(f.to_string())
assert "begin>" in str(f.to_string())
assert "end>" not in str(f.to_string())
f.begin = None
f._times = None
assert "TimeSpan>" not in str(f.to_string())

def test_read_timestamp_year(self) -> None:
Expand Down

0 comments on commit d30f680

Please sign in to comment.