Exemplo n.º 1
0
    def test_feature_removed_removed(self):
        '''
            Test removing a feature already removed
        '''
        expected = {
            'comment': "The feature Feat2 is already removed",
            'changes': {},
            'name': 'Feat2',
            'result': True
        }

        mock_removed = MagicMock(side_effect=[['Feat1'], ['Feat1']])
        mock_remove = MagicMock()

        with patch.dict(
                dism.__salt__, {
                    'dism.installed_features': mock_removed,
                    'dism.remove_feature': mock_remove
                }):

            out = dism.feature_removed('Feat2')

            mock_removed.assert_called_once_with()
            assert not mock_remove.called
            self.assertEqual(out, expected)
Exemplo n.º 2
0
    def test_feature_removed(self):
        '''
            Test removing a feature with DISM
        '''
        expected = {
            'comment': "Removed Feat2",
            'changes': {
                'feature': {
                    'old': ['Feat2']
                },
                'retcode': 0
            },
            'name': 'Feat2',
            'result': True
        }

        mock_removed = MagicMock(side_effect=[['Feat1', 'Feat2'], ['Feat1']])
        mock_remove = MagicMock(return_value={'retcode': 0})

        with patch.dict(
                dism.__salt__, {
                    'dism.installed_features': mock_removed,
                    'dism.remove_feature': mock_remove
                }):
            with patch.dict(dism.__opts__, {'test': False}):

                out = dism.feature_removed('Feat2')

                mock_removed.assert_called_with()
                mock_remove.assert_called_once_with('Feat2', False, None,
                                                    False)
                self.assertEqual(out, expected)
Exemplo n.º 3
0
    def test_feature_removed_failure(self):
        '''
            Test removing a feature which fails with DISM
        '''
        expected = {
            'comment': "Failed to remove Feat2: Failed",
            'changes': {},
            'name': 'Feat2',
            'result': False
        }

        mock_removed = MagicMock(
            side_effect=[['Feat1', 'Feat2'], ['Feat1', 'Feat2']])
        mock_remove = MagicMock(return_value={
            'retcode': 67,
            'stdout': 'Failed'
        })

        with patch.dict(
                dism.__salt__, {
                    'dism.installed_features': mock_removed,
                    'dism.remove_feature': mock_remove
                }):
            with patch.dict(dism.__opts__, {'test': False}):

                out = dism.feature_removed('Feat2')

                mock_removed.assert_called_with()
                mock_remove.assert_called_once_with('Feat2', False, None,
                                                    False)
                self.assertEqual(out, expected)
Exemplo n.º 4
0
def test_feature_removed_removed():
    """
    Test removing a feature already removed
    """
    expected = {
        "comment": "The feature Feat2 is already removed",
        "changes": {},
        "name": "Feat2",
        "result": True,
    }

    mock_removed = MagicMock(side_effect=[["Feat1"], ["Feat1"]])
    mock_remove = MagicMock()

    with patch.dict(
            dism.__salt__,
        {
            "dism.installed_features": mock_removed,
            "dism.remove_feature": mock_remove
        },
    ):

        out = dism.feature_removed("Feat2")

        mock_removed.assert_called_once_with()
        assert not mock_remove.called
        assert out == expected
Exemplo n.º 5
0
def test_feature_removed_failure():
    """
    Test removing a feature which fails with DISM
    """
    expected = {
        "comment": "Failed to remove Feat2: Failed",
        "changes": {},
        "name": "Feat2",
        "result": False,
    }

    mock_removed = MagicMock(
        side_effect=[["Feat1", "Feat2"], ["Feat1", "Feat2"]])
    mock_remove = MagicMock(return_value={"retcode": 67, "stdout": "Failed"})

    with patch.dict(
            dism.__salt__,
        {
            "dism.installed_features": mock_removed,
            "dism.remove_feature": mock_remove
        },
    ):
        with patch.dict(dism.__opts__, {"test": False}):

            out = dism.feature_removed("Feat2")

            mock_removed.assert_called_with()
            mock_remove.assert_called_once_with("Feat2", False, None, False)
            assert out == expected
Exemplo n.º 6
0
    def test_feature_removed_failure(self):
        '''
            Test removing a feature which fails with DISM
        '''
        expected = {
            'comment': "Failed to remove Feat2: Failed",
            'changes': {},
            'name': 'Feat2',
            'result': False}

        mock_removed = MagicMock(
            side_effect=[['Feat1', 'Feat2'], ['Feat1', 'Feat2']])
        mock_remove = MagicMock(
            return_value={'retcode': 67, 'stdout': 'Failed'})

        with patch.dict(
            dism.__salt__, {'dism.installed_features': mock_removed,
                            'dism.remove_feature': mock_remove}):
            with patch.dict(dism.__opts__, {'test': False}):

                out = dism.feature_removed('Feat2')

                mock_removed.assert_called_with()
                mock_remove.assert_called_once_with(
                    'Feat2', False, None, False)
                self.assertEqual(out, expected)
Exemplo n.º 7
0
    def test_feature_removed(self):
        """
            Test removing a feature with DISM
        """
        expected = {
            "comment": "Removed Feat2",
            "changes": {
                "feature": {
                    "old": ["Feat2"]
                },
                "retcode": 0
            },
            "name": "Feat2",
            "result": True,
        }

        mock_removed = MagicMock(side_effect=[["Feat1", "Feat2"], ["Feat1"]])
        mock_remove = MagicMock(return_value={"retcode": 0})

        with patch.dict(
                dism.__salt__,
            {
                "dism.installed_features": mock_removed,
                "dism.remove_feature": mock_remove,
            },
        ):
            with patch.dict(dism.__opts__, {"test": False}):

                out = dism.feature_removed("Feat2")

                mock_removed.assert_called_with()
                mock_remove.assert_called_once_with("Feat2", False, None,
                                                    False)
                self.assertEqual(out, expected)
Exemplo n.º 8
0
    def test_feature_removed_removed(self):
        '''
            Test removing a feature already removed
        '''
        expected = {
            'comment': "The feature Feat2 is already removed",
            'changes': {},
            'name': 'Feat2',
            'result': True}

        mock_removed = MagicMock(
            side_effect=[['Feat1'], ['Feat1']])
        mock_remove = MagicMock()

        with patch.dict(
            dism.__salt__, {'dism.installed_features': mock_removed,
                            'dism.remove_feature': mock_remove}):

            out = dism.feature_removed('Feat2')

            mock_removed.assert_called_once_with()
            assert not mock_remove.called
            self.assertEqual(out, expected)