def or_it_has_wrong_processed_path(self, request): """This test simulates a wrong user behaviour, using a None object instead of a str, or a path as processed_path param""" _resampled_dimensions = method_mock(request, Slide, "_resampled_dimensions") _resampled_dimensions.return_value = (1, 2, 3, 4) with pytest.raises(TypeError) as err: slide = Slide("path", None) slide.scaled_image_path(32) assert isinstance(err.value, TypeError) assert (str(err.value) == "expected str, bytes or os.PathLike object, not NoneType")
def it_can_save_scaled_image(self, tmpdir, resampled_dims_): tmp_path_ = tmpdir.mkdir("myslide") image = PILIMG.RGBA_COLOR_500X500_155_249_240 image.save(os.path.join(tmp_path_, "mywsi.png"), "PNG") slide_path = os.path.join(tmp_path_, "mywsi.png") slide = Slide(slide_path, os.path.join(tmp_path_, "processed")) resampled_dims_.return_value = (100, 200, 300, 400) slide.save_scaled_image(32) assert slide.scaled_image_path(32) == os.path.join( tmp_path_, "processed", "mywsi-32x-100x200-300x400.png") assert os.path.exists( os.path.join(tmp_path_, slide.scaled_image_path(32)))
def it_knows_its_scaled_image_path(self, resampled_dims_, slide_path, proc_path, slide_dims, expected_value): resampled_dims_.return_value = slide_dims slide = Slide(slide_path, proc_path) scaled_img_path = slide.scaled_image_path(scale_factor=22) assert scaled_img_path == expected_value