def test_download_with_error(self, exists, mkdir): spreads.config['keep'] = False exists.return_value = False flow.os.mkdir = mkdir flow.os.path.exists = exists self.cams[0].download_files.side_effect = Exception flow.download(devices=self.cams, path='/tmp/foo')
def download(args=None, path=None, devices=None): if args and args.path: path = args.path if not devices: devices = get_devices() status_str = "Downloading {0} images from devices" if config['download']['keep'].get(bool) or config['keep'].get(bool): status_str = status_str.format("and deleting ") else: status_str = status_str.format("") print(colorama.Fore.GREEN + status_str) workflow.download(devices, path)
def test_download_noparallel(self, exists, mkdir): spreads.config['keep'] = False spreads.config['parallel_download'] = False exists.return_value = False flow.os.mkdir = mkdir flow.os.path.exists = exists flow.download(devices=self.cams, path='/tmp/foo') # TODO: Find a way to verify that the cameras were indeed called # in sequence and not in parallel for cam in self.cams: assert cam.download_files.call_count == 1 assert cam.download_files.call_args_list == [call('/tmp/foo/{0}' .format(cam.orientation.lower()))] assert cam.delete_files.call_count == 1
def test_download_noparallel(self, exists, mkdir): spreads.config['keep'] = False spreads.config['parallel_download'] = False exists.return_value = False flow.os.mkdir = mkdir flow.os.path.exists = exists flow.download(devices=self.cams, path='/tmp/foo') # TODO: Find a way to verify that the cameras were indeed called # in sequence and not in parallel for cam in self.cams: assert cam.download_files.call_count == 1 assert cam.download_files.call_args_list == [ call('/tmp/foo/{0}'.format(cam.orientation.lower())) ] assert cam.delete_files.call_count == 1
def test_download(self, exists, mkdir): spreads.config['keep'] = False exists.return_value = False flow.os.mkdir = mkdir flow.os.path.exists = exists flow.download(devices=self.cams, path='/tmp/foo') assert flow.os.mkdir.call_count == 3 assert call('/tmp/foo') in flow.os.mkdir.call_args_list assert call('/tmp/foo/right') in flow.os.mkdir.call_args_list assert call('/tmp/foo/left') in flow.os.mkdir.call_args_list for cam in self.cams: assert cam.download_files.call_count == 1 assert cam.download_files.call_args_list == [call('/tmp/foo/{0}' .format(cam.orientation.lower()))] assert cam.delete_files.call_count == 1 for plug in self.plugins: assert plug.obj.download.call_count == 1 assert plug.obj.download.call_args_list == [call( self.cams, '/tmp/foo')] assert plug.obj.delete.call_count == 1 assert plug.obj.delete.call_args_list == [call(self.cams)]
def test_download(self, exists, mkdir): spreads.config['keep'] = False exists.return_value = False flow.os.mkdir = mkdir flow.os.path.exists = exists flow.download(devices=self.cams, path='/tmp/foo') assert flow.os.mkdir.call_count == 3 assert call('/tmp/foo') in flow.os.mkdir.call_args_list assert call('/tmp/foo/right') in flow.os.mkdir.call_args_list assert call('/tmp/foo/left') in flow.os.mkdir.call_args_list for cam in self.cams: assert cam.download_files.call_count == 1 assert cam.download_files.call_args_list == [ call('/tmp/foo/{0}'.format(cam.orientation.lower())) ] assert cam.delete_files.call_count == 1 for plug in self.plugins: assert plug.obj.download.call_count == 1 assert plug.obj.download.call_args_list == [ call(self.cams, '/tmp/foo') ] assert plug.obj.delete.call_count == 1 assert plug.obj.delete.call_args_list == [call(self.cams)]