Skip to content

Commit fc2e5db

Browse files
Make the subTemporalValue property test self-contained and timezone-correct
The test stores a TReal property with values spanning the queried window before reading it back, so it no longer depends on another test having created the property, and it compares timezone-aware datetimes rather than ISO strings so the window check holds regardless of the server's offset.
1 parent d70faf0 commit fc2e5db

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

tests/test_mobility_api.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -986,19 +986,36 @@ def test_get_temporal_property_with_datetime(setup_property_test_data):
986986

987987
def test_get_temporal_property_with_subtemporal(setup_property_test_data):
988988
data = setup_property_test_data
989+
# Store a TReal property with values spanning the window so this test owns its
990+
# data and does not depend on another test's ordering.
991+
requests.post(
992+
f"{HOST}/collections/{data['collection_id']}/items/{data['feature_id']}/tproperties",
993+
json={
994+
"datetimes": [
995+
"2024-03-01T00:00:00Z", "2024-03-01T00:15:00Z", "2024-03-01T00:30:00Z",
996+
"2024-03-01T00:45:00Z", "2024-03-01T01:00:00Z",
997+
],
998+
"subspeed": {"type": "TReal", "form": "KMH",
999+
"values": [10.0, 20.0, 30.0, 40.0, 50.0], "interpolation": "Linear"},
1000+
},
1001+
)
9891002
interval = urllib.parse.quote("2024-03-01T00:15:00Z/2024-03-01T00:45:00Z")
9901003
resp = requests.get(
991-
f"{HOST}/collections/{data['collection_id']}/items/{data['feature_id']}/tproperties/speed?subTemporalValue=true&datetime={interval}"
1004+
f"{HOST}/collections/{data['collection_id']}/items/{data['feature_id']}/tproperties/subspeed?subTemporalValue=true&datetime={interval}"
9921005
)
9931006
log_request_response("Get temporal property with subTemporalValue", resp)
9941007
assert resp.status_code == 200
9951008
result = resp.json()
9961009
assert "temporalProperties" in result
9971010
assert len(result["temporalProperties"]) > 0
1011+
# Compare timezone-aware datetimes (the server returns its local offset), not
1012+
# ISO strings, so the window check is correct regardless of the offset.
1013+
lo = datetime.fromisoformat("2024-03-01T00:15:00+00:00")
1014+
hi = datetime.fromisoformat("2024-03-01T00:45:00+00:00")
9981015
for segment in result["temporalProperties"]:
9991016
for dt_str in segment["datetimes"]:
1000-
dt = datetime.fromisoformat(dt_str.replace('Z', '+00:00'))
1001-
assert "2024-03-01T00:15:00Z" <= dt.isoformat() <= "2024-03-01T00:45:00Z"
1017+
dt = datetime.fromisoformat(dt_str.replace("Z", "+00:00"))
1018+
assert lo <= dt <= hi
10021019
#============================================================DELETE /collections/{id}/items/{fid}/tproperties/{name}===========================
10031020
def test_delete_temporal_property(setup_property_test_data):
10041021

0 commit comments

Comments
 (0)