def test_uninstalled_error(self):
        '''
        Test to check uninstalled when hana uninstall method fails
        '''

        ret = {
            'name': 'prd',
            'changes': {},
            'result': False,
            'comment': 'hana command error'
        }

        mock_installed = MagicMock(return_value=True)
        mock_uninstall = MagicMock(
            side_effect=exceptions.CommandExecutionError('hana command error'))
        with patch.dict(hanamod.__salt__, {
                'hana.is_installed': mock_installed,
                'hana.uninstall': mock_uninstall
        }):
            assert hanamod.uninstalled('prd',
                                       '00',
                                       'pass',
                                       'root',
                                       'pass',
                                       installation_folder='/hana') == ret
            mock_uninstall.assert_called_once_with(root_user='******',
                                                   root_password='******',
                                                   sid='prd',
                                                   inst='00',
                                                   password='******',
                                                   installation_folder='/hana')
    def test_uninstalled(self):
        '''
        Test to check uninstalled when hana is installed
        '''

        ret = {
            'name': 'prd',
            'changes': {
                'sid': 'prd'
            },
            'result': True,
            'comment': 'HANA uninstalled'
        }

        mock_is_installed = MagicMock(return_value=True)
        mock_uninstall = MagicMock()
        with patch.dict(
                hanamod.__salt__, {
                    'hana.is_installed': mock_is_installed,
                    'hana.uninstall': mock_uninstall
                }):
            assert hanamod.uninstalled('prd',
                                       '00',
                                       'pass',
                                       'root',
                                       'pass',
                                       installation_folder='/hana') == ret
            mock_uninstall.assert_called_once_with(root_user='******',
                                                   root_password='******',
                                                   sid='prd',
                                                   inst='00',
                                                   password='******',
                                                   installation_folder='/hana')
    def test_uninstalled_uinstalled(self):
        '''
        Test to check uninstalled when hana is already installed
        '''

        ret = {
            'name': 'prd',
            'changes': {},
            'result': True,
            'comment': 'HANA already not installed'
        }

        mock_installed = MagicMock(return_value=False)
        with patch.dict(hanamod.__salt__,
                        {'hana.is_installed': mock_installed}):
            assert hanamod.uninstalled('prd', '00', 'pass', 'root',
                                       'pass') == ret
    def test_uninstalled_test(self):
        '''
        Test to check uninstalled in test mode
        '''

        ret = {
            'name': 'prd',
            'changes': {
                'sid': 'prd'
            },
            'result': None,
            'comment': '{} would be uninstalled'.format('prd')
        }

        mock_installed = MagicMock(return_value=True)
        with patch.dict(hanamod.__salt__,
                        {'hana.is_installed': mock_installed}):
            with patch.dict(hanamod.__opts__, {'test': True}):
                assert hanamod.uninstalled('prd', '00', 'pass', 'root',
                                           'pass') == ret