Skip to content

Commit ed55353

Browse files
Fix incorrect mock
`add_mock_vector_layer_download_responses` incorrectly setup a response as a FeatureCollection, when the endpoint returns vector layer results as a MultiPolygon.
1 parent b0d1914 commit ed55353

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

tests/test_client.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -392,23 +392,14 @@ def add_mock_vector_layer_download_responses(layer_id, num_features):
392392
"download_url": "http://layer.geojson.example.com",
393393
}
394394
add_mock_operations_responses("success", results=results)
395-
features = []
396-
for i in range(num_features):
397-
url = results["download_url"]
398-
features.append(
399-
{
400-
"type": "Feature",
401-
"geometry": make_geojson_multipolygon(i + 1),
402-
"properties": {},
403-
}
404-
)
405-
fc = {"type": "FeatureCollection", "features": features}
395+
url = results["download_url"]
396+
mp = make_geojson_multipolygon(2)
406397
responses.add(
407398
responses.GET,
408399
url,
409-
body=json.dumps(fc),
400+
body=json.dumps(mp),
410401
)
411-
return fc
402+
return mp
412403

413404

414405
def make_geojson_multipolygon(npolygons=1):
@@ -1008,11 +999,11 @@ def test_download_vector_layer_to_file(monkeypatch):
1008999
client = _client(monkeypatch)
10091000
with tempfile.NamedTemporaryFile() as fp:
10101001
client.download_vector_layer_to_file("foobar", fp.name)
1011-
fc = json.load(fp)
1012-
assert fc == expected_content and len(fc["features"]) == 2
1002+
mp = json.load(fp)
10131003
assert (
1014-
fc["type"] == "FeatureCollection" and fc["features"][0]["type"] == "Feature"
1004+
mp["type"] == "MultiPolygon"
10151005
)
1006+
assert mp == expected_content and len(mp["coordinates"]) == 2
10161007
assert len(responses.calls) == 3 # POST /download, GET /operations, GET url
10171008

10181009

0 commit comments

Comments
 (0)