def test_invalidTypeForPath(self): local_path = pathlib.Path(self._test_local_dir).joinpath( self._test_filename) with open(local_path, 'w') as f: f.write('hello world') with self.assertRaises(TypeError): push_to_remote(self.client, local_path, self._test_remote_dir)
def test_pushFileToRemote(self): remote_path = os.path.join(self._test_remote_dir, self._test_filename) local_path = os.path.join(self._test_local_dir, self._test_filename) with open(local_path, 'w') as f: f.write('hello world') push_to_remote(self.client, local_path, self._test_remote_dir) self.assertTrue(os.path.isfile(remote_path))
def test_pushDirectoryToRemote(self): remote_dir = os.path.join(self._test_remote_dir, 'local') file_path = os.path.join(self._test_local_dir, self._test_filename) file_path_remote = os.path.join(remote_dir, self._test_filename) with open(file_path, 'w') as f: f.write('hello world') push_to_remote(self.client, self._test_local_dir, remote_dir) self.client.upload_sync.assert_called_once_with( file_path_remote, file_path)
def pushremote(self, remote_destination): """ push directory with output from local fs to remote_dir :param remote_destination: path to remote target directory """ if self._wdclient is None: raise RuntimeError('WebDAV client not setup!') logger.info('Pushing to WebDAV {} ...'.format(remote_destination)) push_to_remote(self._wdclient, self.output_folder.as_posix(), remote_destination) logger.info('... pushing completed.') return self
def test_remoteFileExists(self): remote_path = os.path.join(self._test_remote_dir, 'local') with open(remote_path, 'w') as f: f.write('hello world') with self.assertRaises(FileExistsError): push_to_remote(self.client, self._test_local_dir, remote_path)
def test_localPathDoesNotExist(self): local_path = os.path.join(self._test_local_dir, self._test_filename) with self.assertRaises(FileNotFoundError): push_to_remote(self.client, local_path, self._test_remote_dir)