示例#1
0
    def test_installed_not_needed(self):
        '''
        Test if it returns True when there is nothing to install
        '''

        mock = MagicMock(
            return_value={
                'underscore': {
                    'pkgMeta': {
                        'version': '1.7.0'
                    }
                },
                'jquery': {
                    'pkgMeta': {
                        'version': '2.0.0'
                    }
                }
            })

        with patch.dict(bower.__salt__, {'bower.list': mock}):
            ret = bower.installed('test', '/path/to/project',
                                  ['underscore', 'jquery#2.0.0'])
            expected = {
                'name':
                'test',
                'result':
                True,
                'comment': ('Package(s) \'underscore, jquery#2.0.0\''
                            ' satisfied by underscore#1.7.0, jquery#2.0.0'),
                'changes': {}
            }
            self.assertEqual(ret, expected)
示例#2
0
def test_installed_not_needed():
    """
    Test if it returns True when there is nothing to install
    """

    mock = MagicMock(
        return_value={
            "underscore": {
                "pkgMeta": {
                    "version": "1.7.0"
                }
            },
            "jquery": {
                "pkgMeta": {
                    "version": "2.0.0"
                }
            },
        })

    with patch.dict(bower.__salt__, {"bower.list": mock}):
        ret = bower.installed("test", "/path/to/project",
                              ["underscore", "jquery#2.0.0"])
        expected = {
            "name":
            "test",
            "result":
            True,
            "comment": ("Package(s) 'underscore, jquery#2.0.0'"
                        " satisfied by underscore#1.7.0, jquery#2.0.0"),
            "changes": {},
        }
        assert ret == expected
示例#3
0
文件: bower_test.py 项目: DaveQB/salt
    def test_installed_with_error(self):
        '''
        Test if it returns False when list packages fails
        '''

        mock = MagicMock(side_effect=CommandExecutionError)

        with patch.dict(bower.__salt__, {'bower.list': mock}):
            ret = bower.installed('underscore', '/path/to/project')
            expected = {'name': 'underscore',
                        'result': False,
                        'comment': 'Error looking up \'underscore\': ',
                        'changes': {}}
            self.assertEqual(ret, expected)
示例#4
0
    def test_installed_with_error(self):
        '''
        Test if it returns False when list packages fails
        '''

        mock = MagicMock(side_effect=CommandExecutionError)

        with patch.dict(bower.__salt__, {'bower.list': mock}):
            ret = bower.installed('underscore', '/path/to/project')
            expected = {
                'name': 'underscore',
                'result': False,
                'comment': 'Error looking up \'underscore\': ',
                'changes': {}
            }
            self.assertEqual(ret, expected)
示例#5
0
文件: bower_test.py 项目: DaveQB/salt
    def test_installed_new_with_exc(self):
        '''
        Test if it returns False when install packages fails (exception)
        '''

        mock_list = MagicMock(return_value={})
        mock_install = MagicMock(side_effect=CommandExecutionError)

        with patch.dict(bower.__salt__, {'bower.list': mock_list,
                                         'bower.install': mock_install}):
            ret = bower.installed('underscore', '/path/to/project')
            expected = {'name': 'underscore',
                        'result': False,
                        'comment': 'Error installing \'underscore\': ',
                        'changes': {}}
            self.assertEqual(ret, expected)
示例#6
0
def test_installed_with_error():
    """
    Test if it returns False when list packages fails
    """

    mock = MagicMock(side_effect=CommandExecutionError)

    with patch.dict(bower.__salt__, {"bower.list": mock}):
        ret = bower.installed("underscore", "/path/to/project")
        expected = {
            "name": "underscore",
            "result": False,
            "comment": "Error looking up 'underscore': ",
            "changes": {},
        }
        assert ret == expected
示例#7
0
文件: bower_test.py 项目: DaveQB/salt
    def test_installed_success(self):
        '''
        Test if it returns True when install succeeds
        '''

        mock_list = MagicMock(return_value={})
        mock_install = MagicMock(return_value=True)

        with patch.dict(bower.__salt__, {'bower.list': mock_list,
                                         'bower.install': mock_install}):
            ret = bower.installed('underscore', '/path/to/project')
            expected = {'name': 'underscore',
                        'result': True,
                        'comment':
                            'Package(s) \'underscore\' successfully installed',
                        'changes': {'new': ['underscore'], 'old': []}}
            self.assertEqual(ret, expected)
