Beispiel #1
0
    def test_rar(self):
        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.rar(
                '/tmp/rarfile.rar',
                '/tmp/sourcefile1,/tmp/sourcefile2'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'rar a -idp /tmp/rarfile.rar '
                '/tmp/sourcefile1 /tmp/sourcefile2',
                template=None
            )

        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.rar(
                '/tmp/rarfile.rar',
                ['/tmp/sourcefile1', '/tmp/sourcefile2']
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'rar a -idp /tmp/rarfile.rar '
                '/tmp/sourcefile1 /tmp/sourcefile2',
                template=None
            )
Beispiel #2
0
    def test_rar(self):
        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.rar(
                '/tmp/rarfile.rar',
                '/tmp/sourcefile1,/tmp/sourcefile2'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                ['rar', 'a', '-idp', '/tmp/rarfile.rar',
                 '/tmp/sourcefile1', '/tmp/sourcefile2'],
                runas=None, python_shell=False, template=None, cwd=None
            )

        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.rar(
                '/tmp/rarfile.rar',
                ['/tmp/sourcefile1', '/tmp/sourcefile2']
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                ['rar', 'a', '-idp', '/tmp/rarfile.rar',
                 '/tmp/sourcefile1', '/tmp/sourcefile2'],
                runas=None, python_shell=False, template=None, cwd=None
            )
Beispiel #3
0
    def test_rar(self):
        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.rar(
                '/tmp/rarfile.rar',
                '/tmp/sourcefile1,/tmp/sourcefile2'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'rar a -idp /tmp/rarfile.rar '
                '/tmp/sourcefile1 /tmp/sourcefile2',
                template=None
            )

        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.rar(
                '/tmp/rarfile.rar',
                ['/tmp/sourcefile1', '/tmp/sourcefile2']
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                'rar a -idp /tmp/rarfile.rar '
                '/tmp/sourcefile1 /tmp/sourcefile2',
                template=None
            )
Beispiel #4
0
    def test_rar(self):
        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.rar(
                '/tmp/rarfile.rar',
                '/tmp/sourcefile1,/tmp/sourcefile2'
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                ['rar', 'a', '-idp', '/tmp/rarfile.rar',
                 '/tmp/sourcefile1', '/tmp/sourcefile2'],
                runas=None, python_shell=False, template=None, cwd=None
            )

        mock = MagicMock(return_value='salt')
        with patch.dict(archive.__salt__, {'cmd.run': mock}):
            ret = archive.rar(
                '/tmp/rarfile.rar',
                ['/tmp/sourcefile1', '/tmp/sourcefile2']
            )
            self.assertEqual(['salt'], ret)
            mock.assert_called_once_with(
                ['rar', 'a', '-idp', '/tmp/rarfile.rar',
                 '/tmp/sourcefile1', '/tmp/sourcefile2'],
                runas=None, python_shell=False, template=None, cwd=None
            )
Beispiel #5
0
def test_rar_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.rar("/tmp/rarfile.rar", "/tmp/sourcefile1,/tmp/sourcefile2")
            assert not mock.called
Beispiel #6
0
def test_rar(unicode_filename):
    """
    Validate using the rar function
    """
    with Archive("rar", unicode_filename=unicode_filename) as arch:
        ret = archive.rar(str(arch.archive), str(arch.src))
        assert isinstance(ret, list)
        arch.assert_artifacts_in_ret(ret)
Beispiel #7
0
def test_rar():
    with patch("glob.glob", lambda pathname: [pathname]):
        with patch("salt.utils.path.which", lambda exe: exe):
            mock = MagicMock(return_value="salt")
            with patch.dict(archive.__salt__, {"cmd.run": mock}):
                ret = archive.rar(
                    "/tmp/rarfile.rar", "/tmp/sourcefile1,/tmp/sourcefile2"
                )
                assert ["salt"] == ret
                mock.assert_called_once_with(
                    [
                        "rar",
                        "a",
                        "-idp",
                        "/tmp/rarfile.rar",
                        "/tmp/sourcefile1",
                        "/tmp/sourcefile2",
                    ],
                    runas=None,
                    python_shell=False,
                    template=None,
                    cwd=None,
                )

            mock = MagicMock(return_value="salt")
            with patch.dict(archive.__salt__, {"cmd.run": mock}):
                ret = archive.rar(
                    "/tmp/rarfile.rar", ["/tmp/sourcefile1", "/tmp/sourcefile2"]
                )
                assert ["salt"] == ret
                mock.assert_called_once_with(
                    [
                        "rar",
                        "a",
                        "-idp",
                        "/tmp/rarfile.rar",
                        "/tmp/sourcefile1",
                        "/tmp/sourcefile2",
                    ],
                    runas=None,
                    python_shell=False,
                    template=None,
                    cwd=None,
                )