def test_uninstall_return_default(self): ''' Test uninstall method - return ''' mock_hana_inst = MagicMock() mock_hana = MagicMock(return_value=mock_hana_inst) with patch.object(hanamod, '_init', mock_hana): hanamod.uninstall('root', 'pass', None, 'prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') mock_hana_inst.uninstall.assert_called_once_with('root', 'pass')
def test_uninstall_raise(self): ''' Test uninstall method - raise ''' mock_hana_inst = MagicMock() mock_hana_inst.uninstall.side_effect = hanamod.hana.HanaError( 'hana error') mock_hana = MagicMock(return_value=mock_hana_inst) with patch.object(hanamod, '_init', mock_hana): with pytest.raises(exceptions.CommandExecutionError) as err: hanamod.uninstall('root', 'pass', None, 'prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') mock_hana_inst.uninstall.assert_called_once_with('root', 'pass') assert 'hana error' in str(err)