Beispiel #1
0
    def test_removed(self):
        '''
        Test to verify that the given package is not installed.
        '''
        name = 'coffee-script'

        ret = {'name': name,
               'result': False,
               'comment': '',
               'changes': {}}

        mock_err = MagicMock(side_effect=[CommandExecutionError, {},
                                          {name: ''}, {name: ''}])
        mock_t = MagicMock(return_value=True)
        with patch.dict(npm.__salt__, {'npm.list': mock_err,
                                       'npm.uninstall': mock_t}):
            comt = ("Error uninstalling 'coffee-script': ")
            ret.update({'comment': comt})
            self.assertDictEqual(npm.removed(name), ret)

            comt = ("Package 'coffee-script' is not installed")
            ret.update({'comment': comt, 'result': True})
            self.assertDictEqual(npm.removed(name), ret)

            with patch.dict(npm.__opts__, {'test': True}):
                comt = ("Package 'coffee-script' is set to be removed")
                ret.update({'comment': comt, 'result': None})
                self.assertDictEqual(npm.removed(name), ret)

            with patch.dict(npm.__opts__, {'test': False}):
                comt = ("Package 'coffee-script' was successfully removed")
                ret.update({'comment': comt, 'result': True,
                            'changes': {name: 'Removed'}})
                self.assertDictEqual(npm.removed(name), ret)
Beispiel #2
0
def test_removed():
    """
    Test to verify that the given package is not installed.
    """
    name = "coffee-script"

    ret = {"name": name, "result": False, "comment": "", "changes": {}}

    mock_err = MagicMock(
        side_effect=[CommandExecutionError, {}, {name: ""}, {name: ""}]
    )
    mock_t = MagicMock(return_value=True)
    with patch.dict(npm.__salt__, {"npm.list": mock_err, "npm.uninstall": mock_t}):
        comt = "Error uninstalling 'coffee-script': "
        ret.update({"comment": comt})
        assert npm.removed(name) == ret

        comt = "Package 'coffee-script' is not installed"
        ret.update({"comment": comt, "result": True})
        assert npm.removed(name) == ret

        with patch.dict(npm.__opts__, {"test": True}):
            comt = "Package 'coffee-script' is set to be removed"
            ret.update({"comment": comt, "result": None})
            assert npm.removed(name) == ret

        with patch.dict(npm.__opts__, {"test": False}):
            comt = "Package 'coffee-script' was successfully removed"
            ret.update({"comment": comt, "result": True, "changes": {name: "Removed"}})
            assert npm.removed(name) == ret
Beispiel #3
0
    def test_removed(self):
        '''
        Test to verify that the given package is not installed.
        '''
        name = 'coffee-script'

        ret = {'name': name,
               'result': False,
               'comment': '',
               'changes': {}}

        mock_err = MagicMock(side_effect=[CommandExecutionError, {},
                                          {name: ''}, {name: ''}])
        mock_t = MagicMock(return_value=True)
        with patch.dict(npm.__salt__, {'npm.list': mock_err,
                                       'npm.uninstall': mock_t}):
            comt = ("Error uninstalling 'coffee-script': ")
            ret.update({'comment': comt})
            self.assertDictEqual(npm.removed(name), ret)

            comt = ("Package 'coffee-script' is not installed")
            ret.update({'comment': comt, 'result': True})
            self.assertDictEqual(npm.removed(name), ret)

            with patch.dict(npm.__opts__, {'test': True}):
                comt = ("Package 'coffee-script' is set to be removed")
                ret.update({'comment': comt, 'result': None})
                self.assertDictEqual(npm.removed(name), ret)

            with patch.dict(npm.__opts__, {'test': False}):
                comt = ("Package 'coffee-script' was successfully removed")
                ret.update({'comment': comt, 'result': True,
                            'changes': {name: 'Removed'}})
                self.assertDictEqual(npm.removed(name), ret)