Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Stoops committed Dec 9, 2024
1 parent 4710726 commit 755d2ee
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
32 changes: 28 additions & 4 deletions tests/test_packet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ast
import datetime as dt
from uuid import UUID

import pytest
Expand Down Expand Up @@ -28,7 +29,12 @@
PositionList,
SolidColorMaterial,
)
from czml3.types import Cartesian3Value, Sequence, StringValue
from czml3.types import (
Cartesian3Value,
StringValue,
TimeInterval,
TimeIntervalCollection,
)


def test_preamble_has_proper_id_and_expected_version():
Expand Down Expand Up @@ -212,7 +218,7 @@ def test_packet_dynamic_cartesian_position():
}"""
packet = Packet(
id="InternationalSpaceStation",
position=PositionList(
position=Position(
interpolationAlgorithm=InterpolationAlgorithms.LAGRANGE,
referenceFrame=ReferenceFrames.INERTIAL,
cartesian=[
Expand Down Expand Up @@ -621,7 +627,25 @@ def test_different_IDs():


def test_different_availabilities():
p1 = Packet(availability=Sequence(values=[1, 2, 3]))
p2 = Packet(availability=Sequence(values=[2, 3, 4]))
p1 = Packet(
availability=TimeIntervalCollection(
values=[
TimeInterval(
start=dt.datetime(2019, 3, 20, 12, tzinfo=dt.timezone.utc),
end=dt.datetime(2019, 4, 20, 12, tzinfo=dt.timezone.utc),
)
]
)
)
p2 = Packet(
availability=TimeIntervalCollection(
values=[
TimeInterval(
start=dt.datetime(2019, 3, 20, 12, tzinfo=dt.timezone.utc),
end=dt.datetime(2020, 4, 20, 12, tzinfo=dt.timezone.utc),
)
]
)
)
assert p1 != p2
assert str(p1) != str(p2)
24 changes: 13 additions & 11 deletions tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@
ViewFrom,
)
from czml3.types import (
CartographicDegreesListOfListsValue,
CartographicRadiansListOfListsValue,
Cartesian2Value,
Cartesian3ListOfListsValue,
CartographicRadiansListValue,
Cartesian3ListValue,
ReferenceListOfListsValue,
ReferenceListValue,
Cartesian2Value,
Cartesian3Value,
CartographicDegreesListOfListsValue,
CartographicDegreesListValue,
CartographicRadiansListOfListsValue,
CartographicRadiansListValue,
DistanceDisplayConditionValue,
IntervalValue,
NearFarScalarValue,
Sequence,
ReferenceListOfListsValue,
ReferenceListValue,
TimeInterval,
TimeIntervalCollection,
UnitQuaternionValue,
format_datetime_like,
)
Expand Down Expand Up @@ -740,7 +740,7 @@ def test_multiple_interval_value():
end0 = start1 = dt.datetime(2019, 1, 2, tzinfo=dt.timezone.utc)
end1 = dt.datetime(2019, 1, 3, tzinfo=dt.timezone.utc)

prop = Sequence(
prop = TimeIntervalCollection(
values=[
IntervalValue(start=start0, end=end0, value=True),
IntervalValue(start=start1, end=end1, value=False),
Expand All @@ -766,7 +766,7 @@ def test_multiple_interval_decimal_value():
end0 = start1 = dt.datetime(2019, 1, 2, 1, 2, 3, 456789, tzinfo=dt.timezone.utc)
end1 = dt.datetime(2019, 1, 3, 1, 2, 3, 456789, tzinfo=dt.timezone.utc)

prop = Sequence(
prop = TimeIntervalCollection(
values=[
IntervalValue(start=start0, end=end0, value=True),
IntervalValue(start=start1, end=end1, value=False),
Expand Down Expand Up @@ -1347,7 +1347,7 @@ def test_no_values():

def test_SequenceTime_mix():
with pytest.raises(ValidationError):
Sequence(
TimeIntervalCollection(
values=[ # type: ignore
TimeInterval(
start=dt.datetime(2019, 3, 20, 12, tzinfo=dt.timezone.utc),
Expand Down Expand Up @@ -1573,5 +1573,7 @@ def test_position_list_of_lists_with_bad_references():
cartographicDegrees=CartographicDegreesListOfListsValue(
values=[[20, 30, 10], [20, 30, 10]]
),
references=ReferenceListOfListsValue(values=[["1#this"], ["1#this", "2#this"]]),
references=ReferenceListOfListsValue(
values=[["1#this"], ["1#this", "2#this"]]
),
)
10 changes: 1 addition & 9 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
IntervalValue,
NearFarScalarValue,
NumberValue,
ReferenceListValue,
ReferenceListOfListsValue,
ReferenceListValue,
ReferenceValue,
RgbafValue,
RgbaValue,
Expand Down Expand Up @@ -94,16 +94,12 @@ def test_bad_cartesian3_raises_error(values):
with pytest.raises(TypeError):
Cartesian3Value(values=values)

assert str(Cartesian3Value()) == "[]"


@pytest.mark.parametrize("values", [[2, 2, 2, 2, 2], [5, 5, 5, 5, 5]])
def test_bad_cartesian2_raises_error(values):
with pytest.raises(TypeError):
Cartesian2Value(values=values)

assert str(Cartesian2Value()) == "{}"


def test_reference_value():
expected_result = '"id#property"'
Expand Down Expand Up @@ -321,8 +317,6 @@ def test_cartographic_radians_value():
1.0
]"""
)
result = CartographicRadiansValue()
assert str(result) == """[]"""
with pytest.raises(TypeError):
CartographicRadiansValue(values=[0, 0, 1, 1, 1, 1, 1])

Expand All @@ -347,8 +341,6 @@ def test_cartographic_degrees_value():
1.0
]"""
)
result = CartographicDegreesValue()
assert str(result) == """[]"""
with pytest.raises(TypeError):
CartographicDegreesValue(values=[0, 0, 1, 1, 1, 1, 1])

Expand Down

0 comments on commit 755d2ee

Please sign in to comment.