def test_fetchImages_all_inte(self, mock_logger, test_dir_env): fetcher = CameraImageFetcher(dcim_folder=Path("DCIM/")) res_cam = fetcher.fetch_images() expected_cam = [ CameraImage(path=Path("DCIM/100S3D_L/3D_L0001.JPG")), CameraImage(path=Path("DCIM/100S3D_L/3D_L0002.JPG")), CameraImage(path=Path("DCIM/101S3D_L/3D_L0003.JPG")), CameraImage(path=Path("DCIM/101S3D_L/3D_L0004.JPG")), CameraImage(path=Path("DCIM/101S3D_L/3D_L0000.JPG")) ] assert self.fake_env_patcher_mocks['dirs'].called, "Directories weren't fetch" assert res_cam == expected_cam, "Something went wrong"
def load_cam_images(self) -> List[CameraImageFetcher]: """ Load camera images from pictures_path/APNxx/DCIM. Using camera fetcher. Lazy only start camera image fetchers once and fetch the images. """ if self.fetchers is not None: return self.fetchers self.fetchers = [] for no in range(0, self.nb_cams): fetcher = CameraImageFetcher(dcim_folder=self.pictures_path / CAM_DCIM_PATH.format(no)) fetcher.fetch_images() self.fetchers.append(fetcher) return self.fetchers
def test__init__ok(self, mock_extract_file_names_param): fetcher = CameraImageFetcher(dcim_folder=Path("/tmp/")) assert fetcher.dcim_folder == "/tmp/", "DCIM folder not correcly set" assert fetcher._img_start_index == opv_import.services.camera_image_fetcher.GORPRO_IMG_START_INDEX, "Default start index is wrong" assert mock_extract_file_names_param.called, "File format (prefix, extension ..) wasn't called in constructor"
def test_get_last(self, mock_logger, test_dir_env): fetcher = CameraImageFetcher(dcim_folder=Path("DCIM/")) assert fetcher.get_last() == CameraImage(path=Path("DCIM/101S3D_L/3D_L0000.JPG"))
def test_nb_pic(self, mock_logger, test_dir_env): fetcher = CameraImageFetcher(dcim_folder=Path("DCIM/")) assert fetcher.nb_pic() == 5, "Wrong number of pictures"
def test_get_pic(self, mock_logger, test_dir_env): fetcher = CameraImageFetcher(dcim_folder=Path("DCIM/")) assert fetcher.get_pic(index=1) == CameraImage(path=Path("DCIM/100S3D_L/3D_L0002.JPG")) assert fetcher.get_pic(index=30) is None
def test__init__fail(self, mock_extract_file_names_param): with pytest.raises(opv_import.services.camera_image_fetcher.MissingDcfFolderError) as e: fetcher = CameraImageFetcher(dcim_folder=Path("/tmp/"))