@patch('salt.modules.bower._check_valid_version',
           MagicMock(return_value=True))
    def test_install_with_error(self):
        mock = MagicMock(return_value={'retcode': 1, 'stderr': 'error'})
        with patch.dict(bower.__salt__, {'cmd.run_all': mock}):
            self.assertRaises(
                CommandExecutionError,
                bower.install,
                '/path/to/project',
                'underscore')
Test if it raises an exception when install package fails
dataset/ETHPy150Open saltstack/salt/tests/unit/modules/bower_test.py/BowerTestCase.test_install_with_error