Loading isis/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -609,7 +609,7 @@ install(FILES ${CMAKE_SOURCE_DIR}/../CHANGELOG.md DESTINATION ${CMAKE_INSTA install(FILES ${CMAKE_BINARY_DIR}/version DESTINATION ${CMAKE_INSTALL_PREFIX}) install(DIRECTORY ${CMAKE_SOURCE_DIR}/scripts DESTINATION ${CMAKE_INSTALL_PREFIX}) install(PROGRAMS ${CMAKE_BINARY_DIR}/lib/Camera.plugin DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/) install(PROGRAMS ${CMAKE_SOURCE_DIR}/scripts/downloadIsisData.py DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/) install(PROGRAMS ${CMAKE_SOURCE_DIR}/scripts/downloadIsisData DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/) install(PROGRAMS ${CMAKE_SOURCE_DIR}/config/rclone.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/isis/) # Trigger all post-install behavior. Loading isis/pytests/test_IsisDownload.py +12 −9 Original line number Diff line number Diff line Loading @@ -8,7 +8,15 @@ from unittest import mock from tempfile import TemporaryDirectory from pathlib import Path from downloadIsisData import rclone, create_rclone_arguments from importlib.util import spec_from_loader, module_from_spec from importlib.machinery import SourceFileLoader spec = spec_from_loader("downloadIsisData", SourceFileLoader("downloadIsisData", "../scripts/downloadIsisData")) downloadIsisData = module_from_spec(spec) spec.loader.exec_module(downloadIsisData) did = downloadIsisData # from downloadIsisData import rclone, create_rclone_arguments class MockedPopen: def __init__(self, args, **kwargs): Loading Loading @@ -36,27 +44,22 @@ class MockedBustedPopen: def __init__(self, args, **kwargs): raise Exception("idk what happened") @mock.patch('downloadIsisData.which', return_value=False) def test_rclone_not_installed(mock_which): with pytest.raises(ProcessLookupError, match="rclone is not installed"): rclone("lsf", "test", extra_args=["-l", "-R", "--format", "p", "--files-only"], redirect_stdout=True, redirect_stderr=True) @mock.patch("subprocess.Popen", MockedPopen) def test_rclone(): res = rclone("lsf", "test", extra_args=["-l", "-R", "--format", "p", "--files-only"], redirect_stdout=True, redirect_stderr=True) res = did.rclone("lsf", "test", extra_args=["-l", "-R", "--format", "p", "--files-only"], redirect_stdout=True, redirect_stderr=True) assert res["out"].decode() == "Success" @mock.patch("subprocess.Popen", MockedBustedPopen) def test_rclone_unknown_exception(): with pytest.raises(Exception, match="idk"): res = rclone("lsf", "test", extra_args=["-l", "-R", "--format", "p", "--files-only"], redirect_stdout=True, redirect_stderr=True) res = did.rclone("lsf", "test", extra_args=["-l", "-R", "--format", "p", "--files-only"], redirect_stdout=True, redirect_stderr=True) def test_create_rclone_args(): with TemporaryDirectory() as tdir: dest = Path(tdir) / "test" args = create_rclone_arguments(str(dest), "lro_naifKernels:", dry_run=False, ntransfers=100) args = did.create_rclone_arguments(str(dest), "lro_naifKernels:", dry_run=False, ntransfers=100) assert args == ['lro_naifKernels:', str(dest/"lro"/"kernels"), '--progress', '--checkers=100', '--transfers=100', '--track-renames', '--log-level=WARNING'] assert dest.exists() Loading Loading
isis/CMakeLists.txt +1 −1 Original line number Diff line number Diff line Loading @@ -609,7 +609,7 @@ install(FILES ${CMAKE_SOURCE_DIR}/../CHANGELOG.md DESTINATION ${CMAKE_INSTA install(FILES ${CMAKE_BINARY_DIR}/version DESTINATION ${CMAKE_INSTALL_PREFIX}) install(DIRECTORY ${CMAKE_SOURCE_DIR}/scripts DESTINATION ${CMAKE_INSTALL_PREFIX}) install(PROGRAMS ${CMAKE_BINARY_DIR}/lib/Camera.plugin DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/) install(PROGRAMS ${CMAKE_SOURCE_DIR}/scripts/downloadIsisData.py DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/) install(PROGRAMS ${CMAKE_SOURCE_DIR}/scripts/downloadIsisData DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/) install(PROGRAMS ${CMAKE_SOURCE_DIR}/config/rclone.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/isis/) # Trigger all post-install behavior. Loading
isis/pytests/test_IsisDownload.py +12 −9 Original line number Diff line number Diff line Loading @@ -8,7 +8,15 @@ from unittest import mock from tempfile import TemporaryDirectory from pathlib import Path from downloadIsisData import rclone, create_rclone_arguments from importlib.util import spec_from_loader, module_from_spec from importlib.machinery import SourceFileLoader spec = spec_from_loader("downloadIsisData", SourceFileLoader("downloadIsisData", "../scripts/downloadIsisData")) downloadIsisData = module_from_spec(spec) spec.loader.exec_module(downloadIsisData) did = downloadIsisData # from downloadIsisData import rclone, create_rclone_arguments class MockedPopen: def __init__(self, args, **kwargs): Loading Loading @@ -36,27 +44,22 @@ class MockedBustedPopen: def __init__(self, args, **kwargs): raise Exception("idk what happened") @mock.patch('downloadIsisData.which', return_value=False) def test_rclone_not_installed(mock_which): with pytest.raises(ProcessLookupError, match="rclone is not installed"): rclone("lsf", "test", extra_args=["-l", "-R", "--format", "p", "--files-only"], redirect_stdout=True, redirect_stderr=True) @mock.patch("subprocess.Popen", MockedPopen) def test_rclone(): res = rclone("lsf", "test", extra_args=["-l", "-R", "--format", "p", "--files-only"], redirect_stdout=True, redirect_stderr=True) res = did.rclone("lsf", "test", extra_args=["-l", "-R", "--format", "p", "--files-only"], redirect_stdout=True, redirect_stderr=True) assert res["out"].decode() == "Success" @mock.patch("subprocess.Popen", MockedBustedPopen) def test_rclone_unknown_exception(): with pytest.raises(Exception, match="idk"): res = rclone("lsf", "test", extra_args=["-l", "-R", "--format", "p", "--files-only"], redirect_stdout=True, redirect_stderr=True) res = did.rclone("lsf", "test", extra_args=["-l", "-R", "--format", "p", "--files-only"], redirect_stdout=True, redirect_stderr=True) def test_create_rclone_args(): with TemporaryDirectory() as tdir: dest = Path(tdir) / "test" args = create_rclone_arguments(str(dest), "lro_naifKernels:", dry_run=False, ntransfers=100) args = did.create_rclone_arguments(str(dest), "lro_naifKernels:", dry_run=False, ntransfers=100) assert args == ['lro_naifKernels:', str(dest/"lro"/"kernels"), '--progress', '--checkers=100', '--transfers=100', '--track-renames', '--log-level=WARNING'] assert dest.exists() Loading