def test_init_raise(self, mock_hana): ''' Test _init method ''' mock_hana.side_effect = TypeError('error') with pytest.raises(exceptions.SaltInvocationError) as err: hanamod._init('prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') assert 'error' in str(err)
def test_init_return(self, mock_hana): ''' Test _init method ''' mock_hana_inst = MagicMock() mock_hana.return_value = mock_hana_inst hana_inst = hanamod._init('prd', '00', 'pass') mock_hana.assert_called_once_with('prd', '00', 'pass') assert mock_hana_inst == hana_inst
def test_init_return_conf(self, mock_hana): ''' Test _init method ''' mock_hana_inst = MagicMock() mock_hana.return_value = mock_hana_inst mock_config = MagicMock( side_effect=['conf_sid', 'conf_inst', 'conf_password']) with patch.dict(hanamod.__salt__, {'config.option': mock_config}): hana_inst = hanamod._init() mock_hana.assert_called_once_with('conf_sid', 'conf_inst', 'conf_password') assert mock_hana_inst == hana_inst mock_config.assert_has_calls([ mock.call('hana.sid', None), mock.call('hana.inst', None), mock.call('hana.password', None) ])