Exemple #1
0
    def test_removed_with_error(self):
        '''
        Test if returns False when list packages fails
        '''

        mock = MagicMock(side_effect=CommandExecutionError)

        with patch.dict(bower.__salt__, {'bower.list': mock}):
            ret = bower.removed('underscore', '/path/to/project')
            expected = {'name': 'underscore',
                        'result': False,
                        'comment': 'Error removing \'underscore\': ',
                        'changes': {}}
            self.assertEqual(ret, expected)
Exemple #2
0
    def test_removed_not_installed(self):
        '''
        Test if it returns True when specified package is not installed
        '''

        mock = MagicMock(return_value={'underscore': {}})

        with patch.dict(bower.__salt__, {'bower.list': mock}):
            ret = bower.removed('jquery', '/path/to/project')
            expected = {'name': 'jquery',
                        'result': True,
                        'comment': 'Package \'jquery\' is not installed',
                        'changes': {}}
            self.assertEqual(ret, expected)
Exemple #3
0
    def test_removed_with_error(self):
        '''
        Test if returns False when list packages fails
        '''

        mock = MagicMock(side_effect=CommandExecutionError)

        with patch.dict(bower.__salt__, {'bower.list': mock}):
            ret = bower.removed('underscore', '/path/to/project')
            expected = {
                'name': 'underscore',
                'result': False,
                'comment': 'Error removing \'underscore\': ',
                'changes': {}
            }
            self.assertEqual(ret, expected)
Exemple #4
0
    def test_removed_not_installed(self):
        '''
        Test if it returns True when specified package is not installed
        '''

        mock = MagicMock(return_value={'underscore': {}})

        with patch.dict(bower.__salt__, {'bower.list': mock}):
            ret = bower.removed('jquery', '/path/to/project')
            expected = {
                'name': 'jquery',
                'result': True,
                'comment': 'Package \'jquery\' is not installed',
                'changes': {}
            }
            self.assertEqual(ret, expected)
Exemple #5
0
def test_removed_with_error():
    """
    Test if returns False when list packages fails
    """

    mock = MagicMock(side_effect=CommandExecutionError)

    with patch.dict(bower.__salt__, {"bower.list": mock}):
        ret = bower.removed("underscore", "/path/to/project")
        expected = {
            "name": "underscore",
            "result": False,
            "comment": "Error removing 'underscore': ",
            "changes": {},
        }
        assert ret == expected
Exemple #6
0
def test_removed_not_installed():
    """
    Test if it returns True when specified package is not installed
    """

    mock = MagicMock(return_value={"underscore": {}})

    with patch.dict(bower.__salt__, {"bower.list": mock}):
        ret = bower.removed("jquery", "/path/to/project")
        expected = {
            "name": "jquery",
            "result": True,
            "comment": "Package 'jquery' is not installed",
            "changes": {},
        }
        assert ret == expected
Exemple #7
0
    def test_removed_existing_with_error(self):
        '''
        Test if it returns False when specified package is installed and
        uninstall fails
        '''

        mock_list = MagicMock(return_value={'underscore': {}})
        mock_uninstall = MagicMock(side_effect=CommandExecutionError)

        with patch.dict(bower.__salt__, {'bower.list': mock_list,
                                         'bower.uninstall': mock_uninstall}):
            ret = bower.removed('underscore', '/path/to/project')
            expected = {'name': 'underscore',
                        'result': False,
                        'comment':
                            'Error removing \'underscore\': ',
                        'changes': {}}
            self.assertEqual(ret, expected)
Exemple #8
0
    def test_removed_existing(self):
        '''
        Test if it returns True when specified package is installed and
        uninstall succeeds
        '''

        mock_list = MagicMock(return_value={'underscore': {}})
        mock_uninstall = MagicMock(return_value=True)

        with patch.dict(bower.__salt__, {'bower.list': mock_list,
                                         'bower.uninstall': mock_uninstall}):
            ret = bower.removed('underscore', '/path/to/project')
            expected = {'name': 'underscore',
                        'result': True,
                        'comment':
                            'Package \'underscore\' was successfully removed',
                        'changes': {'underscore': 'Removed'}}
            self.assertEqual(ret, expected)
Exemple #9
0
def test_removed_existing_with_error():
    """
    Test if it returns False when specified package is installed and
    uninstall fails
    """

    mock_list = MagicMock(return_value={"underscore": {}})
    mock_uninstall = MagicMock(side_effect=CommandExecutionError)

    with patch.dict(
        bower.__salt__, {"bower.list": mock_list, "bower.uninstall": mock_uninstall}
    ):
        ret = bower.removed("underscore", "/path/to/project")
        expected = {
            "name": "underscore",
            "result": False,
            "comment": "Error removing 'underscore': ",
            "changes": {},
        }
        assert ret == expected
Exemple #10
0
def test_removed_existing():
    """
    Test if it returns True when specified package is installed and
    uninstall succeeds
    """

    mock_list = MagicMock(return_value={"underscore": {}})
    mock_uninstall = MagicMock(return_value=True)

    with patch.dict(
        bower.__salt__, {"bower.list": mock_list, "bower.uninstall": mock_uninstall}
    ):
        ret = bower.removed("underscore", "/path/to/project")
        expected = {
            "name": "underscore",
            "result": True,
            "comment": "Package 'underscore' was successfully removed",
            "changes": {"underscore": "Removed"},
        }
        assert ret == expected
Exemple #11
0
    def test_removed_existing_with_error(self):
        '''
        Test if it returns False when specified package is installed and
        uninstall fails
        '''

        mock_list = MagicMock(return_value={'underscore': {}})
        mock_uninstall = MagicMock(side_effect=CommandExecutionError)

        with patch.dict(bower.__salt__, {
                'bower.list': mock_list,
                'bower.uninstall': mock_uninstall
        }):
            ret = bower.removed('underscore', '/path/to/project')
            expected = {
                'name': 'underscore',
                'result': False,
                'comment': 'Error removing \'underscore\': ',
                'changes': {}
            }
            self.assertEqual(ret, expected)
Exemple #12
0
    def test_removed_existing(self):
        '''
        Test if it returns True when specified package is installed and
        uninstall succeeds
        '''

        mock_list = MagicMock(return_value={'underscore': {}})
        mock_uninstall = MagicMock(return_value=True)

        with patch.dict(bower.__salt__, {
                'bower.list': mock_list,
                'bower.uninstall': mock_uninstall
        }):
            ret = bower.removed('underscore', '/path/to/project')
            expected = {
                'name': 'underscore',
                'result': True,
                'comment': 'Package \'underscore\' was successfully removed',
                'changes': {
                    'underscore': 'Removed'
                }
            }
            self.assertEqual(ret, expected)