def test_remove(self):
        with patch.dict(alternatives.__grains__, {"os_family": "RedHat"}):
            mock = MagicMock(return_value={"retcode": 0, "stdout": "salt"})
            with patch.dict(alternatives.__salt__, {"cmd.run_all": mock}):
                solution = alternatives.remove("better-world", "/usr/bin/better-world")
                self.assertEqual("salt", solution)
                mock.assert_called_once_with(
                    ["alternatives", "--remove", "better-world", "/usr/bin/better-world"], python_shell=False
                )

        with patch.dict(alternatives.__grains__, {"os_family": "Debian"}):
            mock = MagicMock(return_value={"retcode": 0, "stdout": "salt"})
            with patch.dict(alternatives.__salt__, {"cmd.run_all": mock}):
                solution = alternatives.remove("better-world", "/usr/bin/better-world")
                self.assertEqual("salt", solution)
                mock.assert_called_once_with(
                    ["update-alternatives", "--remove", "better-world", "/usr/bin/better-world"], python_shell=False
                )

        with patch.dict(alternatives.__grains__, {"os_family": "RedHat"}):
            mock = MagicMock(return_value={"retcode": 1, "stdout": "salt-out", "stderr": "salt-err"})
            with patch.dict(alternatives.__salt__, {"cmd.run_all": mock}):
                solution = alternatives.remove("better-world", "/usr/bin/better-world")
                self.assertEqual("salt-err", solution)
                mock.assert_called_once_with(
                    ["alternatives", "--remove", "better-world", "/usr/bin/better-world"], python_shell=False
                )
Пример #2
0
    def test_remove(self):
        with patch.dict(alternatives.__grains__, {"os_family": "RedHat"}):
            mock = MagicMock(return_value={"retcode": 0, "stdout": "salt"})
            with patch.dict(alternatives.__salt__, {"cmd.run_all": mock}):
                solution = alternatives.remove(
                    "better-world",
                    "/usr/bin/better-world",
                )
                self.assertEqual("salt", solution)
                mock.assert_called_once_with(
                    [
                        "alternatives",
                        "--remove",
                        "better-world",
                        "/usr/bin/better-world",
                    ],
                    python_shell=False,
                )

        with patch.dict(alternatives.__grains__, {"os_family": "Debian"}):
            mock = MagicMock(return_value={"retcode": 0, "stdout": "salt"})
            with patch.dict(alternatives.__salt__, {"cmd.run_all": mock}):
                solution = alternatives.remove(
                    "better-world",
                    "/usr/bin/better-world",
                )
                self.assertEqual("salt", solution)
                mock.assert_called_once_with(
                    [
                        "update-alternatives",
                        "--remove",
                        "better-world",
                        "/usr/bin/better-world",
                    ],
                    python_shell=False,
                )

        with patch.dict(alternatives.__grains__, {"os_family": "RedHat"}):
            mock = MagicMock(return_value={
                "retcode": 1,
                "stdout": "salt-out",
                "stderr": "salt-err"
            })
            with patch.dict(alternatives.__salt__, {"cmd.run_all": mock}):
                solution = alternatives.remove(
                    "better-world",
                    "/usr/bin/better-world",
                )
                self.assertEqual("salt-err", solution)
                mock.assert_called_once_with(
                    [
                        "alternatives",
                        "--remove",
                        "better-world",
                        "/usr/bin/better-world",
                    ],
                    python_shell=False,
                )
Пример #3
0
    def test_remove(self):
        with patch.dict(alternatives.__grains__, {'os_family': 'RedHat'}):
            mock = MagicMock(return_value={'retcode': 0, 'stdout': 'salt'})
            with patch.dict(alternatives.__salt__, {'cmd.run_all': mock}):
                solution = alternatives.remove(
                    'better-world',
                    '/usr/bin/better-world',
                )
                self.assertEqual('salt', solution)
                mock.assert_called_once_with([
                    'alternatives', '--remove', 'better-world',
                    '/usr/bin/better-world'
                ],
                                             python_shell=False)

        with patch.dict(alternatives.__grains__, {'os_family': 'Debian'}):
            mock = MagicMock(return_value={'retcode': 0, 'stdout': 'salt'})
            with patch.dict(alternatives.__salt__, {'cmd.run_all': mock}):
                solution = alternatives.remove(
                    'better-world',
                    '/usr/bin/better-world',
                )
                self.assertEqual('salt', solution)
                mock.assert_called_once_with([
                    'update-alternatives', '--remove', 'better-world',
                    '/usr/bin/better-world'
                ],
                                             python_shell=False)

        with patch.dict(alternatives.__grains__, {'os_family': 'RedHat'}):
            mock = MagicMock(return_value={
                'retcode': 1,
                'stdout': 'salt-out',
                'stderr': 'salt-err'
            })
            with patch.dict(alternatives.__salt__, {'cmd.run_all': mock}):
                solution = alternatives.remove(
                    'better-world',
                    '/usr/bin/better-world',
                )
                self.assertEqual('salt-err', solution)
                mock.assert_called_once_with([
                    'alternatives', '--remove', 'better-world',
                    '/usr/bin/better-world'
                ],
                                             python_shell=False)
Пример #4
0
    def test_remove(self):
        with patch.dict(alternatives.__grains__, {'os_family': 'RedHat'}):
            mock = MagicMock(return_value={'retcode': 0, 'stdout': 'salt'})
            with patch.dict(alternatives.__salt__, {'cmd.run_all': mock}):
                solution = alternatives.remove(
                    'better-world',
                    '/usr/bin/better-world',
                )
                self.assertEqual('salt', solution)
                mock.assert_called_once_with(
                    ['alternatives', '--remove', 'better-world',
                     '/usr/bin/better-world'], python_shell=False
                )

        with patch.dict(alternatives.__grains__, {'os_family': 'Debian'}):
            mock = MagicMock(return_value={'retcode': 0, 'stdout': 'salt'})
            with patch.dict(alternatives.__salt__, {'cmd.run_all': mock}):
                solution = alternatives.remove(
                    'better-world',
                    '/usr/bin/better-world',
                )
                self.assertEqual('salt', solution)
                mock.assert_called_once_with(
                    ['update-alternatives', '--remove', 'better-world',
                     '/usr/bin/better-world'], python_shell=False
                )

        with patch.dict(alternatives.__grains__, {'os_family': 'RedHat'}):
            mock = MagicMock(
                return_value={
                    'retcode': 1,
                    'stdout': 'salt-out',
                    'stderr': 'salt-err'
                }
            )
            with patch.dict(alternatives.__salt__, {'cmd.run_all': mock}):
                solution = alternatives.remove(
                    'better-world',
                    '/usr/bin/better-world',
                )
                self.assertEqual('salt-err', solution)
                mock.assert_called_once_with(
                    ['alternatives', '--remove', 'better-world',
                     '/usr/bin/better-world'], python_shell=False
                )