11import json
22import operator
3+ import urllib .parse
34from datetime import datetime , timedelta
45from typing import Any , Dict , Iterator
56
@@ -99,7 +100,7 @@ def test_url_with_parameters(self) -> None:
99100 datetime = "2020-02-01T00:00:00Z" ,
100101 bbox = [- 104.5 , 44.0 , - 104.0 , 45.0 ],
101102 )
102- assert "bbox=-104.5,44.0, -104.0,45 .0" in search .url_with_parameters ()
103+ assert "bbox=-104.5%2C44.0%2C -104.0%2C45 .0" in search .url_with_parameters ()
103104
104105 # Motivating example: https://github.com/stac-utils/pystac-client/issues/299
105106 search = ItemSearch (
@@ -110,7 +111,7 @@ def test_url_with_parameters(self) -> None:
110111 assert (
111112 search .url_with_parameters ()
112113 == "https://planetarycomputer.microsoft.com/api/stac/v1/search?"
113- "limit=100&bbox=88.214,27 .927,88 .302,28 .034&collections=cop-dem-glo-30"
114+ "limit=100&bbox=88.214%2C27 .927%2C88 .302%2C28 .034&collections=cop-dem-glo-30"
114115 )
115116
116117 def test_single_string_datetime (self ) -> None :
@@ -803,3 +804,13 @@ def test_query_json_syntax() -> None:
803804 assert item_search ._format_query (["eo:cloud_cover<=1" , "eo:cloud_cover>0" ]) == {
804805 "eo:cloud_cover" : {"lte" : "1" , "gt" : "0" }
805806 }
807+
808+
809+ def test_url_with_query_parameter () -> None :
810+ # https://github.com/stac-utils/pystac-client/issues/522
811+ search = ItemSearch (
812+ url = "http://pystac-client.test" , query = {"eo:cloud_cover" : {"lt" : 42 }}
813+ )
814+ url = urllib .parse .urlparse (search .url_with_parameters ())
815+ query = urllib .parse .parse_qs (url .query )
816+ assert query ["query" ] == [r'{"eo:cloud_cover":{"lt":42}}' ]
0 commit comments