From 33aff2a65a8d430754a3f80dd8947bed1c1dc519 Mon Sep 17 00:00:00 2001 From: Nikolay Akhmetov Date: Wed, 11 Dec 2024 12:45:09 -0500 Subject: [PATCH] handle case where epic fixture gets pulled in to `has_visualization` test --- test/test_builders.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/test/test_builders.py b/test/test_builders.py index 95d4b1b..7f9d076 100644 --- a/test/test_builders.py +++ b/test/test_builders.py @@ -80,14 +80,20 @@ def get_entity(input): [ (False, {"uuid": "2c2179ea741d3bbb47772172a316a2bf"}), (True, json.loads(Path.read_text(good_entity_paths[0]))), - # If the first fixture returns a Null builder this would break. + # NOTE: If the first fixture returns a Null builder this breaks. ], ids=lambda has_vis_entity: f"has_visualization={has_vis_entity[0]}", ) def test_has_visualization(has_vis_entity): has_vis, entity = has_vis_entity parent = entity.get("parent") or None # Only used for image pyramids - assert has_vis == has_visualization(entity, get_entity, parent) + # TODO: Once other epic hints exist, this may need to be adjusted + epic_uuid = ( + entity.get("uuid") + if "segmentation_mask" in entity.get("vitessce-hints", {}) + else None + ) + assert has_vis == has_visualization(entity, get_entity, parent, epic_uuid) def mock_zarr_store(entity_path, mocker): @@ -147,7 +153,7 @@ def test_entity_to_vitessce_conf(entity_path, mocker): entity = json.loads(entity_path.read_text()) parent = entity.get("parent") or None # Only used for image pyramids assay_type = get_entity(entity["uuid"]) - if 'segmentation_mask' in assay_type['vitessce-hints']: + if "segmentation_mask" in assay_type["vitessce-hints"]: epic_uuid = entity.get("uuid") Builder = get_view_config_builder(entity, get_entity, parent, epic_uuid) # Envvars should not be set during normal test runs, @@ -157,22 +163,23 @@ def test_entity_to_vitessce_conf(entity_path, mocker): # epic_uuid = environ.get("EPIC_UUID", "epic_uuid") builder = Builder(entity, groups_token, assets_url) conf, cells = builder.get_conf_cells(marker=marker) - if 'segmentation_mask' not in assay_type['vitessce-hints']: + if "segmentation_mask" not in assay_type["vitessce-hints"]: assert Builder.__name__ == entity_path.parent.name compare_confs(entity_path, conf, cells) - if 'segmentation_mask' in assay_type['vitessce-hints']: + if "segmentation_mask" in assay_type["vitessce-hints"]: epic_builder = get_epic_builder(epic_uuid) assert epic_builder is not None assert epic_builder.__name__ == entity_path.parent.name - if conf is None: # pragma: no cover + if conf is None: # pragma: no cover with pytest.raises(ValueError): - epic_builder(epic_uuid, - ConfCells(conf, cells), entity, groups_token, assets_url).get_conf_cells() + epic_builder( + epic_uuid, ConfCells(conf, cells), entity, groups_token, assets_url + ).get_conf_cells() return - built_epic_conf, cells = epic_builder(epic_uuid, - ConfCells(conf, cells), entity, groups_token, assets_url - ).get_conf_cells() + built_epic_conf, cells = epic_builder( + epic_uuid, ConfCells(conf, cells), entity, groups_token, assets_url + ).get_conf_cells() assert built_epic_conf is not None compare_confs(entity_path, built_epic_conf, cells)