def test_create_segmentation_layer(volume_info): _, b, vox_size, tiff_dims, _, top_level = volume_info vols = upload.create_cloud_volume( "file://" + str(top_level / "test_upload_segments"), tiff_dims, vox_size, num_resolutions=len(b), layer_type="segmentation", ) assert len(vols) == 1 for i, vol in enumerate(vols): assert vol.info["scales"][0]["size"] == [(2 ** i) * j for j in tiff_dims]
def test_process_bad_inputs(volume_info): """Tests that errors are raised when bad inputs are given to upload.process.""" fpaths, bin_paths, v, i, o, top = volume_info dest = "file://" + str(top / "test_upload") vols = upload.create_cloud_volume(dest, i, v, NUM_RES) with pytest.raises(TypeError): upload.process(0, bin_paths[0][0], vols[0]) with pytest.raises(FileNotFoundError): upload.process("asdf", bin_paths[0][0], vols[0]) with pytest.raises(TypeError): upload.process(fpaths[0][0], 0, vols[0]) with pytest.raises(ValueError): upload.process(fpaths[0][0], ["asdf"], vols[0]) with pytest.raises(TypeError): upload.process(fpaths[0][0], bin_paths[0][0], 0)
def test_create_annotation_layer(volume_info): """Tests that create_cloud_volume returns valid CloudVolumePrecomputed object for annotation data.""" _, b, vox_size, tiff_dims, _, top_level = volume_info dir_annotation = top_level / "test_upload_annotations" vols = upload.create_cloud_volume( dir_annotation.as_uri(), tiff_dims, vox_size, num_resolutions=NUM_RES, layer_type="annotation", ) assert len(vols) == 1 # always 1 for segementation for i, vol in enumerate(vols): assert vol.scales[-1 - i]["size"] == [(2**i) * j for j in tiff_dims] assert (dir_annotation / "info").is_file() # contains info file
def test_create_image_layer(volume_info): """Tests that create_image_layer returns valid CloudVolumePrecomputed object for image data.""" _, b, vox_size, tiff_dims, _, top_level = volume_info dir = top_level / "test_upload" vols = upload.create_cloud_volume( dir.as_uri(), tiff_dims, vox_size, num_resolutions=NUM_RES, layer_type="image", ) assert len(vols) == NUM_RES # one vol for each resolution for i, vol in enumerate(vols): assert vol.scales[-1 - i]["size"] == [(2**i) * j for j in tiff_dims] assert (dir / "info").is_file() # contains info file
def test_create_cloud_volume_bad_inputs(volume_info): """Tests that errors are raised when bad inputs are given to upload.create_cloud_volume.""" ( _, _, v, i, _, top_level, ) = volume_info p = "file://" + str(top_level) n = 1 c = i par = False l = "image" d = "uint16" with pytest.raises(TypeError): upload.create_cloud_volume(0, i, v, n, c, par, l, d) with pytest.raises(NotImplementedError): upload.create_cloud_volume("asdf", i, v, n, c, par, l, d) with pytest.raises(TypeError): upload.create_cloud_volume(p, 0, v, n, c, par, l, d) with pytest.raises(ValueError): upload.create_cloud_volume(p, [0], v, n, c, par, l, d) with pytest.raises(TypeError): upload.create_cloud_volume(p, ["a", "b", "c"], v, n, c, par, l, d) with pytest.raises(TypeError): upload.create_cloud_volume(p, i, 0, n, c, par, l, d) with pytest.raises(ValueError): upload.create_cloud_volume(p, i, [0], n, c, par, l, d) with pytest.raises(TypeError): upload.create_cloud_volume(p, i, ["a", "b", "c"], n, c, par, l, d) with pytest.raises(TypeError): upload.create_cloud_volume(p, i, v, 0.0, c, par, l, d) with pytest.raises(ValueError): upload.create_cloud_volume(p, i, v, 0, c, par, l, d) with pytest.raises(TypeError): upload.create_cloud_volume(p, i, v, n, 0, par, l, d) with pytest.raises(ValueError): upload.create_cloud_volume(p, i, v, n, [0], par, l, d) with pytest.raises(TypeError): upload.create_cloud_volume(p, i, v, n, ["a", "b", "c"], par, l, d) with pytest.raises(TypeError): upload.create_cloud_volume(p, i, v, n, c, 0, l, d) with pytest.raises(TypeError): upload.create_cloud_volume(p, i, v, n, c, par, 0, d) with pytest.raises(ValueError): upload.create_cloud_volume(p, i, v, n, c, par, "seg", d) with pytest.raises(TypeError): upload.create_cloud_volume(p, i, v, n, c, par, l, 0) with pytest.raises(ValueError): upload.create_cloud_volume(p, i, v, n, c, par, l, "uint8") with pytest.raises(TypeError): upload.create_cloud_volume(p, i, v, n, c, par, l, d, 0)