@@ -100,11 +100,7 @@ def app(remote_sample: Callable, tmp_path: Path) -> TileServer:
100100 imwrite (thumb_path , thumb )
101101
102102 sample_store = Path (remote_sample ("annotation_store_svs_1" ))
103- store = SQLiteStore (sample_store )
104- geo_path = tmp_path / "test.geojson"
105- store .to_geojson (geo_path )
106- store .commit ()
107- store .close ()
103+ geo_path = Path (remote_sample ("geojson_cmu_1" ))
108104
109105 # make tileserver with layers representing all the types
110106 # of things it should be able to handle
@@ -115,7 +111,7 @@ def app(remote_sample: Callable, tmp_path: Path) -> TileServer:
115111 "tile" : str (thumb_path ),
116112 "im_array" : np .zeros (wsi .slide_dimensions (1.25 , "power" ), dtype = np .uint8 ).T ,
117113 "overlay" : str (sample_store ),
118- "store_geojson" : tmp_path / "test.geojson" ,
114+ "store_geojson" : str ( geo_path ) ,
119115 },
120116 )
121117 app .config .from_mapping ({"TESTING" : True })
@@ -446,14 +442,22 @@ def test_change_overlay( # noqa: PLR0915
446442 assert response .status_code == 200
447443 response = client .put (
448444 "/tileserver/overlay" ,
449- data = {"overlay_path" : safe_str (geo_path )},
445+ data = {"overlay_path" : safe_str (sample_store )},
450446 )
451447 assert response .status_code == 200
452448 assert response .content_type == "text/html; charset=utf-8"
453449 assert set (json .loads (response .data )) == {0 , 1 , 2 , 3 , 4 }
454450 # check that the annotations have been correctly loaded
455451 assert len (empty_app .pyramids [session_id ]["overlay" ].store ) == num_annotations
456452
453+ # check loading a geojson from qupath with cells/nuclei
454+ qpath_geo_path = Path (remote_sample ("geojson_cmu_1" ))
455+ response = client .put (
456+ "/tileserver/overlay" ,
457+ data = {"overlay_path" : safe_str (qpath_geo_path )},
458+ )
459+ assert response .status_code == 200
460+
457461 # add another image layer
458462 response = client .put (
459463 "/tileserver/overlay" ,
@@ -462,10 +466,18 @@ def test_change_overlay( # noqa: PLR0915
462466 assert response .status_code == 200
463467 assert response .content_type == "text/html; charset=utf-8"
464468 # check that the overlay has been correctly added
465- lname = f"layer { len ( empty_app . pyramids [ session_id ]) - 1 } "
469+ lname = Path ( overlay_path ). stem
466470 layer = empty_app .pyramids [session_id ][lname ]
467471 assert layer .wsi .info .file_path == overlay_path
468472
473+ # add same image again to check if duplicate names triggers disambiguation
474+ response = client .put (
475+ "/tileserver/overlay" ,
476+ data = {"overlay_path" : safe_str (overlay_path )},
477+ )
478+ assert response .status_code == 200
479+ assert Path (overlay_path ).name in empty_app .pyramids [session_id ]
480+
469481 # replace existing store overlay
470482 response = client .put (
471483 "/tileserver/overlay" ,
@@ -494,7 +506,7 @@ def test_change_overlay( # noqa: PLR0915
494506 data = {"overlay_path" : safe_str (jpg_path )},
495507 )
496508 # check that the overlay has been correctly added
497- lname = f"layer { len ( empty_app . pyramids [ session_id ]) - 1 } "
509+ lname = Path ( jpg_path ). stem
498510 layer = empty_app .pyramids [session_id ][lname ]
499511 assert np .all (layer .wsi .img == imread (jpg_path ))
500512
@@ -518,7 +530,7 @@ def test_change_overlay( # noqa: PLR0915
518530 data = {"overlay_path" : safe_str (tiff_path )},
519531 )
520532 # check that the overlay has been correctly added
521- lname = f"layer { len ( empty_app . pyramids [ session_id ]) - 1 } "
533+ lname = Path ( tiff_path ). stem
522534 layer = empty_app .pyramids [session_id ][lname ]
523535 assert layer .wsi .info .file_path == tiff_path
524536
0 commit comments