@@ -333,8 +333,10 @@ def stac_check(
333
333
errors += (
334
334
f"[{ context } ] { method } { url } is not a valid STAC object: { linter .error_msg } "
335
335
)
336
- if linter .best_practices_msg :
337
- warnings += f"[{ context } ] { method } { url } has these stac-check recommendations: { linter .best_practices_msg } "
336
+ if msgs := linter .best_practices_msg [1 :]: # first msg is a header
337
+ warnings += (
338
+ f"[{ context } ] { method } { url } has these stac-check recommendations: { msgs } "
339
+ )
338
340
339
341
340
342
def retrieve (
@@ -373,7 +375,9 @@ def retrieve(
373
375
elif not has_content_type (resp .headers , content_type ):
374
376
errors += f"[{ context } ] { method } { url } params={ params } body={ body } content-type header is not '{ content_type } '"
375
377
376
- if resp .headers .get ("content-type" , "" ).split (";" )[0 ].endswith ("json" ):
378
+ if has_json_content_type (resp .headers ) or has_geojson_content_type (
379
+ resp .headers
380
+ ):
377
381
try :
378
382
return resp .status_code , resp .json (), resp .headers
379
383
except json .decoder .JSONDecodeError :
@@ -391,7 +395,7 @@ def validate_core_landing_page_body(
391
395
collection : Optional [str ],
392
396
geometry : Optional [str ],
393
397
) -> bool :
394
- if not has_content_type (headers , "application/json" ):
398
+ if not has_json_content_type (headers ):
395
399
errors += (
396
400
"CORE-1" ,
397
401
"[Core] : Landing Page (/) response Content-Type header is not application/json" ,
@@ -728,7 +732,7 @@ def validate_collections(
728
732
if not body :
729
733
errors += f"[{ Context .COLLECTIONS } ] /collections body was empty"
730
734
else :
731
- if not resp_headers or not is_json_type (resp_headers . get ( "content-type" ) ):
735
+ if not resp_headers or not has_json_content_type (resp_headers ):
732
736
errors += f"[{ Context .COLLECTIONS } ] /collections content-type header was not application/json"
733
737
734
738
if not (self_link := link_by_rel (body .get ("links" , []), "self" )):
@@ -766,11 +770,7 @@ def validate_collections(
766
770
if not body :
767
771
errors += f"[{ Context .COLLECTIONS } ] { collection_url } body was empty"
768
772
else :
769
- if (
770
- not resp_headers
771
- or resp_headers .get ("content-type" , "" ).split (";" )[0 ]
772
- != "application/json"
773
- ):
773
+ if not resp_headers or not has_json_content_type (resp_headers ):
774
774
errors += f"[{ Context .COLLECTIONS } ] { collection_url } content-type header was not application/json"
775
775
776
776
if not (self_link := link_by_rel (body .get ("links" , []), "self" )):
@@ -1749,13 +1749,14 @@ def validate_item_search_intersects(
1749
1749
)
1750
1750
1751
1751
if body :
1752
- if not len ( body [ "features" ] ):
1752
+ if not body . get ( "features" ):
1753
1753
errors += f"[{ Context .ITEM_SEARCH } ] GET { search_url } Search result for intersects={ geometry } returned no results"
1754
- if any (
1755
- not intersects_shape .intersects (shape (item ["geometry" ]))
1756
- for item in body ["features" ]
1757
- ):
1758
- errors += f"[{ Context .ITEM_SEARCH } ] GET { search_url } Search results for intersects={ geometry } do not all intersect"
1754
+ else :
1755
+ if any (
1756
+ not intersects_shape .intersects (shape (item .get ("geometry" , None )))
1757
+ for item in body .get ("features" , [])
1758
+ ):
1759
+ errors += f"[{ Context .ITEM_SEARCH } ] GET { search_url } Search results for intersects={ geometry } do not all intersect"
1759
1760
1760
1761
if Method .POST in methods :
1761
1762
_ , item_collection , _ = retrieve (
@@ -1766,11 +1767,12 @@ def validate_item_search_intersects(
1766
1767
body = {"collections" : [collection ], "intersects" : geometry },
1767
1768
r_session = r_session ,
1768
1769
)
1769
- if not ( item_collection and len ( item_collection [ "features" ]) ):
1770
+ if not item_collection or not item_collection . get ( "features" ):
1770
1771
errors += f"[{ Context .ITEM_SEARCH } ] POST Search result for intersects={ geometry } returned no results"
1771
- for item in item_collection ["features" ]: # type: ignore
1772
- if not intersects_shape .intersects (shape (item ["geometry" ])):
1773
- errors += f"[{ Context .ITEM_SEARCH } ] POST Search result for intersects={ geometry } , does not intersect { item ['geometry' ]} "
1772
+ else :
1773
+ for item in item_collection .get ("features" , []):
1774
+ if not intersects_shape .intersects (shape (item .get ("geometry" ))):
1775
+ errors += f"[{ Context .ITEM_SEARCH } ] POST Search result for intersects={ geometry } , does not intersect { item .get ('geometry' )} "
1774
1776
1775
1777
1776
1778
def validate_item_search_bbox (
0 commit comments