brainglobe-atlasapi icon indicating copy to clipboard operation
brainglobe-atlasapi copied to clipboard

[Feature] fixtures to mock invalid atlases

Open alessandrofelder opened this issue 4 months ago • 0 comments

Is your feature request related to a problem? Please describe. Once valid versions of all atlases are created, we won't be able to use them as test data for our validation function tests, like we do currently in e.g. brainglobe/bg-atlasgen#114

Describe the solution you'd like We should add some fixtures or similar that mock invalid atlases

Additional context

A potentially useful code snippet to mock listdir and atlas.structures, from experimentation by @alessandrofelder and @viktorpm

# pretend atlas does not have 545 in keys
mocked_structures = atlas.structures
mocked_structures.pop(545)
atlas.structures = mocked_structures

# pretend atlas does have 545.obj in meshes folder
atlas_path = (
    Path(get_brainglobe_dir())
    / f"{atlas.atlas_name}_v{get_local_atlas_version(atlas.atlas_name)}"
)
obj_path = Path(atlas_path / "meshes")
mocked_obj_files = os.listdir(obj_path)
mocked_obj_files.append("545.obj")

with mocker.patch("bg_atlasgen.validate_atlases.os.listdir", side_effect=lambda path: mocked_obj_files) as mock_list_dir:
	# make assertions here

alessandrofelder avatar Feb 19 '24 14:02 alessandrofelder