def move_photos_del_folders_year(): photo_roots = traverse_photos_path( r"C:\repos\photonomist\test\data\testing_folder_with_photos\bla\blabla" ) yield photo_roots shutil.move( r"test\data\testing_folder_with_photos\move_folder\2019_place_reason_people\DSC_0262.NEF", r"test\data\testing_folder_with_photos\bla\blabla\DSC_0262.NEF") shutil.move( r"test\data\testing_folder_with_photos\move_folder\2020_place_reason_people\DSC_1402.JPG", r"test\data\testing_folder_with_photos\bla\blabla\blablabla\DSC_1402.JPG" ) shutil.move( r"test\data\testing_folder_with_photos\move_folder\2020_place_reason_people\IMG_5494.CR2", r"test\data\testing_folder_with_photos\bla\blabla\IMG_5494.CR2") os.rmdir( r"test\data\testing_folder_with_photos\move_folder\2019_place_reason_people" ) os.rmdir( r"test\data\testing_folder_with_photos\move_folder\2020_place_reason_people" ) os.remove( r"test\data\testing_folder_with_photos\move_folder\not_transferred.txt" ) os.rmdir(r"test\data\testing_folder_with_photos\move_folder")
def test_photos_total_size(): """Test src\\photonomist\\__main__ > photos_size """ sample_photo_roots = traverse_photos_path( r'test\data\testing_folder_with_photos') photos_total_size = photos_size(sample_photo_roots) assert photos_total_size == 140855708
def test_extracts_photo_roots(): """Test src\\photonomist\\__main__ > traverse_photos_path """ sample_path = r'test\data\testing_folder_with_photos' num_of_photos = 0 for photo_list in traverse_photos_path(sample_path).values(): print(photo_list) num_of_photos += len(photo_list) assert num_of_photos == 9
def test_input_path_validation_traverse_photos_path(): """ Test for src\\photonomist\\__main__ > input_path_validation """ sample_path = r'test\data\testing_folder_with_photos' num_of_photos = 0 for photo_list in traverse_photos_path(sample_path).values(): print(photo_list) num_of_photos += len(photo_list) assert num_of_photos == 9
def test_path_contains_files_extensions_jpg_nef_cr2(capsys): """Test src\\photonomist\\__main__ > path_photos """ sample_photo_roots = traverse_photos_path( r'test\data\testing_folder_with_photos') path_photos(sample_photo_roots) captured = capsys.readouterr() assert r'test\data\testing_folder_with_photos\bla\blanef\blablanef\blablablanef' in captured.out assert r'test\data\testing_folder_with_photos\bla\blabla\blablabla' in captured.out assert r'C:\repos\photonomist\test\data\testing_folder_with_photos\bla\blablacr2' in captured.out
def test_path_does_not_contain_jpg_jpeg_nef_cr2_files(): """Test src\\photonomist\\__main__ > path_photos """ sample_photo_roots = traverse_photos_path( r'test\data\testing_empty_folder') with pytest.raises( Exception, match= "The provided path does not contain any files with .jpg, .jpeg, .nef or .cr2 extension!" ): path_photos(sample_photo_roots)
def test_extracts_0_photo_roots(): """Test src\\photonomist\\__main__ > traverse_photos_path """ sample_path = r'test\data\testing_empty_folder' assert len(traverse_photos_path(sample_path)) == 0