(tmpdir_factory)
| 51 | @pytest.mark.deprecated |
| 52 | @pytest.mark.filterwarnings("ignore::DeprecationWarning") |
| 53 | def test_get_list_of_videos(tmpdir_factory): |
| 54 | fake_folder = tmpdir_factory.mktemp("videos") |
| 55 | n_ext = len(SUPPORTED_VIDEOS) |
| 56 | |
| 57 | def _create_fake_file(filename): |
| 58 | path = str(fake_folder.join(filename)) |
| 59 | with open(path, "w") as f: |
| 60 | f.write("") |
| 61 | return path |
| 62 | |
| 63 | fake_videos = [] |
| 64 | for ext in SUPPORTED_VIDEOS: |
| 65 | path = _create_fake_file(f"fake.{ext}") |
| 66 | fake_videos.append(path) |
| 67 | |
| 68 | # Add some other office files: |
| 69 | path = _create_fake_file("fake.xls") |
| 70 | path = _create_fake_file("fake.pptx") |
| 71 | |
| 72 | # Add a .pickle and .h5 files |
| 73 | _ = _create_fake_file("fake.pickle") |
| 74 | _ = _create_fake_file("fake.h5") |
| 75 | |
| 76 | # By default, all videos with common extensions are taken from a directory |
| 77 | videos = auxiliaryfunctions.get_list_of_videos( |
| 78 | str(fake_folder), |
| 79 | videotype="", |
| 80 | ) |
| 81 | assert len(videos) == n_ext |
| 82 | |
| 83 | # A list of extensions can also be passed in |
| 84 | videos = auxiliaryfunctions.get_list_of_videos( |
| 85 | str(fake_folder), |
| 86 | videotype=SUPPORTED_VIDEOS, |
| 87 | ) |
| 88 | assert len(videos) == n_ext |
| 89 | |
| 90 | for ext in SUPPORTED_VIDEOS: |
| 91 | videos = auxiliaryfunctions.get_list_of_videos( |
| 92 | str(fake_folder), |
| 93 | videotype=ext, |
| 94 | ) |
| 95 | assert len(videos) == 1 |
| 96 | |
| 97 | videos = auxiliaryfunctions.get_list_of_videos( |
| 98 | str(fake_folder), |
| 99 | videotype="unknown", |
| 100 | ) |
| 101 | assert not len(videos) |
| 102 | |
| 103 | videos = auxiliaryfunctions.get_list_of_videos( |
| 104 | fake_videos, |
| 105 | videotype="", |
| 106 | ) |
| 107 | assert len(videos) == n_ext |
| 108 | |
| 109 | for video in fake_videos: |
| 110 | videos = auxiliaryfunctions.get_list_of_videos([video], videotype="") |
nothing calls this directly
no test coverage detected