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 )
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 )
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
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)
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, )