def test_do_calculation_calculation_process(self, tmpdir, data_test_dir): plan = self.create_calculation_plan3() file_path = os.path.join(data_test_dir, "stack1_components", "stack1_component1.tif") calc = Calculation( [file_path], base_prefix=data_test_dir, result_prefix=data_test_dir, measurement_file_path=os.path.join(tmpdir, "test3.xlsx"), sheet_name="Sheet1", calculation_plan=plan, voxel_size=(1, 1, 1), ) calc_process = CalculationProcess() res = calc_process.do_calculation(FileCalculation(file_path, calc)) assert isinstance(res, list) assert isinstance(res[0], ResponseData)
def test_do_calculation_save(self, tmpdir, data_test_dir, file_name, root_type, save_method: SaveBase): save_desc = Save("_test", "", save_method.get_name(), save_method.get_short_name(), save_method.get_default_values()) plan = self.create_simple_plan(root_type, save_desc) file_path = os.path.join(data_test_dir, file_name) calc = Calculation( [file_path], base_prefix=os.path.dirname(file_path), result_prefix=tmpdir, measurement_file_path=os.path.join(tmpdir, "test3.xlsx"), sheet_name="Sheet1", calculation_plan=plan, voxel_size=(1, 1, 1), ) calc_process = CalculationProcess() res = calc_process.do_calculation(FileCalculation(file_path, calc)) assert isinstance(res, list) assert isinstance(res[0], ResponseData)
def test_full_pipeline_base(self, tmpdir, data_test_dir, monkeypatch): monkeypatch.setattr(batch_backend, "CalculationProcess", MockCalculationProcess) plan = self.create_calculation_plan() file_pattern = os.path.join(data_test_dir, "stack1_components", "stack1_component*[0-9].tif") file_paths = sorted(glob(file_pattern)) assert os.path.basename(file_paths[0]) == "stack1_component1.tif" calc = Calculation( file_paths, base_prefix=data_test_dir, result_prefix=data_test_dir, measurement_file_path=os.path.join(tmpdir, "test.xlsx"), sheet_name="Sheet1", calculation_plan=plan, voxel_size=(1, 1, 1), ) calc_process = CalculationProcess() for file_path in file_paths: res = calc_process.do_calculation(FileCalculation(file_path, calc)) assert isinstance(res, list) assert isinstance(res[0], ResponseData)
def test_one_file(self, data_test_dir): plan = self.create_calculation_plan() process = CalculationProcess() file_path = os.path.join(data_test_dir, "stack1_components", "stack1_component5.tif") calc = MocksCalculation(file_path) process.calculation = calc process.image = TiffImageReader.read_image(file_path) process.iterate_over(plan.execution_tree) assert len(process.measurement[0]) == 3