Skip to content

Commit 2bb2ef6

Browse files
author
Tao Peng
authored
fix: relative video path again and tests (#564)
* fix: relative video path again and tests * skip tests if ffmpeg not installed * assert that video_dir is absolute
1 parent ff29e28 commit 2bb2ef6

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

mapillary_tools/sample_video.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def sample_video(
2727
video_list = utils.find_videos(
2828
[video_import_path], skip_subfolders=skip_subfolders
2929
)
30-
video_dir = video_import_path
30+
video_dir = video_import_path.resolve()
3131
LOG.debug(f"Found %d videos in %s", len(video_list), video_dir)
3232
elif video_import_path.is_file():
3333
video_list = [video_import_path]
@@ -36,6 +36,7 @@ def sample_video(
3636
raise exceptions.MapillaryFileNotFoundError(
3737
f"Video file or directory not found: {video_import_path}"
3838
)
39+
assert video_dir.is_absolute(), f"video_dir must be absolute here: {str(video_dir)}"
3940

4041
video_start_time_dt: T.Optional[datetime.datetime] = None
4142
if video_start_time is not None:

tests/integration/test_process.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import os
44
import subprocess
5+
import tempfile
56
import zipfile
67
from pathlib import Path
78

@@ -647,6 +648,30 @@ def ffmpeg_installed():
647648
is_ffmpeg_installed = ffmpeg_installed()
648649

649650

651+
def test_sample_video_relpath():
652+
if not is_ffmpeg_installed:
653+
pytest.skip("skip because ffmpeg not installed")
654+
655+
with tempfile.TemporaryDirectory() as dir:
656+
x = subprocess.run(
657+
f"{EXECUTABLE} sample_video --rerun tests/integration/mapillary_tools_process_images_provider/gopro_data/hero8.mp4 {dir}",
658+
shell=True,
659+
)
660+
assert x.returncode == 0, x.stderr
661+
662+
663+
def test_sample_video_relpath_dir():
664+
if not is_ffmpeg_installed:
665+
pytest.skip("skip because ffmpeg not installed")
666+
667+
with tempfile.TemporaryDirectory() as dir:
668+
x = subprocess.run(
669+
f"{EXECUTABLE} sample_video --rerun --video_start_time 2021_10_10_10_10_10_123 tests/integration {dir}",
670+
shell=True,
671+
)
672+
assert x.returncode == 0, x.stderr
673+
674+
650675
def test_sample_video(setup_data: py.path.local):
651676
if not is_ffmpeg_installed:
652677
pytest.skip("skip because ffmpeg not installed")
@@ -699,10 +724,10 @@ def test_video_process(setup_data: py.path.local):
699724
with gpx_file.open("w") as fp:
700725
fp.write(GPX_CONTENT)
701726
x = subprocess.run(
702-
f"{EXECUTABLE} video_process {PROCESS_FLAGS} --video_start_time 2018_06_08_13_23_34_123 --geotag_source gpx --geotag_source_path {gpx_file} {setup_data} {setup_data.join('my_samples')}",
727+
f"{EXECUTABLE} video_process {PROCESS_FLAGS} --skip_process_errors --video_start_time 2018_06_08_13_23_34_123 --geotag_source gpx --geotag_source_path {gpx_file} {setup_data} {setup_data.join('my_samples')}",
703728
shell=True,
704729
)
705-
assert x.returncode != 0, x.stderr
730+
assert x.returncode == 0, x.stderr
706731
with open(desc_path) as fp:
707732
descs = json.load(fp)
708733
assert 1 == len(find_desc_errors(descs))

0 commit comments

Comments
 (0)