@@ -383,38 +383,32 @@ def add_mock_vector_layer_responses(upload_id, raster_id, name, color):
383383 )
384384
385385
386- def add_mock_vector_layer_download_responses (layer_id , urls_num = 1 ):
387- url = "vector_layers/%s/" % layer_id
388- data = {
389- "name" : "layer%s" % layer_id ,
390- "raster_id" : "raster-id" ,
391- "count" : 1 ,
392- "color" : "#aa0000" ,
393- "id" : layer_id ,
394- "geojson_urls" : [
395- "http://layer%s.geojson.example.com" % str (i ) for i in range (urls_num )
396- ],
386+ def add_mock_vector_layer_download_responses (layer_id , num_features ):
387+ url = "vector_layers/%s/download/" % layer_id
388+ data = {"operation_id" : OPERATION_ID , "poll_interval" : TEST_POLL_INTERVAL }
389+ _add_api_response (detector_api_url (url ), verb = responses .POST , json = data )
390+ results = {
391+ "expiration" : "2021-11-03T10:55:16.000000Z" ,
392+ "download_url" : "http://layer.geojson.example.com" ,
397393 }
398- _add_api_response ( detector_api_url ( url ), json = data )
394+ add_mock_operations_responses ( "success" , results = results )
399395 features = []
400- for i in range (urls_num ):
401- url = "http://layer%s.geojson.example.com" % str ( i )
402- temp_features = [
396+ for i in range (num_features ):
397+ url = results [ "download_url" ]
398+ features . append (
403399 {
404400 "type" : "Feature" ,
405- "geometry" : make_geojson_multipolygon (j + 1 ),
401+ "geometry" : make_geojson_multipolygon (i + 1 ),
406402 "properties" : {},
407403 }
408- for j in range (i + 1 )
409- ]
410- for f in temp_features :
411- features .append (f )
412- responses .add (
413- responses .GET ,
414- url ,
415- body = json .dumps ({"type" : "FeatureCollection" , "features" : temp_features }),
416404 )
417- return {"type" : "FeatureCollection" , "features" : features }
405+ fc = {"type" : "FeatureCollection" , "features" : features }
406+ responses .add (
407+ responses .GET ,
408+ url ,
409+ body = json .dumps (fc ),
410+ )
411+ return fc
418412
419413
420414def make_geojson_multipolygon (npolygons = 1 ):
@@ -1015,11 +1009,11 @@ def test_download_vector_layer_to_file(monkeypatch):
10151009 with tempfile .NamedTemporaryFile () as fp :
10161010 client .download_vector_layer_to_file ("foobar" , fp .name )
10171011 fc = json .load (fp )
1018- assert fc == expected_content and len (fc ["features" ]) == 3
1012+ assert fc == expected_content and len (fc ["features" ]) == 2
10191013 assert (
10201014 fc ["type" ] == "FeatureCollection" and fc ["features" ][0 ]["type" ] == "Feature"
10211015 )
1022- assert len (responses .calls ) == 3
1016+ assert len (responses .calls ) == 3 # POST /download, GET /operations, GET url
10231017
10241018
10251019@responses .activate
0 commit comments