示例#8
0
文件: bower_test.py 项目: DaveQB/salt
    def test_installed_new_with_error(self):
        '''
        Test if returns False when install packages fails (bower error)
        '''

        mock_list = MagicMock(return_value={})
        mock_install = MagicMock(return_value=False)

        with patch.dict(bower.__salt__, {'bower.list': mock_list,
                                         'bower.install': mock_install}):
            ret = bower.installed('underscore', '/path/to/project')
            expected = {'name': 'underscore',
                        'result': False,
                        'comment':
                            'Could not install package(s) \'underscore\'',
                        'changes': {}}
            self.assertEqual(ret, expected)
示例#9
0
def test_installed_success():
    """
    Test if it returns True when install succeeds
    """

    mock_list = MagicMock(return_value={})
    mock_install = MagicMock(return_value=True)

    with patch.dict(
        bower.__salt__, {"bower.list": mock_list, "bower.install": mock_install}
    ):
        ret = bower.installed("underscore", "/path/to/project")
        expected = {
            "name": "underscore",
            "result": True,
            "comment": "Package(s) 'underscore' successfully installed",
            "changes": {"new": ["underscore"], "old": []},
        }
        assert ret == expected
示例#10
0
def test_installed_new_with_error():
    """
    Test if returns False when install packages fails (bower error)
    """

    mock_list = MagicMock(return_value={})
    mock_install = MagicMock(return_value=False)

    with patch.dict(
        bower.__salt__, {"bower.list": mock_list, "bower.install": mock_install}
    ):
        ret = bower.installed("underscore", "/path/to/project")
        expected = {
            "name": "underscore",
            "result": False,
            "comment": "Could not install package(s) 'underscore'",
            "changes": {},
        }
        assert ret == expected
示例#11
0
def test_installed_new_with_exc():
    """
    Test if it returns False when install packages fails (exception)
    """

    mock_list = MagicMock(return_value={})
    mock_install = MagicMock(side_effect=CommandExecutionError)

    with patch.dict(
        bower.__salt__, {"bower.list": mock_list, "bower.install": mock_install}
    ):
        ret = bower.installed("underscore", "/path/to/project")
        expected = {
            "name": "underscore",
            "result": False,
            "comment": "Error installing 'underscore': ",
            "changes": {},
        }
        assert ret == expected
示例#12
0
    def test_installed_new_with_error(self):
        '''
        Test if returns False when install packages fails (bower error)
        '''

        mock_list = MagicMock(return_value={})
        mock_install = MagicMock(return_value=False)

        with patch.dict(bower.__salt__, {
                'bower.list': mock_list,
                'bower.install': mock_install
        }):
            ret = bower.installed('underscore', '/path/to/project')
            expected = {
                'name': 'underscore',
                'result': False,
                'comment': 'Could not install package(s) \'underscore\'',
                'changes': {}
            }
            self.assertEqual(ret, expected)
示例#13
0
    def test_installed_new_with_exc(self):
        '''
        Test if it returns False when install packages fails (exception)
        '''

        mock_list = MagicMock(return_value={})
        mock_install = MagicMock(side_effect=CommandExecutionError)

        with patch.dict(bower.__salt__, {
                'bower.list': mock_list,
                'bower.install': mock_install
        }):
            ret = bower.installed('underscore', '/path/to/project')
            expected = {
                'name': 'underscore',
                'result': False,
                'comment': 'Error installing \'underscore\': ',
                'changes': {}
            }
            self.assertEqual(ret, expected)
示例#14
0
文件: bower_test.py 项目: DaveQB/salt
    def test_installed_not_needed(self):
        '''
        Test if it returns True when there is nothing to install
        '''

        mock = MagicMock(return_value={
            'underscore': {
                'pkgMeta': {'version': '1.7.0'}},
            'jquery': {
                'pkgMeta': {'version': '2.0.0'}}})

        with patch.dict(bower.__salt__, {'bower.list': mock}):
            ret = bower.installed('test', '/path/to/project',
                                  ['underscore', 'jquery#2.0.0'])
            expected = {'name': 'test',
                        'result': True,
                        'comment':
                            ('Package(s) \'underscore, jquery#2.0.0\''
                             ' satisfied by underscore#1.7.0, jquery#2.0.0'),
                        'changes': {}}
            self.assertEqual(ret, expected)
示例#15
0
    def test_installed_success(self):
        '''
        Test if it returns True when install succeeds
        '''

        mock_list = MagicMock(return_value={})
        mock_install = MagicMock(return_value=True)

        with patch.dict(bower.__salt__, {
                'bower.list': mock_list,
                'bower.install': mock_install
        }):
            ret = bower.installed('underscore', '/path/to/project')
            expected = {
                'name': 'underscore',
                'result': True,
                'comment': 'Package(s) \'underscore\' successfully installed',
                'changes': {
                    'new': ['underscore'],
                    'old': []
                }
            }
            self.assertEqual(ret, expected)