Skip to content

Commit c46a601

Browse files
author
Phil Varner
committed
updates
1 parent 7d067bb commit c46a601

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

stac_api_validator/validations.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"../..",
8080
"/..",
8181
"../",
82-
"1984-04-12T23:20:50.52Z/1985-04-12T23:20:50.52Z",
82+
"/1984-04-12T23:20:50.52Z/1985-04-12T23:20:50.52Z",
8383
"1984-04-12T23:20:50.52Z/1985-04-12T23:20:50.52Z/",
8484
"/1984-04-12T23:20:50.52Z/1985-04-12T23:20:50.52Z/",
8585
"1985-04-12", # date only
@@ -211,15 +211,13 @@ def validate_core(root_body: Dict, warnings: List[str], errors: List[str]) -> No
211211
)
212212

213213
service_desc_type = service_desc.get("type")
214-
if (ct := r_service_desc.headers.get("content-type")) == service_desc_type:
215-
pass
216-
elif (";" in ct or ";" in service_desc_type) and (
217-
ct.split(";", 1)[0] == service_desc_type.split(";", 1)[0]
214+
if (
215+
(ct := r_service_desc.headers.get("content-type")) == service_desc_type
216+
) or (
217+
(";" in ct or ";" in service_desc_type)
218+
and (ct.split(";", 1)[0] == service_desc_type.split(";", 1)[0])
218219
):
219-
warnings.append(
220-
f"service-desc ({service_desc}): link must advertise same type as endpoint content-type header, "
221-
f"advertised '{service_desc_type}', actually '{ct}'"
222-
)
220+
pass
223221
else:
224222
errors.append(
225223
f"service-desc ({service_desc}): link must advertise same type as endpoint content-type header, "
@@ -357,38 +355,40 @@ def validate_search_datetime(search_url: str, warnings: List[str], errors: List[
357355
r = requests.get(search_url, params={"datetime": dt})
358356
if r.status_code != 200:
359357
errors.append(
360-
f"Search with datetime={dt} extracted from an Item returned status code {r.status_code}"
358+
f"GET Search with datetime={dt} extracted from an Item returned status code {r.status_code}"
361359
)
362360
elif len(r.json()["features"]) == 0:
363361
errors.append(
364-
f"Search with datetime={dt} extracted from an Item returned no results."
362+
f"GET Search with datetime={dt} extracted from an Item returned no results."
365363
)
366364

367365
for dt in valid_datetimes:
368366
r = requests.get(search_url, params={"datetime": dt})
369367
if r.status_code != 200:
370368
errors.append(
371-
f"Search with datetime={dt} returned status code {r.status_code}"
369+
f"GET Search with datetime={dt} returned status code {r.status_code}"
372370
)
373371
continue
374372
try:
375373
r.json()
376374
except json.decoder.JSONDecodeError:
377-
errors.append(f"Search with datetime={dt} returned non-json response")
375+
errors.append(f"GET Search with datetime={dt} returned non-json response")
378376

379377
for dt in invalid_datetimes:
380378
r = requests.get(search_url, params={"datetime": dt})
381379
if r.status_code == 200:
382380
warnings.append(
383-
f"Search with datetime={dt} returned status code 200 instead of 400"
381+
f"GET Search with datetime={dt} returned status code 200 instead of 400"
384382
)
385383
continue
386384
if r.status_code != 400:
387385
errors.append(
388-
f"Search with datetime={dt} returned status code {r.status_code} instead of 400"
386+
f"GET Search with datetime={dt} returned status code {r.status_code} instead of 400"
389387
)
390388
continue
391389

390+
# todo: POST
391+
392392

393393
def validate_search_bbox_xor_intersects(search_url: str, post: bool, errors: List[str]):
394394
r = requests.get(

0 commit comments

Comments
 (0)