示例#1
0
def test_gzip_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.gzip("/tmp/something-to-compress")
            assert not mock.called
示例#2
0
 def test_gzip(self):
     mock = MagicMock(return_value='salt')
     with patch.dict(archive.__salt__, {'cmd.run': mock}):
         ret = archive.gzip('/tmp/something-to-compress')
         self.assertEqual(['salt'], ret)
         mock.assert_called_once_with('gzip /tmp/something-to-compress',
                                      template=None)
示例#3
0
def test_gzip(unicode_filename):
    """
    Validate using the gzip 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)
示例#4
0
 def test_gzip(self):
     mock = MagicMock(return_value='salt')
     with patch.dict(archive.__salt__, {'cmd.run': mock}):
         ret = archive.gzip('/tmp/something-to-compress')
         self.assertEqual(['salt'], ret)
         mock.assert_called_once_with(
             'gzip /tmp/something-to-compress',
             template=None
         )
示例#5
0
 def test_gzip(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.gzip('/tmp/something-to-compress')
             self.assertEqual(['salt'], ret)
             mock.assert_called_once_with(
                 ['gzip', '/tmp/something-to-compress'],
                 runas=None, python_shell=False, template=None
             )
示例#6
0
def test_gzip():
    mock = MagicMock(return_value="salt")
    with patch.dict(archive.__salt__, {"cmd.run": mock}):
        with patch("salt.utils.path.which", lambda exe: exe):
            ret = archive.gzip("/tmp/something-to-compress")
            assert ["salt"] == ret
            mock.assert_called_once_with(
                ["gzip", "/tmp/something-to-compress"],
                runas=None,
                python_shell=False,
                template=None,
            )