Beispiel #1
0
def test_utils_extract_archive(mock_exec_ssh_command):
    client = MagicMock()

    mock_exec_ssh_command.return_value = 'archive successfully extracted!'

    # Test gzip
    ipa_utils.extract_archive(client, 'archive.tar.gz', extract_path='/tmp/')
    mock_exec_ssh_command.assert_called_once_with(
        client, 'tar -xf archive.tar.gz -C /tmp/')
    mock_exec_ssh_command.reset_mock()
Beispiel #2
0
    def extract_archive(self, client, archive_path, extract_path=None):
        """Extract the archive files using the client in the current path."""
        try:
            out = ipa_utils.extract_archive(client, archive_path, extract_path)
        except Exception as error:
            raise IpaCloudException(
                'Failed to extract archive, "{0}": {1}.'.format(
                    archive_path, error))

        else:
            self._write_to_log(out)