Skip to content

Commit 9a85b25

Browse files
committed
🗑️ Update test_tileserver.py
1 parent 349f940 commit 9a85b25

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

tests/test_tileserver.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ def _fill_store(
9191

9292

9393
@pytest.fixture
94-
def app(remote_sample: Callable, tmp_path: Path) -> TileServer:
94+
def app(remote_sample: Callable, track_tmp_path: Path) -> TileServer:
9595
"""Create a testing TileServer WSGI app."""
9696
# Make a low-res .jpg of the right shape to be used as
9797
# a low-res overlay.
9898
sample_svs = Path(remote_sample("svs-1-small"))
9999
wsi = WSIReader.open(sample_svs)
100100
thumb = wsi.slide_thumbnail()
101-
thumb_path = tmp_path / "thumb.jpg"
101+
thumb_path = track_tmp_path / "thumb.jpg"
102102
imwrite(thumb_path, thumb)
103103

104104
sample_store = Path(remote_sample("annotation_store_svs_1"))
@@ -334,16 +334,16 @@ def test_change_cmap(app: TileServer) -> None:
334334
assert response.json == cdict
335335

336336

337-
def test_load_save_annotations(app: TileServer, tmp_path: Path) -> None:
337+
def test_load_save_annotations(app: TileServer, track_tmp_path: Path) -> None:
338338
"""Test loading and saving annotations."""
339339
data = make_simple_dat()
340-
joblib.dump(data, tmp_path / "test.dat")
340+
joblib.dump(data, track_tmp_path / "test.dat")
341341
with app.test_client() as client:
342342
num_annotations = len(app.pyramids["default"]["overlay"].store)
343343
response = client.put(
344344
"/tileserver/annotations",
345345
data={
346-
"file_path": safe_str(tmp_path / "test.dat"),
346+
"file_path": safe_str(track_tmp_path / "test.dat"),
347347
"model_mpp": json.dumps(0.5),
348348
},
349349
)
@@ -365,12 +365,12 @@ def test_load_save_annotations(app: TileServer, tmp_path: Path) -> None:
365365

366366
def test_load_annotations_empty(
367367
empty_app: TileServer,
368-
tmp_path: Path,
368+
track_tmp_path: Path,
369369
remote_sample: Callable,
370370
) -> None:
371371
"""Test loading annotations when no annotations are present."""
372372
data = make_simple_dat()
373-
joblib.dump(data, tmp_path / "test.dat")
373+
joblib.dump(data, track_tmp_path / "test.dat")
374374
with empty_app.test_client() as client:
375375
session_id = setup_app(client)
376376
response = client.put(
@@ -381,7 +381,7 @@ def test_load_annotations_empty(
381381
response = client.put(
382382
"/tileserver/annotations",
383383
data={
384-
"file_path": safe_str(tmp_path / "test.dat"),
384+
"file_path": safe_str(track_tmp_path / "test.dat"),
385385
"model_mpp": json.dumps(0.5),
386386
},
387387
)
@@ -406,14 +406,14 @@ def test_load_annotations_empty(
406406

407407
def test_change_overlay( # noqa: PLR0915
408408
empty_app: TileServer,
409-
tmp_path: Path,
409+
track_tmp_path: Path,
410410
remote_sample: Callable,
411411
) -> None:
412412
"""Test changing overlay."""
413413
sample_store = Path(remote_sample("annotation_store_svs_1"))
414414
store = SQLiteStore(sample_store)
415415
num_annotations = len(store)
416-
geo_path = tmp_path / "test.geojson"
416+
geo_path = track_tmp_path / "test.geojson"
417417
store.to_geojson(geo_path)
418418
store.commit()
419419
store.close()
@@ -514,10 +514,10 @@ def test_change_overlay( # noqa: PLR0915
514514

515515
# add an overlay from a .dat file
516516
data = make_simple_dat()
517-
joblib.dump(data, tmp_path / "test.dat")
517+
joblib.dump(data, track_tmp_path / "test.dat")
518518
response = client.put(
519519
"/tileserver/overlay",
520-
data={"overlay_path": safe_str(tmp_path / "test.dat")},
520+
data={"overlay_path": safe_str(track_tmp_path / "test.dat")},
521521
)
522522
assert set(json.loads(response.data)) == {0, 1}
523523

@@ -537,10 +537,12 @@ def test_change_overlay( # noqa: PLR0915
537537
assert layer.wsi.info.file_path == tiff_path
538538

539539

540-
def test_commit(empty_app: TileServer, tmp_path: Path, remote_sample: Callable) -> None:
540+
def test_commit(
541+
empty_app: TileServer, track_tmp_path: Path, remote_sample: Callable
542+
) -> None:
541543
"""Test committing annotations."""
542544
data = make_simple_dat()
543-
joblib.dump(data, tmp_path / "test.dat")
545+
joblib.dump(data, track_tmp_path / "test.dat")
544546
with empty_app.test_client() as client:
545547
setup_app(client)
546548
response = client.put(
@@ -552,25 +554,25 @@ def test_commit(empty_app: TileServer, tmp_path: Path, remote_sample: Callable)
552554
# try to commit now - should return "nothing to save"
553555
response = client.post(
554556
"/tileserver/commit",
555-
data={"save_path": safe_str(tmp_path / "test.db")},
557+
data={"save_path": safe_str(track_tmp_path / "test.db")},
556558
)
557559
assert response.status_code == 200
558560
assert response.content_type == "text/html; charset=utf-8"
559561
assert response.data == b"nothing to save"
560562

561563
response = client.put(
562564
"/tileserver/overlay",
563-
data={"overlay_path": safe_str(tmp_path / "test.dat")},
565+
data={"overlay_path": safe_str(track_tmp_path / "test.dat")},
564566
)
565567
assert response.status_code == 200
566568
# commit the changes
567569
response = client.post(
568570
"/tileserver/commit",
569-
data={"save_path": safe_str(tmp_path / "test.db")},
571+
data={"save_path": safe_str(track_tmp_path / "test.db")},
570572
)
571573

572574
# check that the annotations have been correctly saved
573-
store = SQLiteStore(tmp_path / "test.db")
575+
store = SQLiteStore(track_tmp_path / "test.db")
574576
assert len(store) == 2
575577

576578

@@ -752,11 +754,11 @@ def test_prop_range(app: TileServer) -> None:
752754

753755

754756
def test_registration_dual_window(
755-
empty_app: TileServer, tmp_path: Path, remote_sample: Callable
757+
empty_app: TileServer, track_tmp_path: Path, remote_sample: Callable
756758
) -> None:
757759
"""Test registering slides."""
758760
data = make_simple_dat()
759-
joblib.dump(data, tmp_path / "test.dat")
761+
joblib.dump(data, track_tmp_path / "test.dat")
760762
with empty_app.test_client() as client, empty_app.test_client() as client2:
761763
setup_app(client)
762764
response = client.put(
@@ -842,14 +844,14 @@ def test_registration_single_window_nonslide_overlay(
842844

843845
def test_registration_single_window_different_slide(
844846
empty_app: TileServer,
845-
tmp_path: Path,
847+
track_tmp_path: Path,
846848
remote_sample: Callable,
847849
caplog: pytest.LogCaptureFixture,
848850
) -> None:
849851
"""Test registering slides."""
850852
# Repeat but provide extra overlays
851853
data = make_simple_dat()
852-
joblib.dump(data, tmp_path / "test.dat")
854+
joblib.dump(data, track_tmp_path / "test.dat")
853855
with empty_app.test_client() as client:
854856
setup_app(client)
855857
response = client.put(

0 commit comments

Comments
 (0)