def test_gunzip_raises_exception_if_not_found(): mock = MagicMock(return_value="salt") with patch.dict(archive.__salt__, {"cmd.run": mock}): with patch("salt.utils.path.which", lambda exe: None): with pytest.raises(CommandNotFoundError): archive.gunzip("/tmp/something-to-decompress.tar.gz") assert not mock.called
def test_gunzip(self): mock = MagicMock(return_value='salt') with patch.dict(archive.__salt__, {'cmd.run': mock}): ret = archive.gunzip('/tmp/something-to-decompress.tar.gz') self.assertEqual(['salt'], ret) mock.assert_called_once_with( 'gunzip /tmp/something-to-decompress.tar.gz', template=None)
def test_gunzip(self): mock = MagicMock(return_value='salt') with patch.dict(archive.__salt__, {'cmd.run': mock}): ret = archive.gunzip('/tmp/something-to-decompress.tar.gz') self.assertEqual(['salt'], ret) mock.assert_called_once_with( 'gunzip /tmp/something-to-decompress.tar.gz', template=None )
def test_gunzip(self): mock = MagicMock(return_value='salt') with patch.dict(archive.__salt__, {'cmd.run': mock}): with patch('salt.utils.path.which', lambda exe: exe): ret = archive.gunzip('/tmp/something-to-decompress.tar.gz') self.assertEqual(['salt'], ret) mock.assert_called_once_with( ['gunzip', '/tmp/something-to-decompress.tar.gz'], runas=None, python_shell=False, template=None )
def test_gunzip(): mock = MagicMock(return_value="salt") with patch.dict(archive.__salt__, {"cmd.run": mock}): with patch("salt.utils.path.which", lambda exe: exe): ret = archive.gunzip("/tmp/something-to-decompress.tar.gz") assert ["salt"] == ret mock.assert_called_once_with( ["gunzip", "/tmp/something-to-decompress.tar.gz"], runas=None, python_shell=False, template=None, )
def test_gunzip(unicode_filename): """ Validate using the gunzip function """ with Archive("gz", unicode_filename=unicode_filename) as arch: ret = archive.gzip(str(arch.src_file), options="-v") assert isinstance(ret, list) arch.assert_artifacts_in_ret(ret, file_only=True) ret = archive.gunzip(str(arch.src_file) + ".gz", options="-v") assert isinstance(ret, list) arch.assert_artifacts_in_ret(ret, file_only=True)