Skip to content

Commit

Permalink
handle case where epic fixture gets pulled in to has_visualization
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
NickAkhmetov committed Dec 11, 2024
1 parent 53aaf06 commit 33aff2a
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions test/test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 33aff2a

Please sign in to comment.